環境
- prmd 0.13.0
事象
以下のようなyamlをprmdでJSON Schemaに変換。
$ cat docs/schema/schemata/sample.yml definitions: name: description: name readOnly: true type: - string - null $ bundle exec prmd combine --meta docs/schema/meta.yml docs/schema/schemata/ > docs/schema/schema.json
生成されたJSON Schemaを検証。
$ bundle exec prmd verify docs/schema/schema.json
エラー発生
docs/schema/schema.json: #/definitions/sample/definitions/name/type: failed schema #/properties/type: No subschema in "anyOf" matched.
原因
生成されたJSON Schemaにて、nullがjavascriptの予約語としてのnullとして変換されたことが原因の模様。
"definitions": { "name": { "description": "name", "readOnly": true, "type": [ "string", null ] } }
対策
nullを文字列としてのnullとして定義する。
definitions: name: description: name readOnly: true type: - string - "null"
"definitions": { "name": { "description": "name", "readOnly": true, "type": [ "string", "null" ] } }