1

The idea is taken from here stack-overflow

After adding a parameter that is supposed do allow dynamic query parameters, it gives error.

Query Example:

/pets:
    get:
      description: |
        Returns all pets
      operationId: findPets
      parameters:
        - name: params
          in: query
          required: false
          schema:
            type: object
            # If the parameter values are of specific type, e.g. string:
            # additionalProperties:
            #   type: string
            # If the parameter values can be of different types
            # (e.g. string, number, boolean, ...)
            additionalProperties: true

          # `style: form` and `explode: true` is the default serialization method
          # for query parameters, so these keywords can be omitted
          style: form
          explode: true
      responses:
        '200':
          description: pet response
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Pet'
        default:
          description: unexpected error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'

Executing a query, returns

{"message":"Cannot convert undefined or null to object"}

To Reproduce

  • Clone this repository
  • run npm install
  • run npm start
  • run curl http://localhost:3000/v1/pets\?type\=dog\&limit\=10\&test\=query

Expected behavior It must allow all the query strings

1 Answer 1

1

This was the bug in the express-openapi-validator package.

It is now fixed in v4.4.2

To test out the functionality, see this example project

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.