pipermerriam/flex

Raise errors when undefined query parameters are given

petedmarsh opened this issue · 1 comments

If a URL query parameter is part of a URL but is not defined in the schema then no error is raised, e.g.

The following schema

/get/{id}/:
    get:
      summary: An Example
      description: ''
      produces:
        - application/json
      parameters:
        - in: path
          name: id
          description: ''
          required: true
          type: integer
      responses:
        200:
          description: ''

would not generate errors for the URL http://example.org/get/213?some_query_param=123

I think this can be implemented simply by checking the given list of parameters vs the defned validators in: https://github.com/pipermerriam/flex/blob/master/flex/validation/parameter.py#L98.

However, I am not 100% sure this is the correct behaviour as defined by the specification (i.e. I think it's right to raise errors query parameters undefined in the schema have been passed but I can't see this behaviour dictated in the spec). I'm happy to add this validation (even if it is an opt-in feature).

I am facing the same "problem". I expected the same behavior as @petedmarsh proposes. The documentation says this gets validated

Request validation looks at the following things.

  1. Request path.
  2. Parameters in the path.
  3. Query parameters.
  4. Request method.
  5. Headers.
  6. Content Type

What do you think about this feature?