Spring Bootでswager-boot strap-uiを使う方法
swagger-boot strap-uiはswaggerインターフェースapiに基づいて実現されたUIセットです。swagger原生uiは上下構造ですので、インターフェースを閲覧する時はよく分かりません。だから、swagger-boot strap-uiは左右メニュースタイルに基づいています。私達が開発したバックシステムの左右で構成したスタイルと似ています。インタフェースを閲覧するのが便利です。
GitHub:https://github.com/xiaoymin/Swagger-Bootstrap-UI
画面のプレビュー:
スワップを導入する
pom.xmlファイルにswaggerとuiのjarパッケージ依存を導入します。
swaggerの有効配置ファイルを配置し、キーコメント@EnbleSwagger 2
以下の設定はインターフェースパケットの構成をサポートします。もしパケット構成がないなら、Docetを作成すればいいです。
ctlコード層:
ブラウザで入力:http://米ドル{host}:$
締め括りをつける
以上述べたように、Spring Bootでswagger-boot strap-uiを使う方法を紹介しました。皆さんに助けてほしいです。もし何か質問があれば、メッセージをください。編集者はすぐに返事します。ここでも私たちのサイトを応援してくれてありがとうございます。
GitHub:https://github.com/xiaoymin/Swagger-Bootstrap-UI
画面のプレビュー:
スワップを導入する
pom.xmlファイルにswaggerとuiのjarパッケージ依存を導入します。
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.7.0</version>
</dependency>
<!-- ui -->
<dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>swagger-bootstrap-ui</artifactId>
<version>1.7</version>
</dependency>
configrationの設定swaggerの有効配置ファイルを配置し、キーコメント@EnbleSwagger 2
以下の設定はインターフェースパケットの構成をサポートします。もしパケット構成がないなら、Docetを作成すればいいです。
@Configuration
@EnableSwagger2
public class SwaggerConfiguration {
@Bean
public Docket createRestApi() {
return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo())
.groupName(" ")
.select()
.apis(RequestHandlerSelectors.basePackage("com.lishiots.dc.baseinfo.ctl"))
.paths(PathSelectors.any())
.build();
}
@Bean
public Docket createMonitorRestApi() {
return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo())
.groupName(" ")
.select()
.apis(RequestHandlerSelectors.basePackage("com.lishiots.dc.monitor.ctl"))
.paths(PathSelectors.any())
.build();
}
@Bean
public Docket createActivitiRestApi() {
return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo())
.groupName(" ")
.select()
.apis(RequestHandlerSelectors.basePackage("com.lishiots.dc.activiti.ctl"))
.paths(PathSelectors.any())
.build();
}
@Bean
public Docket createBaseRestApi() {
return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo())
.groupName("kernel ")
.select()
.apis(RequestHandlerSelectors.basePackage("com.lishiots.dc.kernel.ctl"))
.paths(PathSelectors.any())
.build();
}
@Bean
public Docket createComplaintRestApi() {
return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo())
.groupName(" ")
.select()
.apis(RequestHandlerSelectors.basePackage("com.lishiots.dc.complaint.ctl"))
.paths(PathSelectors.any())
.build();
}
private ApiInfo apiInfo() {
return new ApiInfoBuilder()
.title("swagger RESTful APIs")
.description("swagger RESTful APIs")
.termsOfServiceUrl("http://www.test.com/")
.contact("[email protected]")
.version("1.0")
.build();
}
}
Controller層はswaggerで注解します。ctlコード層:
@Api(tags = "banner ")
@RestController
@RequestMapping("/api/bannerInfo")
public class BannerCtl {
@Autowired
private BannerInfoService service;
@PostMapping("/query")
@ApiOperation(value = " banner",notes = " banner")
public Pagination<BannerInfo> bannerInfoQuery(){
Pagination<BannerInfo> pagination = service.bannerInfoQuery();
return pagination;
}
}
インターフェース・アクセスブラウザで入力:http://米ドル{host}:$
締め括りをつける
以上述べたように、Spring Bootでswagger-boot strap-uiを使う方法を紹介しました。皆さんに助けてほしいです。もし何か質問があれば、メッセージをください。編集者はすぐに返事します。ここでも私たちのサイトを応援してくれてありがとうございます。