Skip to content
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

Swagger losing context-path in 4.6.x #1774

Closed
wmunyan opened this issue Sep 18, 2024 · 2 comments · Fixed by #1775
Closed

Swagger losing context-path in 4.6.x #1774

wmunyan opened this issue Sep 18, 2024 · 2 comments · Fixed by #1775

Comments

@wmunyan
Copy link

wmunyan commented Sep 18, 2024

Expected Behavior

I expect to see the swagger output including the context-path for all the controllers

Actual Behaviour

From Post on Discord:

I have applications that I've updated to 4.6.2, and those applications have custom context paths, like /my/api/content, and when I compile the application, my swagger-ui shows my endpoints without the context path, so something like /my/api/content/home is just showing as /home in the swagger. I tried adding the micronaut.openapi.context.path to the application.yml but when I do that, the generated swagger index.html shows the context path doubled, i.e /my/api/content/my/api/content. I tried this on 4.6.2, 4.6.1, and 4.6.0 with the same results. Only when I went back to 4.5.1 did my swagger work again. Anyone seen similar behavior? I definitely have more investigating to do but wanted to get the post out as soon as I could. Thanks for any help!

In one configuration I was able to see the swagger-ui, but the endpoints shown did not include the context-path
In other configurations I just got a blank page for the swagger-ui, and investigating the index.html page, I saw the context-path doubled, i.e. /wkm/api/wkm/api/...

Steps To Reproduce

Project is here - https://github.com/wmunyan/heartbeat - It's got some other things in there, that I've been experimenting with so a lot of the OpenAPI/Swagger stuff is just cut/paste from Micronaut documentation

I've been running the application through my IDE (IntelliJ) using:

  • Running gradlew clean assemble to build the application and generate the swagger
  • Using IntelliJ's support for Micronaut to run the application
  • Attempt to navigate to http://localhost:8080/wkm/api/swagger-ui

Environment Information

  • OS: I first noticed the issue on a work project, that I am running on Windows locally, and it shows up in the deployed application, using amazon linux 2023 in a docker container (running on ECS). The sample project I've developed on Mac
  • Java version is 17
  • I have seen the issue in both pure Java applications and this sample application which uses Groovy

Example Application

https://github.com/wmunyan/heartbeat

Version

4.6.x

@altro3
Copy link
Collaborator

altro3 commented Sep 18, 2024

@wmunyan Looks to the generated files in 6.11.1 and 6.12.3. As you see, paths are the same:

{887D3625-4A40-4E61-BEA0-BAEBA57F5594}

Hmmm... can't reproduce this bug with your sample - all works fine with micronaut.openapi.server.context.path=/

In second case with micronaut.openapi.server.context.path=/wkm/api: you set micronaut.server.context-path = /wkm/api property in application.yml - that's why you have final prefix /wkm/api/wkm/api

But in both cases I see that swagger-ui works correctly, both with version 6.11.1 and with version 6.12.3.

6.12.3:
{3C046CD8-18C3-4C77-94EB-8D7AB47ACA41}

6.11.1:
{5B992060-848F-4F69-89F8-3C6090C4CCD0}

Perhaps I did not understand what the problem is, but then please formulate the problem in more detail.

@altro3
Copy link
Collaborator

altro3 commented Sep 18, 2024

Oh, sorry, I see now. The problem with endpoints... not with swagger-ui. Ok, I'll fix it

altro3 added a commit to altro3/micronaut-openapi that referenced this issue Sep 18, 2024
altro3 added a commit to altro3/micronaut-openapi that referenced this issue Sep 18, 2024
altro3 added a commit to altro3/micronaut-openapi that referenced this issue Sep 19, 2024
altro3 added a commit to altro3/micronaut-openapi that referenced this issue Sep 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants