120 changed files with 113 additions and 2482 deletions
@ -1,68 +0,0 @@ |
|||||
/** |
|
||||
* Copyright (c) 2018 人人开源 All rights reserved. |
|
||||
* |
|
||||
* https://www.renren.io
|
|
||||
* |
|
||||
* 版权所有,侵权必究! |
|
||||
*/ |
|
||||
|
|
||||
package com.epmet.config; |
|
||||
|
|
||||
import com.epmet.commons.tools.constant.Constant; |
|
||||
import io.swagger.annotations.ApiOperation; |
|
||||
import org.springframework.context.annotation.Bean; |
|
||||
import org.springframework.context.annotation.Configuration; |
|
||||
import springfox.documentation.builders.ApiInfoBuilder; |
|
||||
import springfox.documentation.builders.PathSelectors; |
|
||||
import springfox.documentation.builders.RequestHandlerSelectors; |
|
||||
import springfox.documentation.service.ApiInfo; |
|
||||
import springfox.documentation.service.ApiKey; |
|
||||
import springfox.documentation.spi.DocumentationType; |
|
||||
import springfox.documentation.spring.web.plugins.Docket; |
|
||||
import springfox.documentation.swagger2.annotations.EnableSwagger2; |
|
||||
|
|
||||
import java.util.List; |
|
||||
|
|
||||
import static com.google.common.collect.Lists.newArrayList; |
|
||||
|
|
||||
/** |
|
||||
* Swagger配置 |
|
||||
* |
|
||||
* @author Mark sunlightcs@gmail.com |
|
||||
* @since 1.0.0 |
|
||||
*/ |
|
||||
@Configuration |
|
||||
@EnableSwagger2 |
|
||||
public class SwaggerConfig { |
|
||||
|
|
||||
@Bean |
|
||||
public Docket createRestApi() { |
|
||||
return new Docket(DocumentationType.SWAGGER_2) |
|
||||
.apiInfo(apiInfo()) |
|
||||
.select() |
|
||||
//加了ApiOperation注解的类,才生成接口文档
|
|
||||
.apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class)) |
|
||||
//包下的类,才生成接口文档
|
|
||||
//.apis(RequestHandlerSelectors.basePackage("io.renren.controller"))
|
|
||||
.paths(PathSelectors.any()) |
|
||||
.build() |
|
||||
.directModelSubstitute(java.util.Date.class, String.class) |
|
||||
.securitySchemes(security()); |
|
||||
} |
|
||||
|
|
||||
private ApiInfo apiInfo() { |
|
||||
return new ApiInfoBuilder() |
|
||||
.title("人人开源") |
|
||||
.description("系统模块开发文档") |
|
||||
.termsOfServiceUrl("https://www.renren.io/community") |
|
||||
.version("1.4.0") |
|
||||
.build(); |
|
||||
} |
|
||||
|
|
||||
private List<ApiKey> security() { |
|
||||
return newArrayList( |
|
||||
new ApiKey(Constant.TOKEN_HEADER, Constant.TOKEN_HEADER, "header") |
|
||||
); |
|
||||
} |
|
||||
|
|
||||
} |
|
||||
@ -1,69 +0,0 @@ |
|||||
/** |
|
||||
* Copyright (c) 2018 人人开源 All rights reserved. |
|
||||
* |
|
||||
* https://www.renren.io
|
|
||||
* |
|
||||
* 版权所有,侵权必究! |
|
||||
*/ |
|
||||
|
|
||||
package com.epmet.config; |
|
||||
|
|
||||
import com.epmet.commons.tools.constant.Constant; |
|
||||
import io.swagger.annotations.ApiOperation; |
|
||||
import org.springframework.context.annotation.Bean; |
|
||||
import org.springframework.context.annotation.Configuration; |
|
||||
import springfox.documentation.builders.ApiInfoBuilder; |
|
||||
import springfox.documentation.builders.PathSelectors; |
|
||||
import springfox.documentation.builders.RequestHandlerSelectors; |
|
||||
import springfox.documentation.service.ApiInfo; |
|
||||
import springfox.documentation.service.ApiKey; |
|
||||
import springfox.documentation.spi.DocumentationType; |
|
||||
import springfox.documentation.spring.web.plugins.Docket; |
|
||||
import springfox.documentation.swagger2.annotations.EnableSwagger2; |
|
||||
|
|
||||
import java.util.List; |
|
||||
|
|
||||
import static com.google.common.collect.Lists.newArrayList; |
|
||||
|
|
||||
/** |
|
||||
* Swagger配置 |
|
||||
* |
|
||||
* @author Mark sunlightcs@gmail.com |
|
||||
* @since 1.0.0 |
|
||||
*/ |
|
||||
@Configuration |
|
||||
@EnableSwagger2 |
|
||||
public class SwaggerConfig { |
|
||||
|
|
||||
@Bean |
|
||||
public Docket createRestApi() { |
|
||||
return new Docket(DocumentationType.SWAGGER_2) |
|
||||
.apiInfo(apiInfo()) |
|
||||
.select() |
|
||||
//加了ApiOperation注解的类,才生成接口文档
|
|
||||
.apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class)) |
|
||||
//包下的类,才生成接口文档
|
|
||||
//.apis(RequestHandlerSelectors.basePackage("io.renren.controller"))
|
|
||||
.paths(PathSelectors.any()) |
|
||||
.build() |
|
||||
.directModelSubstitute(java.util.Date.class, String.class) |
|
||||
.securitySchemes(security()); |
|
||||
|
|
||||
} |
|
||||
|
|
||||
private ApiInfo apiInfo() { |
|
||||
return new ApiInfoBuilder() |
|
||||
.title("人人开源") |
|
||||
.description("认证模块开发文档") |
|
||||
.termsOfServiceUrl("https://www.renren.io/community") |
|
||||
.version("1.1.0") |
|
||||
.build(); |
|
||||
} |
|
||||
|
|
||||
private List<ApiKey> security() { |
|
||||
return newArrayList( |
|
||||
new ApiKey(Constant.TOKEN_HEADER, Constant.TOKEN_HEADER, "header") |
|
||||
); |
|
||||
} |
|
||||
|
|
||||
} |
|
||||
@ -1,58 +0,0 @@ |
|||||
/** |
|
||||
* Copyright (c) 2018 人人开源 All rights reserved. |
|
||||
* |
|
||||
* https://www.renren.io
|
|
||||
* |
|
||||
* 版权所有,侵权必究! |
|
||||
*/ |
|
||||
|
|
||||
package com.epmet.swagger; |
|
||||
|
|
||||
import org.springframework.beans.factory.annotation.Autowired; |
|
||||
import org.springframework.http.HttpStatus; |
|
||||
import org.springframework.http.ResponseEntity; |
|
||||
import org.springframework.web.bind.annotation.GetMapping; |
|
||||
import org.springframework.web.bind.annotation.RequestMapping; |
|
||||
import org.springframework.web.bind.annotation.RestController; |
|
||||
import reactor.core.publisher.Mono; |
|
||||
import springfox.documentation.swagger.web.*; |
|
||||
|
|
||||
import java.util.Optional; |
|
||||
|
|
||||
/** |
|
||||
* Swagger |
|
||||
* |
|
||||
* @author Mark sunlightcs@gmail.com |
|
||||
* @since 1.0.0 |
|
||||
*/ |
|
||||
@RestController |
|
||||
@RequestMapping("/swagger-resources") |
|
||||
public class SwaggerHandler { |
|
||||
@Autowired(required = false) |
|
||||
private SecurityConfiguration securityConfiguration; |
|
||||
@Autowired(required = false) |
|
||||
private UiConfiguration uiConfiguration; |
|
||||
private final SwaggerResourcesProvider swaggerResources; |
|
||||
|
|
||||
@Autowired |
|
||||
public SwaggerHandler(SwaggerResourcesProvider swaggerResources) { |
|
||||
this.swaggerResources = swaggerResources; |
|
||||
} |
|
||||
|
|
||||
@GetMapping("/configuration/security") |
|
||||
public Mono<ResponseEntity<SecurityConfiguration>> securityConfiguration() { |
|
||||
return Mono.just(new ResponseEntity<>( |
|
||||
Optional.ofNullable(securityConfiguration).orElse(SecurityConfigurationBuilder.builder().build()), HttpStatus.OK)); |
|
||||
} |
|
||||
|
|
||||
@GetMapping("/configuration/ui") |
|
||||
public Mono<ResponseEntity<UiConfiguration>> uiConfiguration() { |
|
||||
return Mono.just(new ResponseEntity<>( |
|
||||
Optional.ofNullable(uiConfiguration).orElse(UiConfigurationBuilder.builder().build()), HttpStatus.OK)); |
|
||||
} |
|
||||
|
|
||||
@GetMapping |
|
||||
public Mono<ResponseEntity> swaggerResources() { |
|
||||
return Mono.just((new ResponseEntity<>(swaggerResources.get(), HttpStatus.OK))); |
|
||||
} |
|
||||
} |
|
||||
@ -1,61 +0,0 @@ |
|||||
/** |
|
||||
* Copyright (c) 2018 人人开源 All rights reserved. |
|
||||
* |
|
||||
* https://www.renren.io
|
|
||||
* |
|
||||
* 版权所有,侵权必究! |
|
||||
*/ |
|
||||
|
|
||||
package com.epmet.swagger; |
|
||||
|
|
||||
import org.springframework.cloud.gateway.config.GatewayProperties; |
|
||||
import org.springframework.cloud.gateway.route.RouteLocator; |
|
||||
import org.springframework.cloud.gateway.support.NameUtils; |
|
||||
import org.springframework.context.annotation.Primary; |
|
||||
import org.springframework.stereotype.Component; |
|
||||
import springfox.documentation.swagger.web.SwaggerResource; |
|
||||
import springfox.documentation.swagger.web.SwaggerResourcesProvider; |
|
||||
|
|
||||
import java.util.ArrayList; |
|
||||
import java.util.List; |
|
||||
|
|
||||
/** |
|
||||
* Swagger |
|
||||
* |
|
||||
* @author Mark sunlightcs@gmail.com |
|
||||
* @since 1.0.0 |
|
||||
*/ |
|
||||
@Component |
|
||||
@Primary |
|
||||
public class SwaggerProvider implements SwaggerResourcesProvider { |
|
||||
public static final String API_URI = "/v2/api-docs"; |
|
||||
private final RouteLocator routeLocator; |
|
||||
private final GatewayProperties gatewayProperties; |
|
||||
|
|
||||
public SwaggerProvider(RouteLocator routeLocator, GatewayProperties gatewayProperties) { |
|
||||
this.routeLocator = routeLocator; |
|
||||
this.gatewayProperties = gatewayProperties; |
|
||||
} |
|
||||
|
|
||||
@Override |
|
||||
public List<SwaggerResource> get() { |
|
||||
List<SwaggerResource> resources = new ArrayList<>(); |
|
||||
List<String> routes = new ArrayList<>(); |
|
||||
routeLocator.getRoutes().subscribe(route -> routes.add(route.getId())); |
|
||||
gatewayProperties.getRoutes().stream().filter(routeDefinition -> routes.contains(routeDefinition.getId())) |
|
||||
.forEach(routeDefinition -> routeDefinition.getPredicates().stream() |
|
||||
.filter(predicateDefinition -> ("Path").equalsIgnoreCase(predicateDefinition.getName())) |
|
||||
.forEach(predicateDefinition -> resources.add(swaggerResource(routeDefinition.getId(), |
|
||||
predicateDefinition.getArgs().get(NameUtils.GENERATED_NAME_PREFIX + "0").replace("/**", API_URI))))); |
|
||||
|
|
||||
return resources; |
|
||||
} |
|
||||
|
|
||||
private SwaggerResource swaggerResource(String name, String location) { |
|
||||
SwaggerResource swaggerResource = new SwaggerResource(); |
|
||||
swaggerResource.setName(name); |
|
||||
swaggerResource.setLocation(location); |
|
||||
swaggerResource.setSwaggerVersion("2.0"); |
|
||||
return swaggerResource; |
|
||||
} |
|
||||
} |
|
||||
@ -1,68 +0,0 @@ |
|||||
/** |
|
||||
* Copyright (c) 2018 人人开源 All rights reserved. |
|
||||
* |
|
||||
* https://www.renren.io
|
|
||||
* |
|
||||
* 版权所有,侵权必究! |
|
||||
*/ |
|
||||
|
|
||||
package com.epmet.config; |
|
||||
|
|
||||
import com.epmet.commons.tools.constant.Constant; |
|
||||
import io.swagger.annotations.ApiOperation; |
|
||||
import org.springframework.context.annotation.Bean; |
|
||||
import org.springframework.context.annotation.Configuration; |
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; |
|
||||
import springfox.documentation.builders.ApiInfoBuilder; |
|
||||
import springfox.documentation.builders.PathSelectors; |
|
||||
import springfox.documentation.builders.RequestHandlerSelectors; |
|
||||
import springfox.documentation.service.ApiInfo; |
|
||||
import springfox.documentation.service.ApiKey; |
|
||||
import springfox.documentation.spi.DocumentationType; |
|
||||
import springfox.documentation.spring.web.plugins.Docket; |
|
||||
import springfox.documentation.swagger2.annotations.EnableSwagger2; |
|
||||
|
|
||||
import java.util.List; |
|
||||
|
|
||||
import static com.google.common.collect.Lists.newArrayList; |
|
||||
|
|
||||
/** |
|
||||
* Swagger配置 |
|
||||
* |
|
||||
* @author Mark sunlightcs@gmail.com |
|
||||
* @since 1.0.0 |
|
||||
*/ |
|
||||
@Configuration |
|
||||
@EnableSwagger2 |
|
||||
public class SwaggerConfig implements WebMvcConfigurer { |
|
||||
|
|
||||
@Bean |
|
||||
public Docket createRestApi() { |
|
||||
return new Docket(DocumentationType.SWAGGER_2) |
|
||||
.apiInfo(apiInfo()) |
|
||||
.select() |
|
||||
//加了ApiOperation注解的类,才生成接口文档
|
|
||||
.apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class)) |
|
||||
.paths(PathSelectors.any()) |
|
||||
.build() |
|
||||
.directModelSubstitute(java.util.Date.class, String.class) |
|
||||
.securitySchemes(security()); |
|
||||
|
|
||||
} |
|
||||
|
|
||||
private ApiInfo apiInfo() { |
|
||||
return new ApiInfoBuilder() |
|
||||
.title("人人开源") |
|
||||
.description("Activiti接口文档") |
|
||||
.termsOfServiceUrl("https://www.renren.io") |
|
||||
.version("1.1.0") |
|
||||
.build(); |
|
||||
} |
|
||||
|
|
||||
private List<ApiKey> security() { |
|
||||
return newArrayList( |
|
||||
new ApiKey(Constant.TOKEN_HEADER, Constant.TOKEN_HEADER, "header") |
|
||||
); |
|
||||
} |
|
||||
|
|
||||
} |
|
||||
@ -1,68 +0,0 @@ |
|||||
/** |
|
||||
* Copyright (c) 2018 人人开源 All rights reserved. |
|
||||
* |
|
||||
* https://www.renren.io
|
|
||||
* |
|
||||
* 版权所有,侵权必究! |
|
||||
*/ |
|
||||
|
|
||||
package com.epmet.config; |
|
||||
|
|
||||
import com.epmet.commons.tools.constant.Constant; |
|
||||
import io.swagger.annotations.ApiOperation; |
|
||||
import org.springframework.context.annotation.Bean; |
|
||||
import org.springframework.context.annotation.Configuration; |
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; |
|
||||
import springfox.documentation.builders.ApiInfoBuilder; |
|
||||
import springfox.documentation.builders.PathSelectors; |
|
||||
import springfox.documentation.builders.RequestHandlerSelectors; |
|
||||
import springfox.documentation.service.ApiInfo; |
|
||||
import springfox.documentation.service.ApiKey; |
|
||||
import springfox.documentation.spi.DocumentationType; |
|
||||
import springfox.documentation.spring.web.plugins.Docket; |
|
||||
import springfox.documentation.swagger2.annotations.EnableSwagger2; |
|
||||
|
|
||||
import java.util.List; |
|
||||
|
|
||||
import static com.google.common.collect.Lists.newArrayList; |
|
||||
|
|
||||
/** |
|
||||
* Swagger配置 |
|
||||
* |
|
||||
* @author Mark sunlightcs@gmail.com |
|
||||
* @since 1.0.0 |
|
||||
*/ |
|
||||
@Configuration |
|
||||
@EnableSwagger2 |
|
||||
public class SwaggerConfig implements WebMvcConfigurer { |
|
||||
|
|
||||
@Bean |
|
||||
public Docket createRestApi() { |
|
||||
return new Docket(DocumentationType.SWAGGER_2) |
|
||||
.apiInfo(apiInfo()) |
|
||||
.select() |
|
||||
//加了ApiOperation注解的类,才生成接口文档
|
|
||||
.apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class)) |
|
||||
.paths(PathSelectors.any()) |
|
||||
.build() |
|
||||
.directModelSubstitute(java.util.Date.class, String.class) |
|
||||
.securitySchemes(security()); |
|
||||
|
|
||||
} |
|
||||
|
|
||||
private ApiInfo apiInfo() { |
|
||||
return new ApiInfoBuilder() |
|
||||
.title("人人开源") |
|
||||
.description("模块接口文档") |
|
||||
.termsOfServiceUrl("https://www.renren.io") |
|
||||
.version("1.1.0") |
|
||||
.build(); |
|
||||
} |
|
||||
|
|
||||
private List<ApiKey> security() { |
|
||||
return newArrayList( |
|
||||
new ApiKey(Constant.TOKEN_HEADER, Constant.TOKEN_HEADER, "header") |
|
||||
); |
|
||||
} |
|
||||
|
|
||||
} |
|
||||
@ -1,68 +0,0 @@ |
|||||
/** |
|
||||
* Copyright (c) 2018 人人开源 All rights reserved. |
|
||||
* |
|
||||
* https://www.renren.io
|
|
||||
* |
|
||||
* 版权所有,侵权必究! |
|
||||
*/ |
|
||||
|
|
||||
package com.epmet.config; |
|
||||
|
|
||||
import com.epmet.commons.tools.constant.Constant; |
|
||||
import io.swagger.annotations.ApiOperation; |
|
||||
import org.springframework.context.annotation.Bean; |
|
||||
import org.springframework.context.annotation.Configuration; |
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; |
|
||||
import springfox.documentation.builders.ApiInfoBuilder; |
|
||||
import springfox.documentation.builders.PathSelectors; |
|
||||
import springfox.documentation.builders.RequestHandlerSelectors; |
|
||||
import springfox.documentation.service.ApiInfo; |
|
||||
import springfox.documentation.service.ApiKey; |
|
||||
import springfox.documentation.spi.DocumentationType; |
|
||||
import springfox.documentation.spring.web.plugins.Docket; |
|
||||
import springfox.documentation.swagger2.annotations.EnableSwagger2; |
|
||||
|
|
||||
import java.util.List; |
|
||||
|
|
||||
import static com.google.common.collect.Lists.newArrayList; |
|
||||
|
|
||||
/** |
|
||||
* Swagger配置 |
|
||||
* |
|
||||
* @author Mark sunlightcs@gmail.com |
|
||||
* @since 1.0.0 |
|
||||
*/ |
|
||||
@Configuration |
|
||||
@EnableSwagger2 |
|
||||
public class SwaggerConfig implements WebMvcConfigurer { |
|
||||
|
|
||||
@Bean |
|
||||
public Docket createRestApi() { |
|
||||
return new Docket(DocumentationType.SWAGGER_2) |
|
||||
.apiInfo(apiInfo()) |
|
||||
.select() |
|
||||
//加了ApiOperation注解的类,才生成接口文档
|
|
||||
.apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class)) |
|
||||
.paths(PathSelectors.any()) |
|
||||
.build() |
|
||||
.directModelSubstitute(java.util.Date.class, String.class) |
|
||||
.securitySchemes(security()); |
|
||||
|
|
||||
} |
|
||||
|
|
||||
private ApiInfo apiInfo() { |
|
||||
return new ApiInfoBuilder() |
|
||||
.title("人人开源") |
|
||||
.description("JOB接口文档") |
|
||||
.termsOfServiceUrl("https://www.renren.io") |
|
||||
.version("1.1.0") |
|
||||
.build(); |
|
||||
} |
|
||||
|
|
||||
private List<ApiKey> security() { |
|
||||
return newArrayList( |
|
||||
new ApiKey(Constant.TOKEN_HEADER, Constant.TOKEN_HEADER, "header") |
|
||||
); |
|
||||
} |
|
||||
|
|
||||
} |
|
||||
@ -1,68 +0,0 @@ |
|||||
/** |
|
||||
* Copyright (c) 2018 人人开源 All rights reserved. |
|
||||
* |
|
||||
* https://www.renren.io
|
|
||||
* |
|
||||
* 版权所有,侵权必究! |
|
||||
*/ |
|
||||
|
|
||||
package com.epmet.config; |
|
||||
|
|
||||
import com.epmet.commons.tools.constant.Constant; |
|
||||
import io.swagger.annotations.ApiOperation; |
|
||||
import org.springframework.context.annotation.Bean; |
|
||||
import org.springframework.context.annotation.Configuration; |
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; |
|
||||
import springfox.documentation.builders.ApiInfoBuilder; |
|
||||
import springfox.documentation.builders.PathSelectors; |
|
||||
import springfox.documentation.builders.RequestHandlerSelectors; |
|
||||
import springfox.documentation.service.ApiInfo; |
|
||||
import springfox.documentation.service.ApiKey; |
|
||||
import springfox.documentation.spi.DocumentationType; |
|
||||
import springfox.documentation.spring.web.plugins.Docket; |
|
||||
import springfox.documentation.swagger2.annotations.EnableSwagger2; |
|
||||
|
|
||||
import java.util.List; |
|
||||
|
|
||||
import static com.google.common.collect.Lists.newArrayList; |
|
||||
|
|
||||
/** |
|
||||
* Swagger配置 |
|
||||
* |
|
||||
* @author Mark sunlightcs@gmail.com |
|
||||
* @since 1.0.0 |
|
||||
*/ |
|
||||
@Configuration |
|
||||
@EnableSwagger2 |
|
||||
public class SwaggerConfig implements WebMvcConfigurer { |
|
||||
|
|
||||
@Bean |
|
||||
public Docket createRestApi() { |
|
||||
return new Docket(DocumentationType.SWAGGER_2) |
|
||||
.apiInfo(apiInfo()) |
|
||||
.select() |
|
||||
//加了ApiOperation注解的类,才生成接口文档
|
|
||||
.apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class)) |
|
||||
.paths(PathSelectors.any()) |
|
||||
.build() |
|
||||
.directModelSubstitute(java.util.Date.class, String.class) |
|
||||
.securitySchemes(security()); |
|
||||
|
|
||||
} |
|
||||
|
|
||||
private ApiInfo apiInfo() { |
|
||||
return new ApiInfoBuilder() |
|
||||
.title("人人开源") |
|
||||
.description("消息接口文档") |
|
||||
.termsOfServiceUrl("https://www.renren.io") |
|
||||
.version("1.1.0") |
|
||||
.build(); |
|
||||
} |
|
||||
|
|
||||
private List<ApiKey> security() { |
|
||||
return newArrayList( |
|
||||
new ApiKey(Constant.TOKEN_HEADER, Constant.TOKEN_HEADER, "header") |
|
||||
); |
|
||||
} |
|
||||
|
|
||||
} |
|
||||
@ -1,68 +0,0 @@ |
|||||
/** |
|
||||
* Copyright (c) 2018 人人开源 All rights reserved. |
|
||||
* |
|
||||
* https://www.renren.io
|
|
||||
* |
|
||||
* 版权所有,侵权必究! |
|
||||
*/ |
|
||||
|
|
||||
package com.epmet.config; |
|
||||
|
|
||||
import com.epmet.commons.tools.constant.Constant; |
|
||||
import io.swagger.annotations.ApiOperation; |
|
||||
import org.springframework.context.annotation.Bean; |
|
||||
import org.springframework.context.annotation.Configuration; |
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; |
|
||||
import springfox.documentation.builders.ApiInfoBuilder; |
|
||||
import springfox.documentation.builders.PathSelectors; |
|
||||
import springfox.documentation.builders.RequestHandlerSelectors; |
|
||||
import springfox.documentation.service.ApiInfo; |
|
||||
import springfox.documentation.service.ApiKey; |
|
||||
import springfox.documentation.spi.DocumentationType; |
|
||||
import springfox.documentation.spring.web.plugins.Docket; |
|
||||
import springfox.documentation.swagger2.annotations.EnableSwagger2; |
|
||||
|
|
||||
import java.util.List; |
|
||||
|
|
||||
import static com.google.common.collect.Lists.newArrayList; |
|
||||
|
|
||||
/** |
|
||||
* Swagger配置 |
|
||||
* |
|
||||
* @author Mark sunlightcs@gmail.com |
|
||||
* @since 1.0.0 |
|
||||
*/ |
|
||||
@Configuration |
|
||||
@EnableSwagger2 |
|
||||
public class SwaggerConfig implements WebMvcConfigurer { |
|
||||
|
|
||||
@Bean |
|
||||
public Docket createRestApi() { |
|
||||
return new Docket(DocumentationType.SWAGGER_2) |
|
||||
.apiInfo(apiInfo()) |
|
||||
.select() |
|
||||
//加了ApiOperation注解的类,才生成接口文档
|
|
||||
.apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class)) |
|
||||
.paths(PathSelectors.any()) |
|
||||
.build() |
|
||||
.directModelSubstitute(java.util.Date.class, String.class) |
|
||||
.securitySchemes(security()); |
|
||||
|
|
||||
} |
|
||||
|
|
||||
private ApiInfo apiInfo() { |
|
||||
return new ApiInfoBuilder() |
|
||||
.title("人人开源") |
|
||||
.description("OSS接口文档") |
|
||||
.termsOfServiceUrl("https://www.renren.io") |
|
||||
.version("1.1.0") |
|
||||
.build(); |
|
||||
} |
|
||||
|
|
||||
private List<ApiKey> security() { |
|
||||
return newArrayList( |
|
||||
new ApiKey(Constant.TOKEN_HEADER, Constant.TOKEN_HEADER, "header") |
|
||||
); |
|
||||
} |
|
||||
|
|
||||
} |
|
||||
@ -1,68 +0,0 @@ |
|||||
/** |
|
||||
* Copyright (c) 2018 人人开源 All rights reserved. |
|
||||
* |
|
||||
* https://www.renren.io
|
|
||||
* |
|
||||
* 版权所有,侵权必究! |
|
||||
*/ |
|
||||
|
|
||||
package com.epmet.config; |
|
||||
|
|
||||
import com.epmet.commons.tools.constant.Constant; |
|
||||
import io.swagger.annotations.ApiOperation; |
|
||||
import org.springframework.context.annotation.Bean; |
|
||||
import org.springframework.context.annotation.Configuration; |
|
||||
import springfox.documentation.builders.ApiInfoBuilder; |
|
||||
import springfox.documentation.builders.PathSelectors; |
|
||||
import springfox.documentation.builders.RequestHandlerSelectors; |
|
||||
import springfox.documentation.service.ApiInfo; |
|
||||
import springfox.documentation.service.ApiKey; |
|
||||
import springfox.documentation.spi.DocumentationType; |
|
||||
import springfox.documentation.spring.web.plugins.Docket; |
|
||||
import springfox.documentation.swagger2.annotations.EnableSwagger2; |
|
||||
|
|
||||
import java.util.List; |
|
||||
|
|
||||
import static com.google.common.collect.Lists.newArrayList; |
|
||||
|
|
||||
/** |
|
||||
* Swagger配置 |
|
||||
* |
|
||||
* @author Mark sunlightcs@gmail.com |
|
||||
* @since 1.0.0 |
|
||||
*/ |
|
||||
@Configuration |
|
||||
@EnableSwagger2 |
|
||||
public class SwaggerConfig { |
|
||||
|
|
||||
@Bean |
|
||||
public Docket createRestApi() { |
|
||||
return new Docket(DocumentationType.SWAGGER_2) |
|
||||
.apiInfo(apiInfo()) |
|
||||
.select() |
|
||||
//加了ApiOperation注解的类,才生成接口文档
|
|
||||
.apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class)) |
|
||||
//包下的类,才生成接口文档
|
|
||||
//.apis(RequestHandlerSelectors.basePackage("io.renren.controller"))
|
|
||||
.paths(PathSelectors.any()) |
|
||||
.build() |
|
||||
.directModelSubstitute(java.util.Date.class, String.class) |
|
||||
.securitySchemes(security()); |
|
||||
} |
|
||||
|
|
||||
private ApiInfo apiInfo() { |
|
||||
return new ApiInfoBuilder() |
|
||||
.title("人人开源") |
|
||||
.description("系统模块开发文档") |
|
||||
.termsOfServiceUrl("https://www.renren.io/community") |
|
||||
.version("1.4.0") |
|
||||
.build(); |
|
||||
} |
|
||||
|
|
||||
private List<ApiKey> security() { |
|
||||
return newArrayList( |
|
||||
new ApiKey(Constant.TOKEN_HEADER, Constant.TOKEN_HEADER, "header") |
|
||||
); |
|
||||
} |
|
||||
|
|
||||
} |
|
||||
@ -1,68 +0,0 @@ |
|||||
/** |
|
||||
* Copyright (c) 2018 人人开源 All rights reserved. |
|
||||
* |
|
||||
* https://www.renren.io
|
|
||||
* |
|
||||
* 版权所有,侵权必究! |
|
||||
*/ |
|
||||
|
|
||||
package com.epmet.config; |
|
||||
|
|
||||
import com.epmet.commons.tools.constant.Constant; |
|
||||
import io.swagger.annotations.ApiOperation; |
|
||||
import org.springframework.context.annotation.Bean; |
|
||||
import org.springframework.context.annotation.Configuration; |
|
||||
import springfox.documentation.builders.ApiInfoBuilder; |
|
||||
import springfox.documentation.builders.PathSelectors; |
|
||||
import springfox.documentation.builders.RequestHandlerSelectors; |
|
||||
import springfox.documentation.service.ApiInfo; |
|
||||
import springfox.documentation.service.ApiKey; |
|
||||
import springfox.documentation.spi.DocumentationType; |
|
||||
import springfox.documentation.spring.web.plugins.Docket; |
|
||||
import springfox.documentation.swagger2.annotations.EnableSwagger2; |
|
||||
|
|
||||
import java.util.List; |
|
||||
|
|
||||
import static com.google.common.collect.Lists.newArrayList; |
|
||||
|
|
||||
/** |
|
||||
* Swagger配置 |
|
||||
* |
|
||||
* @author Mark sunlightcs@gmail.com |
|
||||
* @since 1.0.0 |
|
||||
*/ |
|
||||
@Configuration |
|
||||
@EnableSwagger2 |
|
||||
public class SwaggerConfig { |
|
||||
|
|
||||
@Bean |
|
||||
public Docket createRestApi() { |
|
||||
return new Docket(DocumentationType.SWAGGER_2) |
|
||||
.apiInfo(apiInfo()) |
|
||||
.select() |
|
||||
//加了ApiOperation注解的类,才生成接口文档
|
|
||||
.apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class)) |
|
||||
//包下的类,才生成接口文档
|
|
||||
//.apis(RequestHandlerSelectors.basePackage("io.renren.controller"))
|
|
||||
.paths(PathSelectors.any()) |
|
||||
.build() |
|
||||
.directModelSubstitute(java.util.Date.class, String.class) |
|
||||
.securitySchemes(security()); |
|
||||
} |
|
||||
|
|
||||
private ApiInfo apiInfo() { |
|
||||
return new ApiInfoBuilder() |
|
||||
.title("人人开源") |
|
||||
.description("系统模块开发文档") |
|
||||
.termsOfServiceUrl("https://www.renren.io/community") |
|
||||
.version("1.4.0") |
|
||||
.build(); |
|
||||
} |
|
||||
|
|
||||
private List<ApiKey> security() { |
|
||||
return newArrayList( |
|
||||
new ApiKey(Constant.TOKEN_HEADER, Constant.TOKEN_HEADER, "header") |
|
||||
); |
|
||||
} |
|
||||
|
|
||||
} |
|
||||
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue