gpt4 book ai didi

Swagger 文档

转载 作者:行者123 更新时间:2023-12-02 00:22:18 31 4
gpt4 key购买 nike

如何在 swagger 中为对象数组编写文档。这是我的代码,但我不知道如何访问对象数组中的数据。

{ 
"first_name":"Sam",
"last_name":"Smith",
"reservations":[
{
"chkin_date":"2016-03-31",
"chkout_date":"2016-04-08",
"adults":1,
"children":2,
"chdage":[2,3]
},
{
"chkin_date":"2016-03-30",
"chkout_date":"2016-04-03",
"adults":1,
"children":2,
"chdage":[2,3,5]
}
]
}

最佳答案

给你:

definitions:
SomeObject:
properties:
first_name:
type: string
example: Sam
last_name:
type: string
example: Smith

reservations:
type: array
items:
$ref: '#/definitions/Reservation'
Reservation:
properties:
chkin_date:
type: string
format: date
example: 2016-03-31
chkout_date:
type: string
format: date
example: 2016-04-08
adults:
type: integer
format: int32
example: 1
children:
type: integer
format: int32
example: 2
chdage:
type: array
items:
type: integer
format: int32

关于Swagger 文档,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36341507/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com