Swagger 1.5.3列出" body"作为GET报复的一个参数

时间:2015-09-15 21:03:58

标签: swagger swagger-ui

自从1.5.3 ugprading到Swagger 1.5.3-M1后,我注意到我们的swagger.json文件不同(和错误)

在样本获取请求之前看起来像这样。

   "paths":{  
      "/stores":{  
         "get":{  
            "tags":[  
               "stores"
            ],
            "summary":"Retrieve a list of stores",
            "description":"",
            "operationId":"getStores",
            "produces":[  
               "application/json"
            ],
            "parameters":[  
               {  
                  "name":"api_key",
                  "in":"query",
                  "description":"API consumer key",
                  "required":false,
                  "type":"string"
               },
               {  
                  "name":"onlyConnectedStores",
                  "in":"query",
                  "description":"Only select connected stores",
                  "required":false,
                  "type":"string"
               },
               {  
                  "name":"offset",
                  "in":"query",
                  "description":"Number of records to offset before returning first record",
                  "required":false,
                  "type":"string",
                  "default":"0"
               },
               {  
                  "name":"limit",
                  "in":"query",
                  "description":"Number of records to return",
                  "required":false,
                  "type":"string",
                  "default":"10"
               }
            ],

现在看起来像这样

  "paths":{  
      "/stores":{  
         "get":{  
            "tags":[  
               "stores"
            ],
            "summary":"Retrieve a list of stores",
            "description":"",
            "operationId":"getStores",
            "produces":[  
               "application/json"
            ],
            "parameters":[  
               {  
                  "in":"body",
                  "name":"body",
                  "required":false,
                  "schema":{  
                     "$ref":"#/definitions/AsynchronousResponse"
                  }
               },
               {  
                  "name":"api_key",
                  "in":"query",
                  "description":"API consumer key",
                  "required":true,
                  "type":"string"
               },
               {  
                  "name":"onlyConnectedStores",
                  "in":"query",
                  "description":"Only select connected stores",
                  "required":false,
                  "type":"string",
                  "default":"false"
               },
               {  
                  "name":"offset",
                  "in":"query",
                  "description":"Number of records to offset before returning first record",
                  "required":false,
                  "type":"string",
                  "default":"0"
               },
               {  
                  "name":"limit",
                  "in":"query",
                  "description":"Number of records to return",
                  "required":false,
                  "type":"string",
                  "default":"10"
               }
            ],

正因为如此,当实际上没有" body"时,它似乎将身体显示为我们任何GET请求的参数。 PARAM。

enter image description here

任何ida为什么这个额外"身体" param会出现在最直接的swagger上吗?

1 个答案:

答案 0 :(得分:0)

是的,这是由于一些行为改变。我假设有问题的方法有一个名为AsynchronousResponse的参数。如果您可以使用方法签名在项目上打开问题,这将有所帮助,因此我们可以默认隐藏参数。

同时,您可以通过添加该方法参数@ApiParam(hidden=true)来隐藏它。