Skip to content
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

Support type property as an array, according to JSON Schema Validation #13

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Support type property as an array, according to JSON Schema Validation #13

wants to merge 1 commit into from

Conversation

ramsey
Copy link
Contributor

@ramsey ramsey commented Mar 28, 2017

In JSON Schema, the "type" property may be a string or an array of strings. Previously, if type was set as array of strings (i.e., "type": ["null", "array"]), then bootprint-json-schema would render the following:

null,array

Additionally, the "items" property was not rendered.

The expected result for the given scenario is:

null, integer[]

And the "items" property should be rendered with its schema definition.

This supports the JSON Schema "type" as it is defined to allow an array of strings. If one of the strings in that array is "array," then items.type is used to render the datatype, and the "items" property is also rendered.

In JSON Schema, the "type" property may be a string or an array of
strings. Previously, if type was set as array of strings (i.e., `"type":
["null", "array"]`) and there was also an "items" property defining
the array as items of type "integer," then bootprint-json-schema
would render the following:

    null,array

Additionally, the "items" property was not rendered.

The expected result for the given scenario is:

    null, integer[]

And the "items" property should be rendered with its defintion.

This supports the JSON Schema "type" as it is defined to allow an array
of strings. If one of the strings in that array is "array," then
`items.type` is used to render the datatype, and the "items" property is
also rendered.
@coveralls
Copy link

coveralls commented Mar 28, 2017

Coverage Status

Coverage decreased (-9.3%) to 56.604% when pulling 0237974 on ramsey:fix-schema-type-array into 0225c10 on bootprint:master.

@nknapp
Copy link
Member

nknapp commented Mar 29, 2017 via email

@ramsey
Copy link
Contributor Author

ramsey commented Mar 29, 2017

This should handle all cases, so null, object[] should work. I only used null, integer[] as an example.

I'll provide test cases soon. I thought I saw you mention on another PR that you hadn't yet set up the testing infrastructure, so I skipped over writing tests, since I wasn't sure the status of that. I could have been confused with another project I was working on. :-)

@nknapp
Copy link
Member

nknapp commented Mar 29, 2017 via email

@owaaa
Copy link

owaaa commented Mar 8, 2018

bump? I hit a roadblock and was happy to find this fork exists and fixed my issue. It solves the [array, null] issue well

@nknapp
Copy link
Member

nknapp commented Mar 8, 2018

This change still needs a test. This can be something like the fstab-spec. Should not be too hard to write...
If there is a test and the coverage does not go further down with the merge, I'll merge the PR, but I don't have time to write it at the moment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants