大张旗鼓地发布JSON正文

大张旗鼓地发布JSON正文,第1张

大张旗鼓地发布JSON正文

您需要使用

body
参数:

    "parameters": [      {        "in": "body",        "name": "body",        "description": "Pet object that needs to be added to the store",        "required": false,        "schema": {          "$ref": "#/definitions/Pet"        }      }    ],

#/definitions/Pet
定义为模型:

"Pet": {  "required": [    "name",    "photoUrls"  ],  "properties": {    "id": {      "type": "integer",      "format": "int64"    },    "category": {      "$ref": "#/definitions/Category"    },    "name": {      "type": "string",      "example": "doggie"    },    "photoUrls": {      "type": "array",      "xml": {        "name": "photoUrl",        "wrapped": true      },      "items": {        "type": "string"      }    },    "tags": {      "type": "array",      "xml": {        "name": "tag",        "wrapped": true      },      "items": {        "$ref": "#/definitions/Tag"      }    },    "status": {      "type": "string",      "description": "pet status in the store",      "enum": [        "available",        "pending",        "sold"      ]    }  },  "xml": {    "name": "Pet"  }},

参考:https :
//github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-
generator/src/test/resources/2_0/petstore.json#L35-L43

OpenAPI / Swagger v2规范:https :
//github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#parameter-
object

对于OpenAPI
v3规范,该

body
参数已被弃用。要定义HTTP有效负载,需要使用HTTP有效负载
requestBody
,例如https://github.com/OpenAPITools/openapi-
generator/blob/master/modules/openapi-
generator/src/test/resources/3_0/petstore.json#
L39-L41

OpenAPI v3规范:https://github.com/OAI/OpenAPI-
Specification/blob/master/versions/3.0.0.md#requestBodyObject



欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5128836.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-11-17
下一篇 2022-11-17

发表评论

登录后才能评论

评论列表(0条)

保存