问题
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-uiJAR which contains all the static UI artifacts.A
swagger.jsonfile containing all the JSON definition located under theresourcesfolder.A custom controller having the following endpoints to meet all the requests from the
swagger-ui.html:/swagger-resourcesendpoint which returns a JSON string representation of aspringfox.documentation.swagger.web.SwaggerResourceobject./swagger-resources/configuration/uiendpoint which returns a JSON string representation of aspringfox.documentation.swagger.web.UiConfigurationobject./swagger-resources/configuration/securityendpoint which returns a JSON string representation of aspringfox.documentation.swagger.web.SecurityConfigurationobject./v2/api-docsendpoint 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