首页 > 解决方案 > JSON请求正文示例招摇

问题描述

有没有办法在 swagger 2.0 中为请求正文设置示例?

我的方案与https://petstore.swagger.io/中的相同

我的json参数:

                "parameters": [
                {
                    "in": "body",
                    "name": "body",
                    "description": "Pet object that needs to be added to the store",
                    "required": true,
                    "schema": {
                        "$ref": "#/definitions/Pet"
                    },
                    "x-example":  "x-example": "{\r\n\"id\":123123123123123123,\r\n\"category\":{\r\n\"id\":44,\r\n\"name\":\"A12312312312312AA\"\r\n},\r\n\"name\":\"X123123123123XX\",\r\n\"photoUrls\":[\r\n\"st123123123ring\"\r\n],\r\n\"tags\":[\r\n{\r\n\"id\":0,\r\n\"name\":\"str123123ing\"\r\n}\r\n],\r\n\"status\":\"avai123123lable\"\r\n}""
                }
            ],

我尝试了一切来设置我自己的例子。

x-example: 
 default/(application/json): 

等等。没有结果。

标签: swaggerswagger-uiswagger-2.0

解决方案


推荐阅读