api - 我的 oppproduct 中的 Swagger-YAML 错误映射条目
问题描述
我的路径有问题。我得到的错误是下面的检查图像。我尝试了社区成员@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"
解决方案
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
关键字。
推荐阅读
- javascript - 缺少必需的参数“电子邮件”
- php - 如何在 wordpress 中获得作者第一篇文章的链接
- javascript - Apache Solr 提取,基于查询突出显示 HTML 元素,过滤查询词
- angular - 尝试在 Angular 项目中运行 ng serve 时出现问题'找不到模块“@angular-devkit/build-angular/package.json'”
- gnu - GNU Readline:如何设置输入字符串的初始内容
- r - 使用 fixst/feols() 时如何从模型中恢复常量/截距?
- sql - 为大数据和多用户设计数据库
- python - 我们如何附加或连接具有大部分相似架构但不是全部的多个文件
- case - CTE 结果在 CTE CASE WHEN 中不可见
- python-3.x - 使局部变量成为全局变量