swagger-api / swagger-codegen

swagger-codegen contains a template-driven engine to generate documentation, API clients and server stubs in different languages by parsing your OpenAPI / Swagger definition.
http://swagger.io
Apache License 2.0
17.05k stars 6.03k forks source link

swagger code generation for spring boot page not found #5409

Closed jackxpeng closed 7 years ago

jackxpeng commented 7 years ago

generated spring boot code always returns 404. I tried git clone, the cli jar, and the online editor. Same thing. In each case I just used either the petstore json or in the case of the online editor, I did not modify the yaml. I was just trying codegen out for a project.

Swagger-codegen version

latest

Swagger declaration file content or url

just try it

Command line used for generation

use the one in samples/server/petstore/springboot

Steps to reproduce

mvn spring-boot:run

Related issues

none spring-server-generated.zip

Suggest a Fix

none

cbornet commented 7 years ago

What request are you doing ?

jackxpeng commented 7 years ago

I tried requests in chrome like

http://localhost:8080/ http://localhost:8080/estimates/price http://localhost:8080/estimates/time http://localhost:8080/webjars http://localhost:8080/api-docs http://localhost:8080/swagger-ui.html

I see a list of mappings when starting it up so I tried them to no avail.

2017-04-18 10:21:39.878 INFO 19377 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/]}" onto public java.lang.String io.swagger.configuration.HomeController.index() 2017-04-18 10:21:39.883 INFO 19377 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/products],methods=[GET],produces=[application/json]}" onto public org.springframework.http.ResponseEntity<java.util.List> io.swagger.api.ProductsApiController.productsGet(java.lang.Double,java.lang.Double) 2017-04-18 10:21:39.884 INFO 19377 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/me],methods=[GET],produces=[application/json]}" onto public org.springframework.http.ResponseEntity io.swagger.api.MeApiController.meGet() 2017-04-18 10:21:39.885 INFO 19377 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/history],methods=[GET],produces=[application/json]}" onto public org.springframework.http.ResponseEntity io.swagger.api.HistoryApiController.historyGet(java.lang.Integer,java.lang.Integer) 2017-04-18 10:21:39.886 INFO 19377 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/estimates/price],methods=[GET],produces=[application/json]}" onto public org.springframework.http.ResponseEntity<java.util.List> io.swagger.api.EstimatesApiController.estimatesPriceGet(java.lang.Double,java.lang.Double,java.lang.Double,java.lang.Double) 2017-04-18 10:21:39.886 INFO 19377 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/estimates/time],methods=[GET],produces=[application/json]}" onto public org.springframework.http.ResponseEntity<java.util.List> io.swagger.api.EstimatesApiController.estimatesTimeGet(java.lang.Double,java.lang.Double,java.util.UUID,java.lang.String) 2017-04-18 10:21:39.886 INFO 19377 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/api-docs],methods=[GET],produces=[application/json || application/hal+json]}" onto public org.springframework.http.ResponseEntity springfox.documentation.swagger2.web.Swagger2Controller.getDocumentation(java.lang.String,javax.servlet.http.HttpServletRequest) 2017-04-18 10:21:39.891 INFO 19377 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/swagger-resources/configuration/ui]}" onto org.springframework.http.ResponseEntity springfox.documentation.swagger.web.ApiResourceController.uiConfiguration() 2017-04-18 10:21:39.891 INFO 19377 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/swagger-resources]}" onto org.springframework.http.ResponseEntity<java.util.List> springfox.documentation.swagger.web.ApiResourceController.swaggerResources() 2017-04-18 10:21:39.892 INFO 19377 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/swagger-resources/configuration/security]}" onto org.springframework.http.ResponseEntity springfox.documentation.swagger.web.ApiResourceController.securityConfiguration() 2017-04-18 10:21:39.894 INFO 19377 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse) 2017-04-18 10:21:39.895 INFO 19377 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest) 2017-04-18 10:21:40.030 INFO 19377 --- [ main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@6ad85ac7: startup date [Tue Apr 18 10:21:37 PDT 2017]; root of context hierarchy 2017-04-18 10:21:40.067 INFO 19377 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]

cbornet commented 7 years ago

Your context path is /v1 So try http://localhost:8080/v1/swagger-ui.html

jackxpeng commented 7 years ago

oh that's it. Thanks a lot, Christophe!