问题
I am using Springfox v 2.7 and I'd like to generate my Swagger UI from a JSON file, to keep my Controller classes clean, and without annotations from Swawgger (@Api, @ApiDocs) either my model classes without any annotation (@ApiModelProperty, etc)....
Regards!
PD: This is a Spring boot 1.5.8 version App.
回答1:
Here are the changes you need to make:
Only Springfox JAR needed is
springfox-swagger-ui
JAR which contains all the static UI artifacts.A
swagger.json
file containing all the JSON definition located under theresources
folder.A custom controller having the following endpoints to meet all the requests from the
swagger-ui.html
:/swagger-resources
endpoint which returns a JSON string representation of aspringfox.documentation.swagger.web.SwaggerResource
object./swagger-resources/configuration/ui
endpoint which returns a JSON string representation of aspringfox.documentation.swagger.web.UiConfiguration
object./swagger-resources/configuration/security
endpoint which returns a JSON string representation of aspringfox.documentation.swagger.web.SecurityConfiguration
object./v2/api-docs
endpoint which returns a JSON representation of a Swagger API definition.
You can find a working example here.
来源:https://stackoverflow.com/questions/47439776/generate-swagger-from-a-json-to-keep-clean-my-java-classes