Yelp / swagger_spec_validator

Other
104 stars 71 forks source link

Add type check when validating definition #136

Open ngaya-ll opened 4 years ago

ngaya-ll commented 4 years ago

This prevents an AttributeError when validating definitions like this:

type: object
properties: ...
additionalProperties: false
coveralls commented 4 years ago

Coverage Status

Coverage increased (+0.006%) to 98.563% when pulling 91af7a8d0f0d4932f3ad25ee15efde11741d9ee6 on ngaya-ll:additional-properties-bool into 7234ed917f127dcf750d4b5f2f1c355d3b9fc093 on Yelp:master.

ngaya-ll commented 4 years ago

https://github.com/Yelp/swagger_spec_validator/pull/138 added support for boolean additionalProperties which invalidates one of the test cases in this PR. I'm not sure whether this is correct as the Swagger 2.0 spec is a bit vague about that, see https://github.com/OAI/OpenAPI-Specification/issues/668.

macisamuele commented 4 years ago

I'll try to have a look to the PR and the Specifications later this evening.

For what I remember the schemas defined in #/definitions/<key> must be dictionaries, and the PR seems ensuring this but I'm not 100% sure. So I need to validate this and check the code change.

@ngaya-ll thanks for the PR and for holding tight with us until a proper review is possible.

sjaensch commented 4 years ago

I remember us looking into additionalProperties and the fact that it can be a boolean value in the past, it just slipped through during the code review for #134. OAI/OpenAPI-Specification#668 mentions that (more explicit) support for a boolean value was added in OpenAPI 3.0. See OAI/OpenAPI-Specification#894.

Given all of that, we should allow boolean values for additionalProperties in OpenAPI 2.0.