springfox-swagger-ui

swagger-ui for xncoding

License

License

Categories

Categories

Swagger Program Interface REST Frameworks
GroupId

GroupId

com.xncoding
ArtifactId

ArtifactId

springfox-swagger-ui
Last Version

Last Version

2.7.0
Release Date

Release Date

Type

Type

jar
Description

Description

springfox-swagger-ui
swagger-ui for xncoding
Project URL

Project URL

https://www.xncoding.com/

Download springfox-swagger-ui

How to add to project

<!-- https://jarcasting.com/artifacts/com.xncoding/springfox-swagger-ui/ -->
<dependency>
    <groupId>com.xncoding</groupId>
    <artifactId>springfox-swagger-ui</artifactId>
    <version>2.7.0</version>
</dependency>
// https://jarcasting.com/artifacts/com.xncoding/springfox-swagger-ui/
implementation 'com.xncoding:springfox-swagger-ui:2.7.0'
// https://jarcasting.com/artifacts/com.xncoding/springfox-swagger-ui/
implementation ("com.xncoding:springfox-swagger-ui:2.7.0")
'com.xncoding:springfox-swagger-ui:jar:2.7.0'
<dependency org="com.xncoding" name="springfox-swagger-ui" rev="2.7.0">
  <artifact name="springfox-swagger-ui" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.xncoding', module='springfox-swagger-ui', version='2.7.0')
)
libraryDependencies += "com.xncoding" % "springfox-swagger-ui" % "2.7.0"
[com.xncoding/springfox-swagger-ui "2.7.0"]

Dependencies

compile (1)

Group / Artifact Type Version
io.springfox : springfox-spring-web jar 2.7.0

Project Modules

There are no modules declared in this project.

swagger-ui

自定义风格的RESTful-API文档

使用方法

这里以SpringBoot为例子。

在maven中添加如下依赖:

    <dependency>
        <groupId>io.springfox</groupId>
        <artifactId>springfox-swagger2</artifactId>
        <version>2.7.0</version>
    </dependency>
    <dependency>
        <groupId>com.xncoding</groupId>
        <artifactId>springfox-swagger-ui</artifactId>
        <version>2.7.0</version>
    </dependency>

然后添加一个Swagger2配置:

@Configuration
@EnableSwagger2
public class Swagger2Config {

    @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                // 指定controller存放的目录路径
                .apis(RequestHandlerSelectors.basePackage("com.enzhico.jwt.api"))
//                .paths(PathSelectors.ant("/api/v1/*"))
                .paths(PathSelectors.any())
                .build();
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                // 文档标题
                .title("系统API服务")
                // 文档描述
                .description("系统API接口文档")
                // .termsOfServiceUrl("https://github.com/yidao620c")
                .version("v1")
                // .license("MIT 协议")
                // .licenseUrl("http://www.opensource.org/licenses/MIT")
                // .contact(new Contact("熊能","https://github.com/yidao620c","[email protected]"))
                .build();
    }
}

在Controller中添加相应的Swagger2注解即可,更详细教程可以参考我的博客: SpringBoot系列 - 集成Swagger2

访问地址:http://localhost:port/swagger-ui.html

支持如下8种主题样式

  • 默认
  • Feeling Blue
  • Material
  • Monokai
  • Flattop
  • Muted
  • Newspaper
  • Outline

主题样式风格如下

Versions

Version
2.7.0