如何在Swagger规范中接收动态响应 [英] How to receive a dynamic response in a Swagger spec
本文介绍了如何在Swagger规范中接收动态响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想通过我的API从数据库中请求一个表.但是,我不知道该表将具有多少列,或将包含什么列.如何在Swagger中指定呢?这就是我想做的:
I want to request a table from my database through my API. However, I don't know what number of columns the table will have, or what it will contain. How can I specify this in Swagger? This is what I would like to do:
paths:
/reports/{id}:
get:
summary: Detailed results
description: filler
parameters:
- name: id
in: path
description: filler
required: true
type: integer
format: int64
responses:
200:
description: OK
schema:
type: array
items:
$ref: '#/definitions/DynamicObject'
definitions:
DynamicObject:
type: object
properties:
**$IDONTKNOWWHATTODO**
关于如何定义没有特定参数的JSON对象的任何想法?
Any ideas on how to define a JSON object with no specific parameters?
推荐答案
要描述任意JSON,请使用"type": "object"
.这是JSON中的示例:
To describe arbitrary JSON, please use "type": "object"
. Here is an example in JSON:
"responses": {
"200": {
"description": "successful operation",
"schema": {
"type": "object"
}
}
},
这篇关于如何在Swagger规范中接收动态响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文