我正在构建一个Spring Boot应用程序,并使用Spring Fox Swagger UI使用Swagger UI对其进行记录 . 我've got everything documented, but want to customize the title and description but can'弄清楚如何 . 例如,在此图像中:https://springfox.github.io/springfox/docs/current/images/springfox-swagger-ui.png Headers 为"Springfox petstore API",描述为Lorem Ipsum . 但在我的Swagger UI中, Headers 和描述都说"API Documentation" . 我尝试过使用@SwaggerDefinition注释,但似乎没有做任何事情 .
1 回答
我建议你使用swagger editor,然后你可以使用顶层菜单中的"Generate Server"选项从API文档自动生成Spring Boot服务器 . 这对于第一次生成API非常有用 .
如果要从YAML进行设置,则必须在 info 部分提供此字段:
从代码中,检查Swagger编辑器生成的类,并将其与您的代码进行比较 . 您可以设置描述和 Headers ,在ApiInfo Builder对象上设置相应的属性,该对象位于SwaggerDocumentationConfig类中 .
在这里你有代码:
如果这对您没有任何意义,请向我展示一些代码,以了解您如何使用Springfox,我可以更好地帮助您 .
祝贺你!