-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Distinct OneOf gets parsed as single OneOf group in schema #785
Comments
Can you try and explain the type of structure you are trying to describe, and then I can attempt to advise on MSON used to describe it. It's not entirely clear to me on your intent from the Note your expected JSON Schema contains two |
Both properties |
I'd suggest using enum to declare and exclusive list of types for each property. The following MSON will describe an object which may contain properties (foo and bar) which must be either a string or number: + foo (enum[string, number])
+ bar (enum[string, number]) You can extract the ## Data Structures
## MyObject
+ foo (StringOrNumber)
+ bar (StringOrNumber)
### StringOrNumber (enum[string, number]) These will product the following JSON Schema in Drafter 5: {
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"foo": {
"anyOf": [
{
"type": "string"
},
{
"type": "number"
}
]
},
"bar": {
"anyOf": [
{
"type": "string"
},
{
"type": "number"
}
]
}
}
} If you want to descibe that they both need to be a number, or both need to be a string, then the following MSON will describe that as follows: + One Of
+ Properties
+ foo (number)
+ bar (number)
+ Properties
+ foo (string)
+ bar (string) Which currently produces the following JSON Schema: {
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"allOf": [
{
"oneOf": [
{
"properties": {
"foo": {
"type": "number"
},
"bar": {
"type": "number"
}
}
},
{
"properties": {
"foo": {
"type": "string"
},
"bar": {
"type": "string"
}
}
}
]
}
]
} |
Please sustitute |
@kylef, thank you for providing the examples! This has solved my problem. |
apib:
json schema:
I am expecting the two
One Of
statements to be in distinct groups:Is there a different mson syntax i should use to achieve the expected schema or is this a bug?
The text was updated successfully, but these errors were encountered: