-
Notifications
You must be signed in to change notification settings - Fork 34
V2 Manual Route Setup
Lukas Ruegner edited this page Jun 2, 2024
·
1 revision
Routes for Swagger-UI and the api-spec json-file can be setup automatically or manually.
The automatic setup can be disabled in the plugin config.
install(SwaggerUI) {
swagger {
automaticRouter = false // disable automatic route setup so it does not interfere with manually added routes
}
}
The required routes can then be added manually:
routing {
route("api.json") {
openApiSpec() // api-spec json is served at '/api.json'
}
route("swagger") {
swaggerUI("/api.json") // swagger-ui is available at '/swagger' or '/swagger/index.html'
}
}
-
openApiSpec()
adds the route for the api-spec json-file -
swaggerUi(apiSpecUrl)
adds the routes for the swagger-ui and all required static resources. The url of the api-spec json-file to use must be provided.
When using multiple Swagger-UIs and api-specs in a single application, their names must be provided in the route setup of the api.jsons. Here e.g. with a spec "v1" and a "v2":
route("api") {
route("version-1.json") {
openApiSpec("v1")
}
route("version-2.json") {
openApiSpec("v2")
}
}
route("swagger") {
route("version-1") {
swaggerUI("/api/version-1.json")
}
route("version-2") {
swaggerUI("/api/version-2.json")
}
}
- Getting Started
- Configuration
- Documenting Routes
- Multiple Api-Specs
- Examples
- Changelog
Documentation for previous versions: