超简单实现将swagger文档转word
1、项目pom文件引入依赖包:
<dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger2</artifactId> <version>2.7.0</version> </dependency> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger-ui</artifactId> <version>2.7.0</version> </dependency>
2、项目代码中写入相关配置:
##### 1、新增配置类
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import springfox.documentation.builders.ApiInfoBuilder; import springfox.documentation.builders.PathSelectors; import springfox.documentation.builders.RequestHandlerSelectors; import springfox.documentation.spi.DocumentationType; import springfox.documentation.spring.web.plugins.Docket; import springfox.documentation.swagger2.annotations.EnableSwagger2; /** * Created with IntelliJ IDEA. * @Description: Swagger配置信息 */ @Configuration @EnableSwagger2 //@Profile({"dev","test"}) public class SwaggerConfig { @Bean public Docket createRestApi() { return new Docket(DocumentationType.SWAGGER_2) .pathMapping("/") .select() .apis(RequestHandlerSelectors.basePackage("com.aaaa.aaa.aaaaa.controller")) .paths(PathSelectors.any()) .build().apiInfo(new ApiInfoBuilder() .title("AAAAAA服务") .description("AAAAAAA接口服务") .version("1.0") .build()); } }
##### 2、controller层添加代码:
定义在类上:@Api
定义在方法上:@ApiOperation
3、打开swagger文档:
4、拿到json字符串:
5、将json字符串进行在线转换:
https://tools.kalvinbg.cn/dev/swagger2word
6、文档展示样例:
以上仅作为参考:
标签:swagger,word,documentation,文档,import,springfox From: https://www.cnblogs.com/subtlman/p/16601908.html