捆绑软件中的Swagger-YAML错误映射条目

时间:2018-07-23 08:19:20

标签: api yaml swagger

我真的不知道该怎么办,因为我是YAML新手

我在以下YAML代码上收到错误的映射错误。有人可以协助我吗?

谢谢, 达科

 /Bundle/{Bundleid}:
get:
  tags:
  - "Bundle"
  summary: "Get Bundle by Id"
  description: "This endpoint displays bundle details"
  produces:
  - "application/json"
  parameters:
  - name: "Bundleid"
    in: "path"
    description: "This is unique identifier of the bundle"
    required: true
    type: "string"
  responses:
    200:
      description: "successful operation"

    400:
      description: "Invalid status value"

delete:
  tags:
  - "Bundle"
  summary: "Delete Bundle by Id"
  description: "Delete Bundle by id"
  operationId: "deleteBundle"
  produces:
  - "application/json"
  parameters:
  - name: "Bundleid"
    in: "path"
    description: "ID of the order that needs to be deleted"
    required: true
    type: "integer"
    minimum: 1.0
    format: "int64"
  responses:
    200:
      description: "successful operation"
      schema:
        type: "array"
        items:
          $ref: "#/definitions/Bundle"
    400:
      description: "Invalid ID supplied"
    404:
      description: "Order not found"       

我收到的错误消息。 enter image description here

1 个答案:

答案 0 :(得分:1)

1)在get操作中,从路径参数定义中删除schema。在OpenAPI 2.0中,非主体参数使用type,而不是schema

      parameters:
      - name: "Bundleid"
        in: "path"
        description: "This is unique identifier of the bundle"
        required: true
        # schema:                           # < -- remove this
        #   $ref: "#/definitions/Bundleid"  # < -- remove this
        type: "string"

2)在delete操作中,将参数名称name: BundleId更改为name: Bundleid,并使用小写字母id,以使其与路径中使用的拼写匹配-{{1 }}。参数名称区分大小写!