[
https://issues.apache.org/jira/browse/CXF-9069?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17890966#comment-17890966
]
Dmitry commented on CXF-9069:
-----------------------------
[~reta]
Thank for so quick support! Can you check whats wrong with my configuration
please? url still has not changed after I do that:
{code:java}
@OpenAPIDefinition(servers = {
@Server(url = "http://localhost:8081", description = "Sample Server"),
@Server(url = "http://somehost", description = "Another Sample Server"),
})
public class App extends jakarta.ws.rs.core.Application {
}
@Configuration
public class SwaggerConfiguration {
@Bean
public Server jaxRsServer(Bus bus, SampleControllerImpl sampleController) {
final JAXRSServerFactoryBean factory = new JAXRSServerFactoryBean();
factory.setServiceBean(sampleController);
factory.setProvider(new JacksonJsonProvider());
factory.setFeatures(Arrays.asList(swaggerFeature()));
factory.setBus(bus);
factory.setAddress("/");
factory.setApplication(new App());
return factory.create();
}
@Bean
public OpenApiFeature swaggerFeature() {
OpenApiFeature swagger = new OpenApiFeature();
swagger.setVersion("1.0.0");
swagger.setPrettyPrint(true);
swagger.setContactEmail("[email protected]");
swagger.setDescription("Description");
swagger.setTitle("Title");
swagger.setSupportSwaggerUi(true);
swagger.setSwaggerUiConfig(new SwaggerUiConfig().url("openapi.json"));
return swagger;
}
{code}
I also try to set OpenApiCustomizer in OpenApiFuture and change url there but
it didnt work either for me.
> bad url in swagger servers
> --------------------------
>
> Key: CXF-9069
> URL: https://issues.apache.org/jira/browse/CXF-9069
> Project: CXF
> Issue Type: Bug
> Components: JAX-RS
> Affects Versions: 4.0.5
> Reporter: Dmitry
> Priority: Major
> Attachments: image-2024-10-17-10-11-59-161.png
>
>
> Good afternoon!
> I use cxf-rt-rs-service-description-openapi-v3
> and cxf-spring-boot-autoconfigure
> When I run my app localy - server in swagger its
> ["http://127.0.0.1:8081"|http://127.0.0.1:18081/]
> and its work good.
> but when I run it in docker - server become "http://upstream-api" instead of
> domen name and all endpoints in swagger are dont work ("TypeError:
> NetworkError when attempting to fetch resource.")
> This problem was not there when I used cxf-rt-rs-service-description-swagger.
> What I do wrong? I should change something in app configuration or in
> container/infrastructure?
> Devops tells me that problem is in swagger settings.
> Thank for your time!
> !image-2024-10-17-10-11-59-161.png!
> My SwaggerConfig:
> @[~bean]
> {color:#cf8e6d}public {color}OpenApiFeature
> {color:#56a8f5}openApiFeature{color}() {
> OpenApiFeature openApi = {color:#cf8e6d}new {color}OpenApiFeature();
> openApi.setVersion({color:#c77dbb}version{color});
> openApi.setPrettyPrint({color:#cf8e6d}true{color});
> openApi.setContactEmail({color:#c77dbb}email{color});
> openApi.setDescription({color:#c77dbb}description{color});
> openApi.setTitle({color:#c77dbb}productTitle{color});
> openApi.setSupportSwaggerUi({color:#cf8e6d}true{color});
> openApi.setSwaggerUiConfig({color:#cf8e6d}new
> {color}SwaggerUiConfig().configUrl({color:#6aab73}"/openapi.json"{color}));
> {color:#cf8e6d}return {color}openApi;
> }
--
This message was sent by Atlassian Jira
(v8.20.10#820010)