Introduction
The CXF OpenApiFeature allows you to generate OpenAPI v3.0 documents from JAX-RS service endpoints with a simple configuration. This feature can be configured programmatically in Java or using Spring or Blueprint beans and is an alternative to Swagger's OpenApiFeature.
Setup
|
The cxf-rt-rs-service-description-microprofile-openapi is only available in 3.4.0. For older releases, please consider Swagger's OpenApiFeature instead.
Properties
The following optional parameters can be configured in OpenApiFeature (please note there are some differences comparing to Swagger's OpenApiFeature).
configLocation | the OpenAPI configuration location | null | /config/openapi-configuration.yml |
scanKnownConfigLocations | scan known OpenAPI configuration location (classpath or filesystem), which are: openapi-configuration.yaml openapi-configuration.json openapi.yaml openapi.json | true | true |
propertiesLocation | the properties file location | /swagger.properties | /swagger.properties |
swaggerUiMavenGroupAndArtifact | the Maven artifacts to pinpoint SwaggerUI | null | "org.webjars.swagger-ui' |
swaggerUiVersion | the version of SwaggerUI | null | "3.13.0" |
supportSwaggerUi | turns on/off SwaggerUI support | null (== true) | true |
filterClass | a security filter** | null | "com.example.filter.SampleFilter" |
resourceClasses | a list of resource classes which must be scanned** | null | ["com.example.rest.SampleResource"] |
resourcePackages | a list of package names where resources must be scanned** | null | ["com.example.rest"] |
ignoredRoutes | excludes specific paths when scanning all resources (see scanAllResources)** | null | ["/api/test"] |
prettyPrint | when generating openapi.json, pretty-print the JSON document** | true | true |
runAsFilter | runs the feature as a filter | false | false |
scan | Scan all JAX-RS resources automatically | true | true |
readAllResources | Read all operations also with no @Operation** | true | true |
termsOfServiceUrl | the terms of service URL* | null | null |
licenseUrl | the license URL* | null | "http://www.apache.org/licenses/LICENSE-2.0.html" |
license | the license* | null | "Apache 2.0 License" |
contactUrl | the contact link* | null | null |
contactEmail | the contact email* | null | "users@cxf.apache.org" |
contactName | the contact name* | null | null |
description | the description* | null | "The Sample REST Application with OpenAPI integration" |
title | the title* | null | "Sample REST Application" |
version | the version* | null | "1.0.0" |
swaggerUiConfig | Swagger UI configuration | null | new SwaggerUiConfig().url("/openapi.json") |
* - the properties are defined in the OpenAPI class
** - the properties are defined in the SwaggerConfiguration class
Configuring from Code
|
Configuring from Spring
|