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, theif
subschemas needs aproperties
outside ofgroup
. Currently it looks likegroup
is a keyword, and since it's unknown it'll just be ignored, making theif
always validate.Also, you'll want to make
group
required in theif
subschema if it's possible thatgroup
could be missing.