Comments (2)
Hi @DarkStar1,
we just releases the Holon Platform version 5.2.0-alpha2, which fixes some bugs related to Swagger JAX-RS auto-configuration.
We're improving the documentation, you can find the 5.2.0-alpha2 Swagger JAX-RS auto-configuration docs here.
In short words, the Swagger API documentation endpoints auto-configuration works this way:
- If the Holon Swagger configuration properties are available from Spring Boot application properties, they take the precedence over the
@ApiDefinition
annotation. - Otherwise, the
@ApiDefinition
annotation is used for the Swagger endpoints configuration.
Anyhow, only the JAX-RS endpoints annotated with both @Path
and @Api
are taken into account for API documentation generation. This because is how the Swagger JAX-RS integration works by default.
So, if you use the Holon Swagger configuration properties, for example:
holon:
swagger:
resource-package: "my.api.endpoints.package"
To declare the package (one or more) to scan to detect the JAX-RS endpoints annotated with @Path
and @Api
and generate the Swagger API endpoint. The endpoint path is /api-docs
by default, or you can specify it using the path
property:
holon:
swagger:
resource-package: "my.api.endpoints.package"
path: "/my-docs"
So, if you don't use the Holon Swagger configuration properties, all the @Path
and @Api
annotated JAX-RS endpoint Spring beans are detected from classpath. So you have to ensure the JAX-RS endpoints are Spring beans too, for example using the @Component
annotation.
In this scenario, the @ApiDefinition
can be used (but it is optional) to configure:
- The Swagger API endpoint path, using the annotation
value()
- The Swagger API general configuration, for example the API title or description
The API path declaration can be used to declare more than one API documentation endpoint. The documentation of each valid JAX-RS endpoint bound to the same API path will be merged into a single Swagger API documentation endpoint.
For example, given the following JAX-RS endpoints:
@Api
@Path("example1")
@Component
class ExampleEndpoint1 {
/* Operations omitted */
}
@Api
@Path("example2")
@Component
class ExampleEndpoint2 {
/* Operations omitted */
}
A single Swagger API documentation endpoint will be auto-generated and mapped to the default /api-docs
path, and will include all the API operations provided by the two endpoint.
To declare two different Swagger API documentation endpoints, the @ApiDefinition
annotation can be used, for example:
@ApiDefinition("/docs1")
@Api
@Path("example1")
@Component
class ExampleEndpoint1 {
/* Operations omitted */
}
@ApiDefinition("/docs2")
@Api
@Path("example2")
@Component
class ExampleEndpoint2 {
/* Operations omitted */
}
This way, two Swagger API documentation endpoints will be auto-generated, one mapped to the /docs1
path and the other mapped to the /docs2
path.
To merge another JAX-RS endpoint, an @ApiDefinition
annotation with the same path can be used:
@ApiDefinition("/docs1")
@Api
@Path("example1")
@Component
class ExampleEndpoint1 {
/* Operations omitted */
}
@ApiDefinition("/docs2")
@Api
@Path("example2")
@Component
class ExampleEndpoint2 {
/* Operations omitted */
}
@ApiDefinition("/docs2")
@Api
@Path("example3")
@Component
class ExampleEndpoint3 {
/* Operations omitted */
}
In the example above, two Swagger API documentation endpoints will be auto-generated (one mapped to the /docs1
path and the other mapped to the /docs2
path): the first one will only contain the ExampleEndpoint1
operations, while the second one will contain both the ExampleEndpoint2
and ExampleEndpoint3
operations.
When you use the @ApiDefinition
annotation for the documentation configuration (title, description and so on), the @ApiDefinition
attribute values for the same API documentation path must be consistent, a configuration exception is thrown otherwise.
from holon-jaxrs.
Thanks for your detailed explanation.
from holon-jaxrs.
Related Issues (20)
- Upgrade ByteBuddy to 1.10.6
- Upgrade Swagger v2 to 1.6.0 and v3 to 2.1.0
- Upgrade Resteasy to version 4.4.2
- Update holon-core to 5.5.0
- Update holon-json to 5.5.0
- Update holon-reactor to 5.5.0
- Upgrade Jersey to 2.31
- Upgrade Resteasy to 4.5.5
- Upgrade ByteBuddy to 1.10.13
- Upgrade Swagger V2 to 1.6.2
- Upgrade Swagger V3 to 2.1.3
- Creating Array using PropertyBox
- ListPathProperty failing when iterating
- Upgrade to Jersey 2.35
- Upgrade to Bytebuddy 1.12.23
- Upgrade to Jackson 2.13.5
- Upgrade to Slf4j 1.7.36
- Update holon-core
- Update holon-json
- Update holon-reactor
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from holon-jaxrs.