2017-07-10 16 views
-1

私はspringboot + mybatis + swaggerプロジェクトを作成します。私はプロジェクトAPIをエクスポートするためにswaggerを使用したいと思います。自分のコードにswagger注釈を書きました。swaggerを使用してJavaプロジェクトのAPIをエクスポートするにはどうすればよいですか?

どうすればapiをhtmlやdoc、chmとしてエクスポートできますか?で闊歩を持って

enter image description here

+0

こんにちは、いくつかのリソースがここにありますhttps://stackoverflow.com/questions/25800493/converting-swagger-specification-json-to-html-documentation –

答えて

0

、私たちは、あなたがすべき、この時点で、アプリケーション

@Configuration 
@EnableSwagger2 
public class SwaggerConfig { 
    @Bean 
    public Docket productApi() { 
     return new Docket(DocumentationType.SWAGGER_2) 
       .select()     .apis(RequestHandlerSelectors.basePackage("com.springframework.example")) 
       .paths("/") 
       .build(); 

    } 
} 

で私たちのMaven POM

<dependency> 
    <groupId>io.springfox</groupId> 
    <artifactId>springfox-swagger2</artifactId> 
    <version>2.6.1</version> 
    <scope>compile</scope> 
</dependency> 

<dependency> 
    <groupId>io.springfox</groupId> 
    <artifactId>springfox-swagger-ui</artifactId> 
    <version>2.6.1</version> 
    <scope>compile</scope> 
</dependency> 

設定SWAGGER 2で、次の依存関係の宣言を必要としますアプリを起動してブラウザを指定して設定をテストできるようにするhttp://localhost:8080/v2/api-docs

ブラウザでhttp://localhost:8080/swagger-ui.htmlを指定すると、Swagger UIでレンダリングされたドキュメントが表示されます。

Reference Document

+0

私はhttp:// localhostを使用でき:8080/v2/api-docsを使用してswagger.jsonを作成しますが、html docまたはpdf形式を作成します – lakelise

+0

@lakelise http:// localhost:8080/swagger-ui.htmlはHTML文書 –

+0

ありがとう。 – lakelise

関連する問題