【问题标题】:Cannot pass dynamic query parameters when using `express-openapi-validator`使用“express-openapi-validator”时无法传递动态查询参数
【发布时间】:2020-11-05 13:00:03
【问题描述】:

想法取自here stack-overflow

添加一个应该允许动态查询参数的参数后,它给出了错误。

查询示例:

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

执行查询,返回

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

复制

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

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

【问题讨论】:

    标签: openapi express-openapi-validator


    【解决方案1】:

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

    现在在v4.4.2修复

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-02-23
      • 1970-01-01
      • 2018-08-15
      • 1970-01-01
      • 1970-01-01
      • 2021-06-02
      • 2013-07-04
      • 1970-01-01
      相关资源
      最近更新 更多