У меня есть мой API, выявленный через /context-path /api < /code>, i удалось иметь Swagger-UI, доступный по адресу/context-path/api/swagger-ui/index.html , но он пытается получить/context-path/v3/api-docs/swagger-config , что не существует. Когда я доступен/context-path/api/v3/api-docs/swagger-config он отображает configurl: "/context-path/v3/api-docs/swagger-config"
Я пытался определить свойства в моем приложении.
Код: Выделить всё
springdoc.swagger-ui.disable-swagger-default-url=true
springdoc.swagger-ui.configUrl=/CONTEXT-PATH/api/v3/api-docs/swagger-config
springdoc.swagger-ui.url=/CONTEXT-PATH/api/swagger-ui/index.html
springdoc.api-docs.path=/CONTEXT-PATH/api/v3/api-docs
server.servlet.context-path=/CONTEXT-PATH
spring.mvc.servlet.path=/CONTEXT-PATH/api
< /code>
И здесь мой класс конфигурации Java: < /p>
@Configuration
@EnableWebMvc
@ComponentScan(basePackages = {
"mypackage.rest",
})
@PropertySource("classpath:/application.properties")
@ComponentScan(basePackages = {"org.springdoc"})
@Import({
SpringDocConfiguration.class,
SpringDocConfigProperties.class,
SpringDocSpecPropertiesConfiguration.class,
SpringDocWebMvcConfiguration.class,
MultipleOpenApiSupportConfiguration.class,
SpringDocUIConfiguration.class,
org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration.class})
public class BoApiConfiguration implements WebMvcConfigurer {
@Autowired
private PropertiesService propertiesService;
@Override
public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
configurer.enable();
}
@Bean
public GroupedOpenApi groupOpenAPI() {
return GroupedOpenApi.builder()
.group("api")
.packagesToScan("eu.europa.ec.comm.euaroundme.web.rest")
.addOpenApiCustomizer(serverOpenApiCustomizer())
.build();
}
public OpenApiCustomizer serverOpenApiCustomizer() {
String url = propertiesService.getPropertyValue(ApplicationConstants.APPLICATION_URL_PARAM_KEY);
url += "/api";
Server server = new Server().url(url).description("apiServer");
List servers = new ArrayList();
servers.add(server);
return openApi -> openApi.setServers(servers);
}
}
Подробнее здесь: https://stackoverflow.com/questions/793 ... springboot
Мобильная версия