kin-openapi icon indicating copy to clipboard operation
kin-openapi copied to clipboard

new: add detetion for undescribed request parameters

Open Alexey19 opened this issue 3 years ago • 3 comments

Added the ability, when checking a request, to find parameters that are not described in the schema.

Alexey19 avatar Mar 21 '21 21:03 Alexey19

does openapi allow unspecified query params?

fenollp avatar Mar 21 '21 22:03 fenollp

does openapi allow unspecified query params?

I think yes, but I'm not sure. But this functionality added for user, who has, for example, a lot of request/response and want to ensure, what specification consists full information about all parameters (later I want to add same check for request and response body).

Alexey19 avatar Mar 22 '21 03:03 Alexey19

@fenollp , what about pull-request?

Alexey19 avatar Mar 24 '21 05:03 Alexey19

Hi! This is interesting. Are you still looking to merge this?

I'm thinking that the OpenAPIv3 spec does not treat query params a certain way. Schemas do allow "undescribed query params" in that a schema for a parameter of type "query" may sport the setting additionalProperties: true.

If you want a route not to accept query fields that are not listed in the spec, use additionalProperties: false:

# ...
- name: MyQueryParam
  in: query
  schema:                                    # only allows "?myOnlyProperty=42"
    type: object
    additionalProperties: false
    properties:
      myOnlyProperty:
        type: number
# ...

fenollp avatar Sep 16 '22 19:09 fenollp

@Alexey19 Feel free to re-open if needed.

fenollp avatar Sep 22 '22 13:09 fenollp