Skip to content
This repository was archived by the owner on Nov 3, 2023. It is now read-only.

Include additionalItems schema example #22

Closed
mdboom opened this issue May 16, 2014 · 2 comments
Closed

Include additionalItems schema example #22

mdboom opened this issue May 16, 2014 · 2 comments

Comments

@mdboom
Copy link
Member

mdboom commented May 16, 2014

Michael Zub wrote:

Thank you for great "Understanding JSON Schema" site and book. It is very helpful and easy to understand and should be recommended to everyone working with JSON Schema.

As a reader I have a minor remark on "additionalItems" keyword description. On page 26 you have wrote:

"The additionalItems keyword controls whether it’s valid to have additional items in the array beyond what is defined in the schema. Here, we’ll reuse the example schema above, but set additionalItems to false, which has the effect of disallowing extra items in the array."

According to this one can assume that "additionalItems" can be only boolean flag, but there is a case when "additionalItems" can be schema that describes additional array items (very similar as "additionalProperties" works).
As example, schema {"items":[{}],"additionalItems":{"type":"integer"}} won't validate next JSON: [null,2,3,"foo"]. If this data is put into the validator (for example http://json-schema-validator.herokuapp.com/index.jsp) the error will be "instance type (string) does not match any allowed primitive type (allowed: ["integer"])".

The example from above is taken from JSON Schema Test Suite - https://github.com/json-schema/JSON-Schema-Test-Suite

I think it will be great if similar case is added to your book.

Regards,
Micheal Zub

@embray
Copy link
Collaborator

embray commented May 16, 2014

I was so confused about this at first. I thought you were thanking yourself :)

@mdboom
Copy link
Member Author

mdboom commented May 16, 2014

Doh -- I'll edit this.

Relequestual added a commit that referenced this issue Aug 23, 2018
Fixes #22: Explain about ``additionalItems`` as object.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants