3

我正在用 YAML 编写招摇规范并得到模糊的错误。我已经映射了我认为正确的路径和定义,但不确定这个错误意味着什么:

YAML 语法错误不完整的显式映射对;在第 66 行第 30 列遗漏了一个关键节点:格式:int64schema:^t

线路:

 Line 65:         type: integer
 Line 66:         format: int64

昂首阔步:

  /product/{productId}:
    get:
      tags:
        - content
      summary: Find product item by ID
      description: Returns a product item when ID < 10.  ID > 10 or nonintegers will simulate API error conditions
      operationId: getProductItemByID
      produces:
        - application/json
        - application/xml
      parameters:
        - in: path
          name: productId
          description: ID of menu item that needs to be fetched
          required: true
          type: integer
          format: int64
          schema:
            $ref: "#/definitions/Product"
      responses:
        "404":
          description: Product item not found
        "200":
          description: successful operation
          schema:
            $ref: "#/definitions/Product"
        "400":
          description: Invalid ID supplied
      security:
        - api_key: []
        - my_auth:
          - write
          - read

然后在定义中的招摇文件底部:

definitions:

  Product:
    type: object
    properties:
      id:
        type: integer
        format: int64
      category:
        $ref: '#/definitions/Category'
      name:
        type: string
      detail:
        type: string
4

1 回答 1

3

swagger 2.0 spec 开始,如果 'in' 参数是“路径”,则不能使用模式。我认为有一个错误,你应该使用:

/product/{productId}:
  get:
    tags:
      - content
    summary: Find product item by ID
    description: Returns a product item when ID < 10.  ID > 10 or nonintegers will simulate API error conditions
    operationId: getProductItemByID
    produces:
      - application/json
      - application/xml
    parameters:
      - in: path
        name: productId
        description: ID of menu item that needs to be fetched
        required: true
        type: integer
        format: int64
    responses:
      "404":
        description: Product item not found
      "200":
        description: successful operation
        schema:
          $ref: "#/definitions/Product"
      "400":
        description: Invalid ID supplied
...
于 2015-09-21T20:28:56.817 回答