【发布时间】:2015-07-13 18:30:20
【问题描述】:
我有一个使用以下 JSON 请求正文的 POST 请求。如何使用 OpenAPI (Swagger) 描述此请求正文?
{
"testapi":{
"testapiContext":{
"messageId":"kkkk8",
"messageDateTime":"2014-08-17T14:07:30+0530"
},
"testapiBody":{
"cameraServiceRq":{
"osType":"android",
"deviceType":"samsung555"
}
}
}
}
到目前为止,我尝试了以下方法,但我坚持定义主体 schema。
swagger: "2.0"
info:
version: 1.0.0
title: get camera
license:
name: MIT
host: localhost
basePath: /test/service
schemes:
- http
consumes:
- application/json
produces:
- application/json
paths:
/getCameraParameters:
post:
summary: Create new parameters
operationId: createnew
consumes:
- application/json
- application/xml
produces:
- application/json
- application/xml
parameters:
- name: pet
in: body
description: The pet JSON you want to post
schema: # <--- What do I write here?
required: true
responses:
200:
description: "200 response"
examples:
application/json:
{
"status": "Success"
}
我想内联定义输入正文,作为文档示例。
【问题讨论】:
标签: swagger swagger-2.0 openapi