栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

大张旗鼓地发布JSON正文

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

大张旗鼓地发布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



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/437121.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号