pb33f / libopenapi-validator

OpenAPI validation extension for libopenapi, validate http requests and responses as well as schemas
https://pb33f.io/libopenapi/validation/
Other
55 stars 19 forks source link

Handling of default values in query parameters #56

Closed emilien-puget closed 3 months ago

emilien-puget commented 8 months ago

First of all, i love what you did there.

What do you think about handling default values in query parameters ?

daveshanley commented 8 months ago

Could you help me understand a little more?

emilien-puget commented 8 months ago

in a open api specification, a default value can be specified like so

      name: "page"
      in: "query"
      style: "deepObject"
      required: false
      schema:
        type: object
        properties:
          size:
            type: integer
            minimum: 1
            maximum: 50
            default: 20
            require: false

Right now we would reject an http query with size not set because it violates the schema, but a default value is set.

daveshanley commented 8 months ago

Oh, yes! of course. I forgot about that. We should absolutely add support to the validators.

emilien-puget commented 3 months ago

after some deliberation, i think we should not do that, as this suggestion would mean that we modify the request, and we should keep the responsibility of this library to validate request