Swagger-默认情况下,Springfox始终会生成一些响应消息(401,403…)如何删除它们?

【字号: 日期:2024-03-24浏览:52作者:雯心
(adsbygoogle = window.adsbygoogle || []).push({}); 如何解决Swagger-默认情况下,Springfox始终会生成一些响应消息(401,403…)如何删除它们??

您应该能够将插件设置为 使用默认响应消息。请遵循以下不同版本的说明。

对于1.0.2或更早版本

new SwaggerSpringMvcPlugin(...)//More config.useDefaultResponseMessages(false) //<-- this should be false ...;

对于2.x

new Docket()//More config.useDefaultResponseMessages(false) //<-- this should be false ...;解决方法

我有这样简单的控制器:

@RequestMapping(value='/async/data',method=RequestMethod.GET,produces='application/json') @ApiOperation(value = 'Gets data',notes='Gets data asynchronously') @ApiResponses(value={@ApiResponse(code=200,message='OK')}) public Callable<List<Data>> getData(){return ( () -> {return dataService.loadData();} ); }

我原本只希望HTTP状态为200的响应消息。但是springfox始终生成以下消息(401、403、404)。如何禁用(不显示)它们?

async-rest-controller Show/Hide List Operations Expand OperationsGET /async/data Gets dataImplementation NotesGets data asynchronouslyResponse Class (Status 200)ModelModel Schema{}Response Content TypeResponse MessagesHTTP Status Code Reason Response Model Headers401 Unauthorized403 Forbidden 404 Not Found

相关文章: