Skip to content

Commit

Permalink
修改内容
Browse files Browse the repository at this point in the history
  • Loading branch information
mason committed Nov 21, 2019
1 parent 8e1b1a3 commit 3352b78
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 92 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
2. `advance-sagger-demo`

- 示例功能:包含对接口进行动态过滤,结合easymock进行数据模拟,对接口文档进行离线文档输出等功能。
- 文章:springboot+swagger接口文档企业实践(下)
- 文章:[springboot+swagger接口文档企业实践(下)](https://mianshenglee.github.io/2019/11/21/springboot-swagger2.html)



Expand Down
2 changes: 1 addition & 1 deletion springboot-swagger-demo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
2. `advance-sagger-demo`

- 示例功能:包含对接口进行动态过滤,结合easymock进行数据模拟,对接口文档进行离线文档输出等功能。
- 文章:springboot+swagger接口文档企业实践(下)
- 文章:[springboot+swagger接口文档企业实践(下)](https://mianshenglee.github.io/2019/11/21/springboot-swagger2.html)
10 changes: 5 additions & 5 deletions springboot-swagger-demo/advance-swagger-demo/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,11 @@
<version>1.18.10</version>
</dependency>
<!-- swagger文档离线输出 -->
<!--<dependency>-->
<!--<groupId>io.github.swagger2markup</groupId>-->
<!--<artifactId>swagger2markup</artifactId>-->
<!--<version>${swagger2markup.version}</version>-->
<!--</dependency>-->
<dependency>
<groupId>io.github.swagger2markup</groupId>
<artifactId>swagger2markup</artifactId>
<version>${swagger2markup.version}</version>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ public Docket v100Api() {
//是否启用
.enable(swaggerInfo.getEnable());
ApiSelectorBuilder builder = docket.select();
//
// 指定需要过滤的版本号
builder = builder.apis(Predicates.and(apisFilter(false,true
,new String[]{ApiVersionConstant.VERVION_100})));
//接口路径过滤
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package me.mason.advswagger.demo;

//import io.github.swagger2markup.GroupBy;
//import io.github.swagger2markup.Language;
//import io.github.swagger2markup.Swagger2MarkupConfig;
//import io.github.swagger2markup.Swagger2MarkupConverter;
//import io.github.swagger2markup.builder.Swagger2MarkupConfigBuilder;
//import io.github.swagger2markup.markup.builder.MarkupLanguage;
import io.github.swagger2markup.GroupBy;
import io.github.swagger2markup.Language;
import io.github.swagger2markup.Swagger2MarkupConfig;
import io.github.swagger2markup.Swagger2MarkupConverter;
import io.github.swagger2markup.builder.Swagger2MarkupConfigBuilder;
import io.github.swagger2markup.markup.builder.MarkupLanguage;
import org.junit.jupiter.api.Test;

import java.net.URL;
Expand All @@ -21,85 +21,85 @@ public class SwaggerExportTest {

private String url = "http://localhost:8080/swaggerdemo/v2/api-docs?group=default";

// //输出到目录,分割到各个文件
// /**
// * 生成AsciiDocs格式文档
// * @throws Exception
// */
// @Test
// public void generateAsciiDocs() throws Exception {
// // 输出Ascii格式
// Swagger2MarkupConfig config = new Swagger2MarkupConfigBuilder()
// .withMarkupLanguage(MarkupLanguage.ASCIIDOC)
// .withOutputLanguage(Language.ZH)
// .withPathsGroupedBy(GroupBy.TAGS)
// .withGeneratedExamples()
// .withoutInlineSchema()
// .build();
// // swagger-ui.html页面中能找到此链接
// Swagger2MarkupConverter.from(new URL(url))
// .withConfig(config)
// .build()
// .toFolder(Paths.get("./docs/asciidoc"));
// }
//
//
// /**
// * 生成Markdown文档
// * @throws Exception
// */
// @Test
// public void generateMarkdownDocs() throws Exception {
// // 输出Markdown格式
// Swagger2MarkupConfig config = new Swagger2MarkupConfigBuilder()
// .withMarkupLanguage(MarkupLanguage.MARKDOWN)
// .withOutputLanguage(Language.ZH)
// .withPathsGroupedBy(GroupBy.TAGS)
// .withGeneratedExamples()
// .withoutInlineSchema()
// .build();
//
// Swagger2MarkupConverter.from(new URL(url))
// .withConfig(config)
// .build()
// .toFolder(Paths.get("./docs/mk"));
// }
//
//
// //输出汇总到一个文件
// @Test
// public void generateAsciiDocsToFile() throws Exception {
// // 输出Ascii到单文件
// Swagger2MarkupConfig config = new Swagger2MarkupConfigBuilder()
// .withMarkupLanguage(MarkupLanguage.ASCIIDOC)
// .withOutputLanguage(Language.ZH)
// .withPathsGroupedBy(GroupBy.TAGS)
// .withGeneratedExamples()
// .withoutInlineSchema()
// .build();
//
// Swagger2MarkupConverter.from(new URL(url))
// .withConfig(config)
// .build()
// .toFile(Paths.get("./docs/asciidoc-all"));
// }
//
// @Test
// public void generateMarkdownDocsToFile() throws Exception {
// // 输出Markdown到单文件
// Swagger2MarkupConfig config = new Swagger2MarkupConfigBuilder()
// .withMarkupLanguage(MarkupLanguage.MARKDOWN)
// .withOutputLanguage(Language.ZH)
// .withPathsGroupedBy(GroupBy.TAGS)
// .withGeneratedExamples()
// .withoutInlineSchema()
// .build();
//
// Swagger2MarkupConverter.from(new URL(url))
// .withConfig(config)
// .build()
// .toFile(Paths.get("./docs/mk-all"));
// }
//输出到目录,分割到各个文件
/**
* 生成AsciiDocs格式文档
* @throws Exception
*/
@Test
public void generateAsciiDocs() throws Exception {
// 输出Ascii格式
Swagger2MarkupConfig config = new Swagger2MarkupConfigBuilder()
.withMarkupLanguage(MarkupLanguage.ASCIIDOC)
.withOutputLanguage(Language.ZH)
.withPathsGroupedBy(GroupBy.TAGS)
.withGeneratedExamples()
.withoutInlineSchema()
.build();
// swagger-ui.html页面中能找到此链接
Swagger2MarkupConverter.from(new URL(url))
.withConfig(config)
.build()
.toFolder(Paths.get("./docs/asciidoc"));
}


/**
* 生成Markdown文档
* @throws Exception
*/
@Test
public void generateMarkdownDocs() throws Exception {
// 输出Markdown格式
Swagger2MarkupConfig config = new Swagger2MarkupConfigBuilder()
.withMarkupLanguage(MarkupLanguage.MARKDOWN)
.withOutputLanguage(Language.ZH)
.withPathsGroupedBy(GroupBy.TAGS)
.withGeneratedExamples()
.withoutInlineSchema()
.build();

Swagger2MarkupConverter.from(new URL(url))
.withConfig(config)
.build()
.toFolder(Paths.get("./docs/mk"));
}


//输出汇总到一个文件
@Test
public void generateAsciiDocsToFile() throws Exception {
// 输出Ascii到单文件
Swagger2MarkupConfig config = new Swagger2MarkupConfigBuilder()
.withMarkupLanguage(MarkupLanguage.ASCIIDOC)
.withOutputLanguage(Language.ZH)
.withPathsGroupedBy(GroupBy.TAGS)
.withGeneratedExamples()
.withoutInlineSchema()
.build();

Swagger2MarkupConverter.from(new URL(url))
.withConfig(config)
.build()
.toFile(Paths.get("./docs/asciidoc-all"));
}

@Test
public void generateMarkdownDocsToFile() throws Exception {
// 输出Markdown到单文件
Swagger2MarkupConfig config = new Swagger2MarkupConfigBuilder()
.withMarkupLanguage(MarkupLanguage.MARKDOWN)
.withOutputLanguage(Language.ZH)
.withPathsGroupedBy(GroupBy.TAGS)
.withGeneratedExamples()
.withoutInlineSchema()
.build();

Swagger2MarkupConverter.from(new URL(url))
.withConfig(config)
.build()
.toFile(Paths.get("./docs/mk-all"));
}


}

0 comments on commit 3352b78

Please sign in to comment.