Swagger OpenAPI 给出带有路径变量的简单样式和模式类型对象的错误

问题描述 投票:0回答:1

我在我的项目中使用 swagger 请求验证器库(版本 2.22.0),并具有以下 yaml 配置。

info:
  title: Sample API
  version: 1.0.0
openapi: 3.0.0
paths:
  /demo/{groupIdentifier}:
    get:
      description: This API which will provide all the members of a group.
      operationId: get-group-v2
      responses:
        "200":
          description: Successful response
    parameters:
    - description: Composite group identifier
      explode: false
      in: path
      name: groupIdentifier
      required: true
      allowReserved: true
      schema:
        properties:
          domainCode:
            description: Code of the master data domain
            type: string
          groupTypeCode:
            description: The prototype type of the group that has to be searched
            type: string
        type: object
      style: simple

运行 api 给出以下错误:

"oas://openapi.yaml": failed with reason: "[ERROR - Unable to parse JSON - Unrecognized token 'domainCode': was expecting (JSON String, Number, Array, Object or token 'null', 'true' or 'false')\n\t at [Source: (String)"domainCode,CUSTOMER,groupTypeCode,CUSTOMER_GROUP"; line: 1, column: 11].: []]""

在 api 调用中,我以对象格式(逗号分隔)传递路径变量,如文档中所述 - https://swagger.io/docs/specification/serialization/

例如。 http://test.com/demo/domainCode,CUSTOMER,groupTypeCode,CUSTOMER_GROUP

此外,我调试了该库,发现它尝试转换 json 中的逗号分隔值,因此出现此错误。谁能建议这里的 yaml 配置有什么问题吗?

尝试使用路径变量对象序列化来配置简单的样式。预计它应该按照 swagger 官方文档工作。

swagger openapi swagger-editor
1个回答
0
投票

您的缩进不正确

parameters

  parameters:
    - description: Composite group identifier
      explode: false
      in: path
      name: groupIdentifier
      required: true
      allowReserved: true
      schema:
        properties:
          domainCode:
            description: Code of the master data domain
            type: string
          groupTypeCode:
            description: The prototype type of the group that has to be searched
            type: string
        type: object
      style: simple
© www.soinside.com 2019 - 2024. All rights reserved.