Code Monkey home page Code Monkey logo

learn-docker's Introduction

learn-docker

  • 如果Spring MVC代理了根路径()的url,在spring-mvc.xml增加配置项。
<!-- Enables swgger ui-->
<mvc:default-servlet-handler/>
<mvc:resources location="classpath:/META-INF/resources/" mapping="swagger-ui.html"/>
<mvc:resources location="classpath:/META-INF/resources/webjars/" mapping="/webjars/**"/>

启动Tomat,通过localhost:8080/swagger-ui.html访问Swagger-UI。

  • Maven插件生成API描述文档(json格式)
<plugin>
 <groupId>com.github.kongchen</groupId>
 <artifactId>swagger-maven-plugin</artifactId>
 <version>3.1.5</version>
 <configuration>
     <apiSources>
         <apiSource>
             <springmvc>true</springmvc>
             <locations>com.example.demo13</locations><!-- Controller所在的位置 -->
             <host>orderdish-ecom-web.51ping.com</host>
             <basePath>/s</basePath>
             <schemes>http,https</schemes>
             <info>
                 <title>${artifactId}</title>
                 <version>v1</version>
                 <description>Click Link Below for Help</description>
                 <termsOfService>http://www.github.com/kongchen/swagger-maven-plugin</termsOfService>
             </info>
             <!--html文档输出功能的模板文件 -->
             <!--<templatePath>${basedir}/src/test/resources/swagger_template/strapdown.html.hbs</templatePath>-->
             <!--html文档输出的位置 -->
             <!--<outputPath>${project.build.directory}/swagger-ui/swagger_document.html</outputPath>-->
             <swaggerDirectory>${project.build.directory}/swagger-ui</swaggerDirectory><!--定义API描述文档的输出目录 -->
             <outputFormats>yaml,json</outputFormats><!--支持yaml和json格式 -->
         </apiSource>
     </apiSources>
 </configuration>
 <executions>
     <execution>
         <phase>compile</phase>
         <goals>
             <goal>generate</goal>
         </goals>
     </execution>
 </executions>
</plugin>

执行mvn complie,在设置的target目录下会生成API描述文档。

  • Maven插件生成静态文档(markdown格式)
<plugin>
 <groupId>io.github.swagger2markup</groupId>
 <artifactId>swagger2markup-maven-plugin</artifactId>
 <version>1.3.3</version>
 <configuration>
     <!--The URL or file path to the Swagger specification-->
     <swaggerInput>${project.build.directory}/swagger-ui/swagger.yaml</swaggerInput>
     <outputDir>${project.build.directory}/swagger-ui</outputDir>
     <outputFile>${project.build.directory}/swagger-ui/swagger.md</outputFile>
     <config>
         <!--设置输出文件的语言:ASCIIDOC, MARKDOWN, CONFLUENCE_MARKUP-->
         <swagger2markup.markupLanguage>MARKDOWN</swagger2markup.markupLanguage>
         <!--设置目录的展现方式-->
         <swagger2markup.pathsGroupedBy>TAGS</swagger2markup.pathsGroupedBy>
     </config>
 </configuration>
 <executions>
     <execution>
         <phase>compile</phase>
         <goals>
             <goal>convertSwagger2markup</goal>
         </goals>
     </execution>
 </executions>
</plugin>

如果mvn complie时出现异常,可能是因为之前生成的yaml不符合Swagger规范。把yaml复制到Swagger Editor中,根据提示的语法错误修正,再手动执行mvn swagger2markup:convertSwagger2markup即可生成markdown文档。

learn-docker's People

Contributors

liaonanfeng avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.