使用 `express-openapi-validator` 时无法传递动态查询参数

Cannot pass dynamic query parameters when using `express-openapi-validator`

思路来自

添加一个本应允许动态查询参数的参数后,出现错误。

查询示例:

/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'

正在执行查询,returns

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

重现

预期行为 它必须允许所有查询字符串

这是 express-openapi-validator 包中的错误。

It is now fixed in v4.4.2

要测试功能,请参阅 this example project