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

Getting 404 when trying to access swagger-ui of a native spring-boot app #1394

Closed
ivangfr opened this issue Dec 17, 2021 · 3 comments
Closed
Labels
bug Something isn't working

Comments

@ivangfr
Copy link

ivangfr commented Dec 17, 2021

Describe the bug
After updating my spring-boot project to 2.6.1 and springdoc-openapi to 1.6.1, compiling and starting successfully the Docker native container, when trying to access the swagger-ui, the website doesn't open and a 404 is returned.

To Reproduce

Expected behavior

  • The swagger-ui.html website should open

Screenshots

Screenshot 2021-12-17 at 10 17 28

Additional context
The http://localhost:8080/v3/api-docs works and returns

{
	"openapi":"3.0.1",
	"info":{"title":"game-score-api"},
	"servers":[{"url":"http://localhost:8080","description":"Generated server url"}],
	"tags":[{"name":"Actuator","description":"Monitor and interact","externalDocs":{"description":"Spring Boot Actuator Web API Documentation","url":"https://docs.spring.io/spring-boot/docs/current/actuator-api/html/"}}],
	"paths":{
		"/api/games":{"get":{"tags":["game-score-controller"],"operationId":"getGameScores","parameters":[{"name":"title","in":"query","required":false,"schema":{"type":"string"}}],"responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"$ref":"#/components/schemas/PageGameScoreResponse"}}}}}}},
		"/api/games/{id}":{"get":{"tags":["game-score-controller"],"operationId":"getGameScore","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer","format":"int64"}}],"responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"$ref":"#/components/schemas/GameScoreResponse"}}}}}}},
		"/actuator":{"get":{"tags":["Actuator"],"summary":"Actuator root web endpoint","operationId":"links_1","responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"type":"object","additionalProperties":{"type":"object","additionalProperties":{"$ref":"#/components/schemas/Link"}}}}}}}}},
		"/actuator/metrics":{"get":{"tags":["Actuator"],"summary":"Actuator web endpoint 'metrics'","operationId":"metrics_2","responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"type":"object"}}}}}}},
		"/actuator/metrics/{requiredMetricName}":{"get":{"tags":["Actuator"],"summary":"Actuator web endpoint 'metrics-requiredMetricName'","operationId":"metrics-requiredMetricName_2","parameters":[{"name":"requiredMetricName","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"type":"object"}}}}}}},
		"/actuator/mappings":{"get":{"tags":["Actuator"],"summary":"Actuator web endpoint 'mappings'","operationId":"mappings_2","responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"type":"object"}}}}}}},
		"/actuator/info":{"get":{"tags":["Actuator"],"summary":"Actuator web endpoint 'info'","operationId":"info_2","responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"type":"object"}}}}}}},
		"/actuator/health":{"get":{"tags":["Actuator"],"summary":"Actuator web endpoint 'health'","operationId":"health_2","responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"type":"object"}}}}}}},
		"/actuator/health/**":{"get":{"tags":["Actuator"],"summary":"Actuator web endpoint 'health-path'","operationId":"health-path_2","responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"type":"object"}}}}}}},
		"/actuator/env":{"get":{"tags":["Actuator"],"summary":"Actuator web endpoint 'env'","operationId":"env_2","responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"type":"object"}}}}}}},
		"/actuator/env/{toMatch}":{"get":{"tags":["Actuator"],"summary":"Actuator web endpoint 'env-toMatch'","operationId":"env-toMatch_2","parameters":[{"name":"toMatch","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"type":"object"}}}}}}},
		"/actuator/beans":{"get":{"tags":["Actuator"],"summary":"Actuator web endpoint 'beans'","operationId":"beans_2","responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"type":"object"}}}}}}}},
		"components":{"schemas":{"GameScoreResponse":{"type":"object","properties":{"id":{"type":"integer","format":"int64"},"title":{"type":"string"},"score":{"type":"integer","format":"int32"}}},"PageGameScoreResponse":{"type":"object","properties":{"totalElements":{"type":"integer","format":"int64"},"totalPages":{"type":"integer","format":"int32"},"numberOfElements":{"type":"integer","format":"int32"},"first":{"type":"boolean"},"last":{"type":"boolean"},"sort":{"$ref":"#/components/schemas/Sort"},"size":{"type":"integer","format":"int32"},"content":{"type":"array","items":{"$ref":"#/components/schemas/GameScoreResponse"}},"number":{"type":"integer","format":"int32"},"pageable":{"$ref":"#/components/schemas/Pageable"},"empty":{"type":"boolean"}}},"Pageable":{"type":"object"},"Sort":{"type":"object","properties":{"empty":{"type":"boolean"}}},"Link":{"type":"object","properties":{"href":{"type":"string"},"templated":{"type":"boolean"}}}}}
}
@bnasslahsen
Copy link
Contributor

bnasslahsen commented Dec 17, 2021

@ivangfr,

This is a first workaround in your application.properties:

springdoc.swagger-ui.version=4.1.3

Or as docker argument to your existing image: -e SPRINGDOC_SWAGGERUI_VERSION=4.1.3

Note that since v1.6.0, the following code block, is not anymore needed:

    static {
        SpringDocUtils.getConfig()
                .replaceWithClass(org.springframework.data.domain.Pageable.class, org.springdoc.core.converters.models.Pageable.class);
    }

And meanwhile, we will investigate why the property is not loaded out of the box for this case.

@bnasslahsen
Copy link
Contributor

@ivangfr,

You can upgrade to v1.6.2 which fixes this issue (You won't need the properties listed above).

The root cause of this issue, depends on Properties that are not sometimes available in the Environment which will be enhanced in spring-native.

Once, this enhancement will be available, we can improve the code for handling these properties to be more spring friendly.

@ivangfr
Copy link
Author

ivangfr commented Dec 20, 2021

Thanks @bnasslahsen fast response and support.

I've updated springboot-jsoup-html-parser with springdoc-openapi 1.6.2 and it works fine.

@bnasslahsen bnasslahsen added the bug Something isn't working label Jan 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants