JSON schema
https://json-schema.org
allOf
https://nju33.com/notes/json-schema/articles/複雑な型の設定#par--JUU4JUE0JTg3JUU2JTk1JUIwJUUzJTgxJUFFJUU2JTlEJUExJUU0JUJCJUI2JUUzJTgxJTk5JUUzJTgxJUI5JUUzJTgxJUE2JUUzJTgxJUFCJUUzJTgzJTlFJUUzJTgzJTgzJUUzJTgzJTgxJUUzJTgxJTk3JUUzJTgxJUFBJUUzJTgxJTkxJUUzJTgyJThDJUUzJTgxJUIwJUUzJTgxJUFBJUUzJTgyJTg5JUUzJTgxJUFBJUUzJTgxJTg0
継承で使う
overwriteは不可
https://stackoverflow.com/questions/51280697/override-inherited-json-schema
例えばexamplesを変えたいときは、元のschemaのexamplesを空にして、継承先で設定する
Record<string, Value>を再現する
keyに制限がないならadditionalpropertiesを使う
https://json-schema.org/understanding-json-schema/reference/object#additionalproperties
正規表現でkeyを制限したいならpatternPropertiesを使う
https://json-schema.org/understanding-json-schema/reference/object#patternProperties
TypeScriptのTuple型相当を指定する
prefixItemsを使うhttps://json-schema.org/understanding-json-schema/reference/array#tupleValidation
null型を指定する
type: nullだとエラーになる
type: "null"にすること
union (typescript)
type: [string, number]で指定可
anyOfも使える
#2024-08-22 16:35:03