pom.xml: >
Код: Выделить всё
org.springdoc
springdoc-openapi-starter-webmvc-ui
2.2.0
io.swagger.core.v3
swagger-core
2.1.10
@Configuration
публичный класс OpenAPIConfig {
Код: Выделить всё
@Value("${bezkoder.openapi.dev-url}")
private String devUrl;
@Value("${bezkoder.openapi.prod-url}")
private String prodUrl;
private final ApplicationContext applicationContext;
public OpenAPIConfig(ApplicationContext applicationContext) {
this.applicationContext = applicationContext;
}
@Bean
public OpenAPI myOpenAPI() {
Server devServer = new Server();
devServer.setUrl(devUrl);
devServer.setDescription("Server URL in Development environment");
Server prodServer = new Server();
prodServer.setUrl(prodUrl);
prodServer.setDescription("Server URL in Production environment");
Contact contact = new Contact();
contact.setEmail("bezkoder@gmail.com");
contact.setName("BezKoder");
contact.setUrl("https://www.bezkoder.com");
License mitLicense = new License().name("MIT License").url("https://choosealicense.com/licenses/mit/");
Info info = new Info()
.title("Tutorial Management API")
.version("1.0")
.contact(contact)
.description("This API exposes endpoints to manage tutorials.").termsOfService("https://www.bezkoder.com/terms")
.license(mitLicense);
Set> getIncludedControllers() {
Set beanType = applicationContext.getType(beanName);
if (beanType != null) {
includedControllers.add(beanType);
}
}
return includedControllers;
}
Я пытался получить API-интерфейсы только добавленного контроллера, но получаю следующее: много API. Например:
У меня есть контроллер меню, и у меня всего 5 API, но в Swagger он выглядит как меню-детали-контроллер объекта, меню-поиск-контроллер объекта и т. д.
Кто-нибудь может мне помочь. Любая помощь приветствуется.
Подробнее здесь: https://stackoverflow.com/questions/784 ... -webmvc-ui