Skip to content

GroupedOpenApi seems to not be working with SwaggerUiConfigParameters.urls together #2739

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
eekyrus opened this issue Sep 30, 2024 · 5 comments
Labels
invalid This doesn't seem right

Comments

@eekyrus
Copy link

eekyrus commented Sep 30, 2024

Describe the bug

I want to combine internal application's OpenAPI spec with external specs into one single Swagger UI.
According to already solved issues:
#309
#584
it should be possible:

If you want to combine in the same swagger-ui both, REST APIs that are deployed within the same application as the swagger-ui and external REST APIs: This is an enhancement and will be available with the next release: v1.2.22.

To achieve that, you declare your REST APIs that are deployed within the same application as the swagger-ui using GroupedOpenApi.
And you external REST APIs with the following syntax:

SwaggerUiConfigProperties.addGroup("group1", "url1");
SwaggerUiConfigProperties.addGroup("group2", "url2");

To Reproduce
Steps to reproduce the behavior:

Start application which contains OpenAPI spec:
https://github.com/eekyrus/Microservice
Start Spring Gateway application which contains both external Swagger url configuration and GroupedOpenApi configuration:
https://github.com/eekyrus/GroupedOpenApiBug

Try accessing Swagger via localhost:8080/swagger-ui.html.

Expected behavior

Both groups under Definitions dropdown display Swagger UI. 'Microservice' definition should display external Microservice application OpenAPI spec, while 'internalservice' definition should display internal application's OpenAPI spec (empty in demo application).

Additional context
In demo application, removing GroupedOpenApi bean definition and uncommenting PostConstruct code snippet which only defines external swagger urls makes external OpenAPI specs work. It seems that the Spring Gateway application does not receive request to its routing mechanism when GroupedOpenApi configuration is used and does not forward request to Microservice application.

@bnasslahsen
Copy link
Collaborator

@eekyrus,

Again, Remember, contributions to this repository should follow its contributing guidelines, security policy, and code of conduct.

For how to use the gateway with services, see the following demos samples:

@bnasslahsen bnasslahsen added the invalid This doesn't seem right label Sep 30, 2024
@eekyrus
Copy link
Author

eekyrus commented Oct 1, 2024

The demo doesn't use GroupedOpenApi.

@bnasslahsen
Copy link
Collaborator

@eekyrus,

See the answer here #2741 why GroupedOpenApi are not used anymore.

@eekyrus
Copy link
Author

eekyrus commented Oct 2, 2024

As I understand, GroupedOpenApi is still used for internal OpenApi spec generation, while Swagger urls property on SwaggerUiConfigProperties is used for external OpenApi spec generation. The issue here is that they cannot be combined. Is this intended behavior?

@bnasslahsen
Copy link
Collaborator

@eekyrus,

You maybe do did not read the answer...

We limited the use GroupedOpenApi. so scan for beans within the same application context, to allow dynamic scan.
If you have external URL, that you need to aggregate them based on SwaggerUrl.

Which means they can be combined for different purposes.

@springdoc springdoc locked as too heated and limited conversation to collaborators Oct 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

2 participants