...
Warning | ||
---|---|---|
Apache CXF prior to 3.4.6 / 3.5.1 passed Swagger UI configuration (url, ...) as query parameters. Starting from Swagger UI 4.1.3, most of query parameters are not accepted anymore (due to security concerns), and Apache CXF employes different strategy and tries to replace the URL dynamically (inside HTML) when serving Swagger UI's front web page. This behaviour could be turned off by setting The typical initialization for server-side dynamical URL replacement looks like this:
In other words:
|
Anchor | ||||
---|---|---|---|---|
|
Quite often there are more than one JAXRSServerFactoryBean configured within same Apache CXF application, for example, under "/admin" and "/public" endpoints. The older Swagger/OpenAPI v2.0 integrations used such basePath to disambiguate multiple API documentation contexts, but since OpenAPI v3.0 Specification does not explicitly include the concept of basePath anymore, this approach is not working. Luckily, starting from 2.0.6 release, Swagger OpenAPI v3 implementation properly supports Context Id. To activate it from OpenApiFeature, it is enough to set useContextBasedConfig property to true (very likely you would also want to set scan to false).
Code Block |
---|
final OpenApiFeature feature = new OpenApiFeature(); feature.setScan(false); feature.setUseContextBasedConfig(true); ... |
With that, each OpenApiFeature will generate unique Context Id and won't see any classes / packages beyond its own configuration.
Samples
CXF's distribution contains the following samples.
- samples/jax_rs/description_openapi_v3: the OpenAPI v3.0 standalone sample using OpenApiFeature programmatically
- samples/jax_rs/description_openapi_v3_osgi: the OpenAPI v3.0 OSGi application sample using OpenApiFeature using Blueprint
- samples/jax_rs/description_openapi_v3_web: the OpenAPI v3.0 sample using OpenApiFeature inside WAR-based deployment
- samples/jax_rs/description_openapi_v3_spring: the OpenAPI v3.0 sample using Spring and multiple context paths / OpenApiFeatures