Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
API docs url is empty and endpoints not accessible (404) #867
I think this might be more of a setup problem however the api-docs endpoint offers only an empty map and the endpoints for the documentation result in a 404.
The logs for my app show that the controllers are being scanned.
My configuration class:
The versions I'm using are:
The application is running as ROOT context so there shouldn't be any problems with
My logs contain:
However this is not accessible on http://localhost:8080/v2/api-docs/default/my-controller as expected.
Accessing http://localhost:8080/v2/api-docs returns:
Please note I have had this working using the old com.mangofactory version and followed the migration documentation
Finally the swagger-ui.html is trying to access undefined:
Any help or advice would be gratefully received
This was due to me using the GSON library to generate the Json. I switched on the excludeFieldsWithoutExposeAnnotation() which meant that none of the objects would produce any data. To get around this I created several serialisers for the following classes:
.registerTypeAdapter(springfox.documentation.service.ApiListing.class, new SwaggerApiListingJsonSerializer()) .registerTypeAdapter(springfox.documentation.spring.web.json.Json.class, new SwaggerJsonSerializer()) .registerTypeAdapter(springfox.documentation.swagger.web.SwaggerResource.class, new SwaggerResourceSerializer()) .registerTypeAdapter(springfox.documentation.service.ResourceListing.class, new SwaggerResourceListingJsonSerializer()) .registerTypeAdapter(springfox.documentation.swagger.web.SwaggerResource.class, new SwaggerResourceSerializer()) .registerTypeAdapter(springfox.documentation.swagger.web.SecurityConfiguration.class, new SwaggerSecurityConfigurationSerializer()) .registerTypeAdapter(springfox.documentation.swagger.web.UiConfiguration.class, new SwaggerUiConfigurationSerializer());
Ah great! Thanks for reporting your solution back
In addition since we're not really supporting gson, would you be able to create an adapter for gson such that it always works if gson is found in the classpath? I might attempt it but since your more intimate it would be great if you could shepherd that! I'd be happy to collaborate
The solution for Gson use in Swagger looks intriguing. However, when I try to use the code, none of the