admin管理员组

文章数量:1406942

Having about 6 Spring Boot applications with REST APIs running with Actuator and Prometheus support.
These are running on Docker, but the actuator port is not exposed.
Although we can connect each application actuator to an Prometheus and Grafana instance.

On of the application has OpenAPI documentation with SwaggerUI. This SwaggerUI is exposed through Actuator management port.

<dependency>
    <groupId>.springdoc</groupId>
    <artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
    <version>2.8.5</version>
</dependency>

Now I want to make similar OpenAPI documentation for the other applications.
However having our users to deal with 6+ different URLs for accessing the various OpenAPI documentation is not a good solution.

Is there any way I can combine all the SwaggerUIs OpenAPI definitions into one single SwaggerUI something similar as I do with Actuator and Prometheus?

Otherwise I was thinking the only way is to have each application generate an openapi.json for its APIs, then "somehow" export this file to a running SwaggerUI application (running on docker).
I can generate an openapi.json for each application with the springdoc-openapi-maven-plugin.

Having about 6 Spring Boot applications with REST APIs running with Actuator and Prometheus support.
These are running on Docker, but the actuator port is not exposed.
Although we can connect each application actuator to an Prometheus and Grafana instance.

On of the application has OpenAPI documentation with SwaggerUI. This SwaggerUI is exposed through Actuator management port.

<dependency>
    <groupId>.springdoc</groupId>
    <artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
    <version>2.8.5</version>
</dependency>

Now I want to make similar OpenAPI documentation for the other applications.
However having our users to deal with 6+ different URLs for accessing the various OpenAPI documentation is not a good solution.

Is there any way I can combine all the SwaggerUIs OpenAPI definitions into one single SwaggerUI something similar as I do with Actuator and Prometheus?

Otherwise I was thinking the only way is to have each application generate an openapi.json for its APIs, then "somehow" export this file to a running SwaggerUI application (running on docker).
I can generate an openapi.json for each application with the springdoc-openapi-maven-plugin.

Share Improve this question edited Mar 7 at 9:03 seenukarthi 8,68410 gold badges50 silver badges74 bronze badges asked Mar 7 at 8:48 DJVikingDJViking 8821 gold badge15 silver badges31 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

What I have used previously is a wrapper/façade Swagger UI server.

It presents a dropdown to choose one of the 6 services. That fetches the v2/api-docs/management json (or v3/api-docs/management) for Actuator stuff from the nominated server and uses it as the base url in SwaggerUI. You need to make sure that the value of servers[].url returned in api-docs json reflects the hostname of the actual server as seen by the browser. You can set this in Spring Boot with @OpenAPIDefinition(servers = {@Server(url = "https://hostname/",

The swagger page for a renamed server looks like the image below with the /v3/api-docs/management json.

本文标签: openapiSpring Boot Combine multiple applications SwaggerUIStack Overflow