springfox.documentation.spring.web.plugins.ApiSelectorBuilder Java Examples
The following examples show how to use
springfox.documentation.spring.web.plugins.ApiSelectorBuilder.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Swagger2Config.java From spring-boot-plus with Apache License 2.0 | 6 votes |
@Bean public Docket createRestApi() { // 获取需要扫描的包 String[] basePackages = getBasePackages(); ApiSelectorBuilder apiSelectorBuilder = new Docket(DocumentationType.SWAGGER_2) .apiInfo(apiInfo()) .select(); // 如果扫描的包为空,则默认扫描类上有@Api注解的类 if (ArrayUtils.isEmpty(basePackages)) { apiSelectorBuilder.apis(RequestHandlerSelectors.withClassAnnotation(Api.class)); } else { // 扫描指定的包 apiSelectorBuilder.apis(basePackage(basePackages)); } Docket docket = apiSelectorBuilder.paths(PathSelectors.any()) .build() .enable(swaggerProperties.isEnable()) .ignoredParameterTypes(ignoredParameterTypes) .globalOperationParameters(getParameters()); return docket; }
Example #2
Source File: SwaggerConfig.java From webanno with Apache License 2.0 | 6 votes |
@ConditionalOnExpression("!(" + REMOTE_API_ENABLED_CONDITION + ")") @Bean public Docket defaultDocket() { ApiSelectorBuilder builder = new Docket(DocumentationType.SWAGGER_2).select(); builder.paths(path -> false); return builder.build() .groupName("Remote API disbled") .apiInfo(new ApiInfoBuilder() .title("Remote API disabled") .description(String.join(" ", "The remote API is disabled.")) .license("") .licenseUrl("") .build()); }
Example #3
Source File: SwaggerConfig.java From webanno with Apache License 2.0 | 6 votes |
@ConditionalOnExpression(REMOTE_API_ENABLED_CONDITION) @Bean public Docket areoRemoteApiDocket() { ApiSelectorBuilder builder = new Docket(DocumentationType.SWAGGER_2).select(); builder.paths(path -> path.matches(AeroRemoteApiController.API_BASE + "/.*")); return builder.build() .groupName("AERO API") .apiInfo(new ApiInfoBuilder() .title("AERO") .version("1.0.0") .description(String.join(" ", "Annotation Editor Remote Operations API. ", "https://openminted.github.io/releases/aero-spec/1.0.0/omtd-aero/")) .license("Apache License 2.0") .licenseUrl("https://www.apache.org/licenses/LICENSE-2.0.txt") .build()) .genericModelSubstitutes(Optional.class); }
Example #4
Source File: SwaggerConfig.java From BlogManagePlatform with Apache License 2.0 | 5 votes |
/** * 基本配置 * @author Frodez * @date 2019-12-04 */ private Docket baseConfig() { ApiSelectorBuilder selectorBuilder = new Docket(DocumentationType.SWAGGER_2).select(); selectorBuilder.apis(RequestHandlerSelectors.basePackage(swagger.getBasePackage())); selectorBuilder.paths(PathSelectors.any()); return selectorBuilder.build(); }
Example #5
Source File: B1ServiceApplication.java From spring-cloud-netflix-example with MIT License | 5 votes |
@Bean public Docket docket() { ApiSelectorBuilder apiSelectorBuilder = new Docket(DocumentationType.SWAGGER_2).select(); apiSelectorBuilder.apis(withClassAnnotation(Api.class)); return apiSelectorBuilder .build() .pathMapping("/") .useDefaultResponseMessages(false) .apiInfo(new ApiInfo("Service B API Doc", "Service B API Doc", "1.0", "https://github.com/yidongnan/spring-cloud-netflix-example", new Contact("Michael", "https://github.com/yidongnan", "[email protected]"), null, null)) .forCodeGeneration(true); }
Example #6
Source File: A1ServiceApplication.java From spring-cloud-netflix-example with MIT License | 5 votes |
@Bean public Docket docket() { ApiSelectorBuilder apiSelectorBuilder = new Docket(DocumentationType.SWAGGER_2).select(); apiSelectorBuilder.apis(withClassAnnotation(Api.class)); return apiSelectorBuilder .build() .pathMapping("/") .useDefaultResponseMessages(false) .apiInfo(new ApiInfo("Service A API Doc", "Service A API Doc", "1.0", "https://github.com/yidongnan/spring-cloud-netflix-example", new Contact("Michael", "https://github.com/yidongnan", "[email protected]"), null, null)) .forCodeGeneration(true); }
Example #7
Source File: BServiceApplication.java From spring-cloud-consul-example with MIT License | 5 votes |
@Bean public Docket docket() { ApiSelectorBuilder apiSelectorBuilder = new Docket(DocumentationType.SWAGGER_2).select(); apiSelectorBuilder.apis(withClassAnnotation(Api.class)); return apiSelectorBuilder .build() .pathMapping("/") .useDefaultResponseMessages(false) .apiInfo(new ApiInfo("Service B API Doc", "Service B API Doc", "1.0", "https://github.com/yidongnan/spring-cloud-consul-example", new Contact("Michael", "https://github.com/yidongnan", "[email protected]"), null, null)) .forCodeGeneration(true); }
Example #8
Source File: AServiceApplication.java From spring-cloud-consul-example with MIT License | 5 votes |
@Bean public Docket docket() { ApiSelectorBuilder apiSelectorBuilder = new Docket(DocumentationType.SWAGGER_2).select(); apiSelectorBuilder.apis(withClassAnnotation(Api.class)); return apiSelectorBuilder .build() .pathMapping("/") .useDefaultResponseMessages(false) .apiInfo(new ApiInfo("Service A API Doc", "Service A API Doc", "1.0", "https://github.com/yidongnan/spring-cloud-consul-example", new Contact("Michael", "https://github.com/yidongnan", "[email protected]"), null, null)) .forCodeGeneration(true); }
Example #9
Source File: SwaggerAutoConfigurationTest.java From jhipster with Apache License 2.0 | 5 votes |
@BeforeEach public void setup() { MockitoAnnotations.initMocks(this); final JHipsterProperties jHipsterProperties = new JHipsterProperties(); properties = jHipsterProperties.getSwagger(); properties.setHost("test.host.org"); properties.setProtocols(new String[]{"http", "https"}); properties.setTitle("test title"); properties.setDescription("test description"); properties.setVersion("6.6.6"); properties.setTermsOfServiceUrl("http://test.host.org/terms"); properties.setContactName("test contact"); properties.setContactEmail("[email protected]"); properties.setContactUrl("http://test.host.org/contact"); properties.setLicense("free as in beer"); properties.setLicenseUrl("http://test.host.org/license"); properties.setUseDefaultResponseMessages(false); config = new SwaggerAutoConfiguration(jHipsterProperties) { @Override protected Docket createDocket() { Docket docket = spy(super.createDocket()); when(docket.select()).thenReturn(builder = spy(new ApiSelectorBuilder(docket))); return docket; } }; recorder = LogbackRecorder.forClass(SwaggerAutoConfiguration.class).reset().capture("ALL"); }
Example #10
Source File: SwaggerConfig.java From webanno with Apache License 2.0 | 5 votes |
@ConditionalOnExpression(REMOTE_API_ENABLED_CONDITION) @Bean public Docket legacyRemoteApiDocket() { ApiSelectorBuilder builder = new Docket(DocumentationType.SWAGGER_2).select(); builder.paths(path -> path.matches(LegacyRemoteApiController.API_BASE + "/.*")); return builder.build() .groupName("Legacy API") .genericModelSubstitutes(Optional.class); }