Swagger UI 中未显示 API 描述

3
我希望使用Swagger和Spring MVC来记录一个REST API,
我在Swagger UI中探索/api-docs URL,
就像下面的图片一样。 enter image description here enter image description here 有人可以帮助我解决这两个问题吗?
1. I don't know why the description isn't display.
2. how can I show all API in same group

SwaggerConfig.java

@Configuration
@EnableSwagger
public class SwaggerConfig {
  private SpringSwaggerConfig springSwaggerConfig;

  @Autowired
  public void setSpringSwaggerConfig(SpringSwaggerConfig springSwaggerConfig){
      this.springSwaggerConfig = springSwaggerConfig;
  }

  @Bean
  public SwaggerSpringMvcPlugin customImplementation(){
    return new SwaggerSpringMvcPlugin(this.springSwaggerConfig)
      .apiInfo(apiInfo())
      .includePatterns(".*/rest.*");
    }

  private ApiInfo apiInfo(){
      ApiInfo apiInfo = new ApiInfo(
      "API description", "API for me", 
      "API terms of service", 
      "ageehuang@gmail.com", "", ""
      );
      return apiInfo;
    }

pom.xml

jackson-annotations 2.2.3
jackson-databind 2.2.3
jackson-core 2.2.3
guava 14.0
swagger-springmvc 1.0.2
swagger-core_2.10 1.3.7

ServletConifg

.......
@Configuration
@ComponentScan(basePackages = {"config.swagger"})
public class ServletConfig{ 
.......

Controller.java

@Controller
@RequestMapping(value = "/rest/v1")
@Api(value = "CounponController" ,description="SCCCCCC")
public class CouponController {
........

http://localhost:8080/coupon/api-docs

{"apiVersion":"1.0","apis":[{"description":"SCCCCCC","path":"/default/counponcontroller","position":0},{"description":"Coupon Order Controller","path":"/default/coupon-order-controller","position":0},{"description":"Data Controller","path":"/default/data-controller","position":0},{"description":"Ep Controller","path":"/default/ep-controller","position":0}],"authorizations":{},"info":{"contact":"ageehuang@eztravel.com.tw","description":"API for Ez-Conpon","license":"","licenseUrl":"","termsOfServiceUrl":"EzTravel API terms of service","title":"EzTravel"},"swaggerVersion":"1.2"}

如果需要任何信息,请告诉我。感谢您能提供帮助。

你有没有找到解决办法?我也遇到了同样的问题。 - Dhruv Raj Singh
2个回答

2

我不确定Spring-MVC对Swagger的看法,但我希望你可以使用我对Swagger 1.5的研究来解决你的问题。我使用了你的问题(并分享了你分享的图片)来构建我的问题,因此我相信它可以为你提供部分帮助。


1
关于第一个问题,是因为您使用了错误的swagger-core依赖项。请尝试使用以下依赖项 com.wordnik:swagger-annotations:1.3.11(gradle artifact表示)。
稍后会详细介绍第二个问题。

我也遇到了同样的问题。我尝试添加了与您提到的相同依赖项,但我的问题并没有得到解决。 - Dhruv Raj Singh

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接