gpt4 book ai didi

java - API 描述未显示在 Swagger UI 中

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:41:13 24 4
gpt4 key购买 nike

我想用 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

Servlet配置

.......
@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"}

如果需要任何信息,请告诉我

如果您能提供任何帮助,我将不胜感激。

最佳答案

我不确定 Spring-MVC 对 Swagger 的看法,但我希望你可以使用 my research on Swagger 1.5阐明你的情况。我使用您的问题(并分享了您的共享图像)来构建我的问题,因此我相信它可以为您提供部分帮助。

关于java - API 描述未显示在 Swagger UI 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33299355/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com