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-UI 3.52.5 to 4.1.3 seeing PetStore page #7723

Closed
act-amirsky opened this issue Dec 28, 2021 · 4 comments
Closed

Swagger-UI 3.52.5 to 4.1.3 seeing PetStore page #7723

act-amirsky opened this issue Dec 28, 2021 · 4 comments

Comments

@act-amirsky
Copy link

Hello,

I tried upgrading from Swagger-UI 3.52.5 to 4.1.3 and upon doing so, my ui is showing the pet store UI.
My swagger document is build using springfox. Of course all of this was functioning find with Swagger-UI 3.52.5

I am not sure if the correct code to look at but here is our method for mapping out /api/swagger-ui.html URL to swagger-UI.

Any help or guidance would be greatly appreciated.

@Controller
    public static class SwaggerRedirect {
        //taken from https://github.com/springfox/springfox/issues/3193#issuecomment-558748502

        @Value("${springfox.documentation.swagger.v2.path:/v2/api-docs}")
        private String springfoxPath;

        @GetMapping("/swagger-ui.html")
        public void redirectToUi(HttpServletRequest request, HttpServletResponse response) throws IOException {
            final String contextPath = request.getContextPath();
            final String url = "?url=" + contextPath + springfoxPath;
            response.sendRedirect("webjars/swagger-ui/4.1.3/index.html" + url);
        }
    }
@vgropp
Copy link

vgropp commented Jan 4, 2022

this should fix your issue: #4872

@act-amirsky
Copy link
Author

act-amirsky commented Apr 4, 2022

Sorry for the long delay in response. I think it am missing something here that you are saying to define "url" configuration and provide details examples. Those are based in JavaScript when above, our starting point is Java. However, how are those configurations supposed to be declared from the side of Java?

@vgropp
Copy link

vgropp commented Apr 5, 2022

it seems like you use springfox, i have no idea how to configure it with it. We are using springdoc and can configure SPRINGDOC_SWAGGER_UI_DISABLE_SWAGGER_DEFAULT_URL = true and use SPRINGDOC_SWAGGER_UI_URL to use our custom url. For a bit more background with this problem with springdoc see springdoc/springdoc-openapi#1492 (comment)

@act-amirsky
Copy link
Author

Ok. We were using Springfox integration with Swagger-UI to build the visual API documentation page. I think instead of the "backend" managing this, I am going to keep the backend as pure JSON/YAML provider and use Swagger-UI's front-end dist with the source URL hard-coded to my application's swagger doc URL.

That way i think this will greatly simplify the layout and also be more conscious of the potential security risks I think is being discussed in #4872 or leaving the 'url' parameter open.

Thanks for the help.

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

No branches or pull requests

2 participants