Swagger Editor 正文的多个参数
it1352
帮助1人
问题说明
所以我明白,如果我们想要身体参数,我们必须有一个模式,我就是这样做的.问题是无论我如何尝试定义我的架构,它都不允许我拥有多个正文参数.这是我尝试过的方法之一的示例.任何帮助都会很棒!
So I understand that if we want body parameters we have to have a schema, which I do. The issue is no matter how I try to define my schema it does not allow me to have multiple body parameters. Here is an example of one of the methods I have tried. Any help would be great!
swagger: '2.0'
# This is your document metadata
info:
version: "0.0.1"
title: Todo App
schema: {
}
host: localhost:3000
schemes:
- http
- https
consumes:
- application/json
produces:
- application/x-www-form-urlencoded
basePath: /
paths:
# This is a path endpoint. Change it.
/tasks:
post:
description: |
Add 'Task' object.
parameters:
# An example parameter that is in query and is required
-
name: name
in: query
description: unique object task name
required: true
schema:
type: string
- name: description
in: query
description: task description
required: true
schema:
type: string
responses:
# Response code
200:
description: Successful response
# A schema describing your response object.
# Use JSON Schema format
schema:
title: Return String
type: string
example: "Task added succesfully"
500:
description: Error
schema:
type: string
example: "Could not add Task"
正确答案
#1
我不确定你的问题...
I'm not sure to understand your question...
- 如果您尝试为一项操作定义多个主体参数,则不能.如 swagger 规范中所述:
Body [...] 只能有一个 body 参数
Body [...] there can only be one body parameter
- 如果您尝试发送具有多个参数的主体,请在定义部分添加一个对象模型并在您的主体参数中引用它,见下文(适用于 editor.swagger.io):
您的示例节点也是错误的,请参阅 这里了解更多详情.
Your example nodes also are wrong, see here for more details.
swagger: '2.0'
info:
version: "0.0.1"
title: Todo App
host: localhost:3000
schemes:
- http
- https
consumes:
- application/json
produces:
- application/x-www-form-urlencoded
basePath: /
paths:
# This is a path endpoint. Change it.
/tasks:
post:
description: |
Add 'Task' object.
parameters:
- name: task
in: body
description: task object
required: true
schema:
$ref: '#/definitions/Task'
responses:
200:
description: Successful response
schema:
title: Return String
type: string
example: "Task added succesfully"
500:
description: Error
schema:
type: string
example: "Could not add Task"
definitions:
Task:
description: Task object
properties:
name:
type: string
description: task object name
description:
type: string
description: task description
required:
- name
- description
这篇好文章是转载于:学新通技术网
- 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
- 本站站名: 学新通技术网
- 本文地址: /reply/detail/tanhcfkefj
系列文章
更多
同类精品
更多
-
YouTube API 不能在 iOS (iPhone/iPad) 工作,但在桌面浏览器工作正常?
it1352 07-30 -
保持在后台运行的 iPhone 应用程序完全可操作
it1352 07-25 -
iPhone,一张图像叠加到另一张图像上以创建要保存的新图像?(水印)
it1352 07-17 -
使用 iPhone 进行移动设备管理
it1352 07-23 -
在android同时打开手电筒和前置摄像头
it1352 09-28 -
扫描 NFC 标签时是否可以启动应用程序?
it1352 08-02 -
检查邮件是否发送成功
it1352 07-25 -
Android微调工具-删除当前选择
it1352 06-20 -
希伯来语的空格句子标记化错误
it1352 06-22 -
Android App 和三星 Galaxy S4 不兼容
it1352 07-20