swagger - 如何在 Open api yml 中的地图对象中定义多个对象时间
问题描述
我是 openapi 的新手。我需要一些帮助来编写 open api yml 3.0
对于以下响应格式
{
“Details”: {
“detail1”: [
{
"id": “idvalue”1,
“Info”: {
“Testinfo1”: "1.0.0",
“Testinfo2”: "2.0.0"
}
}
],
“Detail2”: [
{
"id": “idvalue2”,
“Info”: {
“Testinfo3”: "1.0.0",
“Testinfo4”: "2.0.0" }
}
],
"Detail3”: [
{
“First name”: “firstName,
“Lastname: “last”Name,
“Address”: “address”,
“Dependents”: []
}
]
},
"links": {
"self": {
"href": “some url”
}
}
}
detail1、detail2、detail3 可以是不同的对象类型或相同的对象类型,并且可以没有 details 。我对以下几点感到震惊
- 我如何代表地图打开api
- 如何用 in map 表示多个对象类型。
解决方案
在 YAML snap 下面检查这个
DetailsSchemaElement:
type: object
properties:
Details:
type: object
properties:
detail1:
type: array
items:
properties:
id:
type: string
Info:
type: object
properties:
Testinfo1:
type: string
Testinfo2:
type: string
Detail2:
type: array
items:
properties:
id:
type: string
Info:
type: object
properties:
Testinfo4:
type: string
Testinfo3:
type: string
Detail3:
type: array
items:
properties:
First-name:
type: string
Address:
type: string
Dependents:
type: array
items:
type: string
Lastname:
type: string
links:
type: object
properties:
self:
type: object
properties:
href:
type: string
推荐阅读
- postgresql - 使用带有 BIGINT 列的 Postgres 数据源在 Grafana 中绘制图表作为时间
- java - 如何从用户那里获取任意数量的参数并将它们传递给使用 varargs(变量参数)的方法?
- python - 子图边距以适合 matplotlib 中的标题和标签
- escaping - 如何在 M4 预处理器中转义哈希字符 (#)?
- javascript - 保存后在 div 中显示消息
- javascript - 使用选择 js 输入设置类型/自动完成的下拉列表值
- php - 为什么 utf8 字符看起来像问号?
- javascript - 生成带有多个“选择”选项的 PDF?
- c# - “WordBundle”不包含带有 2 个参数的构造函数
- xamarin - xamaring Android Webview 总是试图加载本地文件