Swagger2

//maven依赖
     <!-- https://mvnrepository.com/artifact/io.springfox/springfox-swagger2 -->
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger2</artifactId>
            <version>2.8.0</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/io.springfox/springfox-swagger-ui -->
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger-ui</artifactId>
            <version>2.8.0</version>
        </dependency>
        <!--swagger-bootstrap-ui-->
        <dependency>
            <groupId>com.github.xiaoymin</groupId>
            <artifactId>swagger-bootstrap-ui</artifactId>
            <version>1.9.0</version>
        </dependency>


//配置

@Configuration
@EnableSwagger2
@EnableSwaggerBootstrapUI
public class SwaggerConfig {
    @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .groupName("商户平台API")
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.baidu.bsm.controller"))//更换com.baidu.bsm.controller为自己的项目controller路径
                .paths(PathSelectors.any())
                .build();
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("商户平台API")   //标题
                .description("商户管理平台API文档(内部文档,请勿外传)") //描述
                .termsOfServiceUrl("https://www.baidu.com")
                .contact(new Contact("XXX有限公司", "https://www.baidu.com", "74532604@qq.cn"))
                .version("1.0") //版本
                .build();
    }
}

//使用
@RestController
@RequestMapping(value = "/api/")
@Api(tags = "违纪管理API", description = "违纪管理API")
public class DisciplineController {

    /**
     * 新建违纪
     *
     * @param violation 违纪实体
     */
    @PostMapping(value = "v1/discipline_add")
    @ApiOperation(value = "新建严重违纪", notes = "violation:违纪实体")
    public Response disciplineAdd(@RequestBody Violation violation) {
        return disciplineService.disciplineAdd(violation);
    }

@Configuration
@ComponentScan
@SpringBootApplication
public class ActivitiApplication {

	public static void main(String[] args) {
		SpringApplication.run(ActivitiApplication.class, args);
	}

}


}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值