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

Can't load swagger-ui.html #2

Open
nvtuan305 opened this issue Nov 14, 2018 · 2 comments
Open

Can't load swagger-ui.html #2

nvtuan305 opened this issue Nov 14, 2018 · 2 comments

Comments

@nvtuan305
Copy link

When I access http://localhost:8080/swagger-ui.html, I got the below message. But accessing http://localhost:8080/v2/api-docs page return the API json content.

Unable to infer base url. This is common when using dynamic servlet registration or when the API is behind an API Gateway. The base url is the root of where all the swagger resources are served. For e.g. if the api is available at http://example.org/api/v2/api-docs then the base url is http://example.org/api/. Please enter the location manually

Thank you!

@hacki11
Copy link

hacki11 commented Aug 30, 2019

As of springfox 2.9.2 breaking changes came into:
springfox.documentation.swagger.web.SwaggerResource
springfox.documentation.swagger.web.UiConfiguration

The configs in SwaggerJsonController must be updated like:

    //https://stackoverflow.com/questions/47395549/springfox-swagger-ui-from-existing-json
    // springfox.documentation.swagger.web.SwaggerResource
    private static String swaggerResource = "[\n" +
            "  {\n" +
            "    \"name\": \"default\",\n" +
            "    \"url\": \"/v2/api-docs\",\n" +
            "    \"swaggerVersion\": \"2.0\"\n" +
            "  }\n" +
            "]";

    // springfox.documentation.swagger.web.UiConfiguration
    private static String uiConfiguration = "{\n" +
            "\"deepLinking\": true,\n" +
            "\"displayOperationId\": false,\n" +
            "\"defaultModelsExpandDepth\": 1,\n" +
            "\"defaultModelExpandDepth\": 1,\n" +
            "\"defaultModelRendering\": \"example\",\n" +
            "\"displayRequestDuration\": false,\n" +
            "\"docExpansion\": \"none\",\n" +
            "\"filter\": false,\n" +
            "\"operationsSorter\": \"alpha\",\n" +
            "\"showExtensions\": false,\n" +
            "\"tagsSorter\": \"alpha\",\n" +
            "\"validatorUrl\": \"\",\n" +
            "\"apisSorter\": \"alpha\",\n" +
            "\"jsonEditor\": false,\n" +
            "\"showRequestHeaders\": false,\n" +
            "\"supportedSubmitMethods\": [\n" +
            "\"get\",\n" +
            "\"put\",\n" +
            "\"post\",\n" +
            "\"delete\",\n" +
            "\"options\",\n" +
            "\"head\",\n" +
            "\"patch\",\n" +
            "\"trace\"\n" +
            "]\n" +
            "}";

    // springfox.documentation.swagger.web.SecurityConfiguration
    private static String securityConfiguration = "{}";

I like this example project because you do not need springfox-swagger2 as a library, it will just work with springfox-swagger-ui and my exisiting swagger.json generated by kongchens maven plugin.

@umeshravuru
Copy link

http://localhost:8080/v2/api-docs is returning back the json from swagger.json but the http://localhost:8080/swagger-ui.html is giving me back 500 response

**Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.

Tue Jul 20 11:27:52 EDT 2021
There was an unexpected error (type=Internal Server Error, status=500).
Already connected**

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

3 participants