首页 > 解决方案 > 我的包中的 Swagger-YAML 错误映射条目

问题描述

我真的不知道在这里做什么,因为我是 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"       

我收到的错误消息。 在此处输入图像描述

标签: apiyamlswagger

解决方案


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,使其与路径中使用的拼写匹配 - /Bundle/{Bundleid}。参数名称区分大小写!


推荐阅读