我的oppproduct中的Swagger-YAML错误映射条目

时间:2018-07-24 10:41:25

标签: api yaml swagger

我的路径有问题。我得到的错误是下面的检查图像。我尝试了社区成员@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"
我收到的错误。 enter image description here

1 个答案:

答案 0 :(得分: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关键字。