我有一个 spring webapp,我添加了 swagger 和 swagger-ui。我添加了一个虚拟类来测试招摇:
导入 com.wordnik.swagger.annotations.Api; 导入 com.wordnik.swagger.annotations.ApiError; 导入 com.wordnik.swagger.annotations.ApiErrors; 导入 com.wordnik.swagger.annotations.ApiOperation; 导入 org.springframework.stereotype.Controller; 导入 org.springframework.web.bind.annotation.RequestBody; 导入 org.springframework.web.bind.annotation.RequestMapping; 导入 org.springframework.web.bind.annotation.RequestMethod; 导入 org.springframework.web.bind.annotation.ResponseBody; @Api(value = "DummyController", description = "控制器的虚拟描述") @控制器 @RequestMapping(value = "/dummy") 公共类 DummyClassForSwagger { @ApiOperation(value = "第一个虚拟输出", httpMethod = "GET") @ApiErrors({@ApiError(code = 404, reason = "First dummy test") }) @RequestMapping(value = "/first", method = RequestMethod.GET) @ResponseBody 公共字符串 dummyOutputOne() { 返回“虚拟输出”; } @ApiOperation(value = "第二个虚拟输出", httpMethod = "GET") @ApiErrors({@ApiError(code = 404, reason = "Second dummy test") }) @RequestMapping(value = "/second", method = RequestMethod.GET) @ResponseBody 公共字符串 dummyOutputTwo() { 返回“第二个虚拟输出”; } }
在构建/部署之后,我可以在 swagger 页面上看到虚拟类(参见附件1)。问题是,“列表操作”没有显示任何内容。原始输出如下:
<controllerDocumentation>
<apiVersion>1.0</apiVersion>
<apis>
<description>Dummy description for the controller</description>
<operations>
<deprecated>false</deprecated>
<errorResponses>
<code>404</code>
<reason>First dummy test</reason>
</errorResponses>
<httpMethod>GET</httpMethod>
<nickname>dummyOutputOne</nickname>
<notes/>
<responseClass>String</responseClass>
<summary>First dummy output</summary>
</operations>
<path>/dummy/first</path>
</apis>
<apis>
<description>Dummy description for the controller</description>
<operations>
<deprecated>false</deprecated>
<errorResponses>
<code>404</code>
<reason>Second dummy test</reason>
</errorResponses>
<httpMethod>GET</httpMethod>
<nickname>dummyOutputTwo</nickname>
<notes/>
<responseClass>String</responseClass>
<summary>Second dummy output</summary>
</operations>
<path>/dummy/second</path>
</apis>
<basePath>http://localhost:8080/mapserver/core</basePath>
<models/>
<resourcePath>/dummy</resourcePath>
<swaggerVersion>1.0</swaggerVersion>
</controllerDocumentation>
我认为,问题是缺少标签“操作”或类似的东西......但我不确定(我不知道如何解决这个问题)。有什么建议么?