首页 > 其他分享 >超简单实现将swagger文档转word

超简单实现将swagger文档转word

时间:2022-08-19 14:45:09浏览次数:72  
标签:swagger word documentation 文档 import springfox

超简单实现将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

相关文章

  • Navicat 连接MySQL数据库出现错误:2059 - authentication plugin 'caching_sha2_passwo
    出现这个错误的原因是因为MySQL8.0.19数据库使用的加密方式是:caching_sha2_password,解决: 1 showvariableslike'default_authentication_plugin查看加密信息 2 ......
  • Could not resolve placeholder 'jdbc.password' in string value "${jdbc.password}"
    spring连接数据库时报错org.springframework.beans.factory.BeanDefinitionStoreException:Invalidbeandefinitionwithname'dataSource'definedinclasspathres......
  • 文档根元素 "mapper" 必须匹配 DOCTYPE 根 "null"(mapper)
    mapperw文件报错文档根元素"mapper"必须匹配DOCTYPE根"null"原因无法识别mapper文件解决加上<!DOCTYPEmapperPUBLIC"-//mybatis.org//DTDMapper3.0//EN""m......
  • 文本编辑器MarkMyWords
    MarkMyWords是一款提供实时预览格式化的文章或预览HTML代码等功能的文本编辑器,可以帮助大家在无干扰模式下进行文本编辑,提高大家工作时的专注力。MarkMyWords为大家提供了......
  • swagger关于参数的配置
    1.springboot集成swagger2时get方式传参在swagger-ui.html中相应的api中为参数赋值问题在@ApilmplicitParam配置一个参数paramType="query"加在后面就行了。这个属性是......
  • Markdow文档编辑
    MarkDown学习标题一级标题#标题二级别标题##标题以此类推最高六级##与标题之间加空格字体粗体文字两边加两个*斜体文字两边加一个*斜体加粗文字两......
  • 804. Unique Morse Code Words
    InternationalMorseCodedefinesastandardencodingwhereeachletterismappedtoaseriesofdotsanddashes,asfollows:'a' mapsto ".-",'b' mapsto......
  • readme 用法相关详细文档
    https://docs.github.com/cn/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax基本撰写和......
  • HDU - 2222 Keywords Search
    思路:AC自动机模板+拓扑优化。因为当前单词可能包含别的单词,所以需要一直nex,但是本题会超时,所以思考优化这个过程。我们知道,拓扑优化,可以将所有出现过的字符都标记上,这......
  • LeetCode 127 Word Ladder
    AtransformationsequencefromwordbeginWordtowordendWordusingadictionarywordListisasequenceofwordsbeginWord->s1->s2->...->sksuchthat:......