【问题标题】:Swagger-YAML Bad Mapping entry in my oppproduct我的 oppproduct 中的 Swagger-YAML 错误映射条目
【发布时间】:2018-12-31 22:56:01
【问题描述】:

我的路径有问题。我得到的错误是下面的检查图像。我尝试了社区成员@Helen Paths 指出的链接,但没有运气。请帮帮我。 谢谢, 达科

  /opportunity/{opportunityid}/oppproduct/{oppproductid}:
get:
  tags:
  - "Opportunity"
  summary: "Get opp product id for certain opportunity"
  description: "This endpoint displays opp product details"
  produces:
  - "application/json"
  parameters:
  - name: "opportunityid"
    in: "path"
    description: "This is unique identifier of specific opportunity"
    required: true
    type: "string"
  - name: "oppproductid"
    in: "path"
    description: "This is unique identifier of specific opp product in specific opportunity "
    required: true
    type: "string"
  responses:
    200:
      description: "successful operation"
      schema:
        type: "array"
        items:
          $ref: "#/definitions/opportunity"
    400:
      description: "Invalid status value"
put:
  tags:
  - "Opportunity"
  summary: "Update opportunity product from specific opportunity"
  description: "Update this opportunity product."
  operationId: "updateOppProduct"
  produces:
  - "application/json"
  parameters:
  - name: "opportunityid"
    in: "path"
    description: "Opportunity product with id that need to be updated"
    required: true
    type: "string"
  responses:
    400:
      description: "Invalid Opportunity product supplied"
    404:
      description: "Opportunity product not found"

我得到的错误。

【问题讨论】:

    标签: api yaml swagger


    【解决方案1】:

    1) “重复的映射键”错误表明您在其中一个参数中有重复的键,特别是两个 name 键。你只需要一个name

          parameters:
          - name: "opportunityid"  # <---------
            in: "path"
            description: "Opportunity product with id that need to be updated"
            required: true
            type: "string"
            name: "oppproductid"  # <---------
    

    2)另一个错误是由路径参数中的schema关键字引起的:

      - in: "path"
        description: "Updated Opp product object"
        type: "string"   # <--- This is the correct way to specify the param type in OAS 2.0
        required: true
        schema:    # <--------- Remove this
            type: integer
    

    这里不需要schema。在 OpenAPI 2.0 中,路径、查询和标头参数直接使用 type,而不使用 schema 关键字。

    【讨论】:

    • 嗨@Helen,如果我删除它,我会收到额外的错误。检查更新。
    • @DarkoTodorovski 新错误与您的previous question 相同。你能从那里弄清楚吗?
    猜你喜欢
    • 2017-06-14
    • 2018-12-30
    • 2018-12-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-04-08
    • 1970-01-01
    • 2021-04-29
    相关资源
    最近更新 更多