RepreZen / KaiZen-OpenApi-Parser

High-performance Parser, Validator, and Java Object Model for OpenAPI 3.x
130 stars 31 forks source link

Check that param type is present via either schema or content #251

Open pilhuhn opened 4 years ago

pilhuhn commented 4 years ago

According to https://swagger.io/docs/specification/describing-parameters/ a param needs to have a data type that is defined by either schema or content:

Describing Parameters In OpenAPI 3.0, parameters are defined in the parameters section of an operation or path. To describe a parameter, you specify its name, location (in), data type (defined by either schema or content)

This PR checks that one of schema or content are present. If not an error is reported.

E.g.:

http://0.0.0.0:8081/api/custom-policies/v1.0/openapi.json[72:9]: Exactly one of schema|content must be present
http://0.0.0.0:8081/api/custom-policies/v1.0/openapi.json[76:9]: Exactly one of schema|content must be present
http://0.0.0.0:8081/api/custom-policies/v1.0/openapi.json[80:9]: Exactly one of schema|content must be present
pilhuhn commented 4 years ago

Test failure is at least on Travis from bad package resolution:

[ERROR] /home/travis/build/RepreZen/KaiZen-OpenApi-Parser/kaizen-openapi-parser/src/main/java/com/reprezen/kaizen/oasparser/model3/Operation.java:[6,24] package javax.annotation does not exist

Same for #249

ghillairet commented 4 years ago

@pilhuhn That looks good for me, @tedepstein What do you think?