Closed larsolofsson closed 1 year ago
Yes! The oneOf
is working as expected, see examples below...
We don't need to have the productType
, it would be a bit redundant.
Be careful that in case of fully specified seller-product or customer-article the UUID does not need to be completed with specific properties!
The following example JSON schema shows how it works, it can be tested with https://www.jsonschemavalidator.net/:
{
"$schema": "http://json-schema.org/draft-00/schema#",
"type": "object",
"required": [
"name"
],
"properties": {
"name": {
"type": "string"
}
},
"oneOf": [
{
"required": [ "paper"],
"properties": {
"paper": {
"$ref": "#/Paper"
}
}
},
{
"required": [ "pulp"],
"properties": {
"pulp": {
"$ref": "#/Pulp"
}
}
}
],
"Paper": {
"type": "object"
},
"Pulp": {
"type": "object"
}
}
It is mandatory to have at least the property "paper" or "pulp" and the definitions (types) of them are globally defined.
In the GetSellerProductById
and GetCustomerArticleById
schemas, I must use the above construct with oneOf
and required
. But, for the CheckAvailabilityOfSellerProductById
and CheckAvailabilityOfCustomerArticleById
schemas, I must use anyOf
without the required
. Unfortunately, that will allow the wrong construct of having both paper
and pulp
properties.
See Issue #71.
Would the following construct be valid in a json schema to allow only for Paper or Pulp in a customer article? I think it would also be good to specify the productType that is also communicated in ListCustomerArticles.
Please also see attached email from Bengt.
Bengt's email, Re oneOf for Paper, Pulp etc.pdf