api - 我的包中的 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"
解决方案
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}
。参数名称区分大小写!
推荐阅读
- javascript - 使用 Angular 中的日期对象将 BST 时间传递给 API
- python - FileNotFoundError:[Errno 2] 没有这样的文件或目录:'hadoop'
- ibm-datapower - 如何使用 API 调用在 IBM Datapower 中添加加密证书
- google-bigquery - 基于组和时间戳的唯一值
- amazon-web-services - UnexpectedStatusException:培训作业 sagemaker-scikit-learnxxxx 失败。原因:AlgorithmError:框架错误
- azure-devops - 如何在 Azure devops wiki 中发布代码覆盖率和测试结果
- angular - 如何修复此错误类型错误:无法以角度读取未定义的属性(读取“长度”)
- azure - 在 Cosmos 中加入数组或非数组对象
- python - 如何在带有 Pycharm 的 WSL/WSL2 中使用 Cython?
- android - 这里Android SDK与华为的兼容性