swagger导出接口文档(不需要模板)

新建一个类

package com.bzl.permission.swagger;

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 java.net.MalformedURLException;
import java.net.URL;
import java.nio.file.Paths;

public class swagger {

    public static void main(String[] args) throws MalformedURLException {
        Swagger2MarkupConfig config = new Swagger2MarkupConfigBuilder()
                .withMarkupLanguage(MarkupLanguage.MARKDOWN)
                .withOutputLanguage(Language.ZH)
                .withPathsGroupedBy(GroupBy.TAGS)
                .withGeneratedExamples()
                .withoutInlineSchema()
                .build();
//修改IP端口
        Swagger2MarkupConverter.from(new URL("http://127.0.0.1:[port]/v2/api-docs"))
                .withConfig(config)
                .build()
                .toFile(Paths.get("./docs/markdown/generated/all"));
    }

}

添加导出依赖


    io.github.swagger2markup
    swagger2markup
    1.3.3


    commons-beanutils
    commons-beanutils
    1.9.3


    org.slf4j
    slf4j-simple
    1.7.25
    compile

你可能感兴趣的:(devops,文档,java)