我已经开发了node API
,现在我正在使用swagger
为此API创建Documentation
,但stuck
中的response part
,请帮助我写下此json
结果的回复,
[
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
-79.90295559,
36.05593626
]
},
"properties": {
"id": "f2e08a02-9be9-468d-9bae-b83118ef5110",
"esri_id": "518",
"name": "Greensboro et al, NC",
"panelCount": 1,
"tot": 790523
}
}
]
}
]
我当前的swagger
响应代码是这样的,
responses:
# Response code
200:
description: Successful response
# A schema describing your response object.
# Use JSON Schema format
schema:
title: User Authentication
type: array
items:
title: token
type: object
我不知道如何撰写回复with type to each object
。
答案 0 :(得分:2)
您可以在“定义”中定义JSON结构,并在架构中引用它
responses:
# Response code
200:
description: Successful response
schema:
$ref: '#/definitions/userAuthentication'
definitions:
-userAuthentication:
title: User Authentication
type: array
items:
title: token
type: string
如果您想将令牌作为JSON,则定义它并引用。