Switching and Validating Schemas based on attribute value #635
-
|
Hey Folks, I have a question on creating Json Meta Schema. High Level, this is how it looks like below User-Schema {
"properties" : {
"type" : {"type" : "string"},
"enum" : {"type" : "array"},
"rating": {"type": "integer"}
}Customer-Schema {
"properties" : {
"type" : {"type" : "string"},
"enum" : {"type" : "array"},
"comments": {"type": "string"}
}I have a top level schema I tried building a if else for validation The above did not work as the additional Properties were not taken to consideration and still referencing the top-level schema for user and customer. There was a similar discussion but it kinda deviated from the topic so looking for some inputs (https://github.com/orgs/json-schema-org/discussions/202) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
The likely issue is that your subschemas are missing a Also, you'll want to make |
Beta Was this translation helpful? Give feedback.
The likely issue is that your subschemas are missing a
properties. For example, theifsubschemas needs apropertiesoutside ofgroup. Currently it looks likegroupis a keyword, and since it's unknown it'll just be ignored, making theifalways validate.Also, you'll want to make
grouprequired in theifsubschema if it's possible thatgroupcould be missing.