array additionalProperties doesn't work #565
Unanswered
hazendaniels
asked this question in
Q&A
Replies: 1 comment 1 reply
-
I believe I have figured it out {
"type": "object",
"required": true,
"additionalProperties": false,
"properties": {
"OrderItems": {
"type": "array",
"required": true,
"items": {
"type": "object",
"additionalProperties": false,
"properties": {
"ProductID": {
"type": "string",
"required": true
},
"Quantity": {
"type": "integer",
"required": true
}
}
}
}
}
} |
Beta Was this translation helpful? Give feedback.
1 reply
# for free
to join this conversation on GitHub.
Already have an account?
# to comment
-
This is my first attempt at writing a schema for JSON. Everything is fine as long as types are defined as objects. But if I change the type to an array the additionalProperties option no longer works.
Using https://www.jsonschemavalidator.net/ to validate while testing.
Any help would be appreciated
Successfully validates - Property 'X' has not been defined and the schema does not allow additional properties.
Schema
JSON
Unsuccessfully validates when OrderItems is changed to an arrary
Schema
JSON
Beta Was this translation helpful? Give feedback.
All reactions