springfox.documentation.service.BasicAuth Java Examples

The following examples show how to use springfox.documentation.service.BasicAuth. 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: SwaggerConfiguration.java    From api-layer with Eclipse Public License 2.0 7 votes vote down vote up
@Bean
public Docket api() {
    return new Docket(DocumentationType.SWAGGER_2)
        .select()
        .apis(RequestHandlerSelectors.basePackage("org.zowe.apiml.apicatalog.controllers.api"))
        .paths(
            PathSelectors.any()
        )
        .build()
        .securitySchemes(
            Arrays.asList(
                new BasicAuth("LoginBasicAuth"),
                new ApiKey("CookieAuth", "apimlAuthenticationToken", "header")
            )
        )
        .apiInfo(
            new ApiInfo(
                apiTitle,
                apiDescription,
                apiVersion,
                null,
                null,
                null,
                null,
                Collections.emptyList()
            )
        );
}
 
Example #2
Source File: SwaggerConfiguration.java    From todo-spring-angular with MIT License 6 votes vote down vote up
/**
 * Swagger Springfox configuration.
 */
@Bean
public Docket swaggerSpringfoxDocket() {
    log.debug("Starting Swagger");
    StopWatch watch = new StopWatch();
    watch.start();
    Docket docket = new Docket(DocumentationType.SWAGGER_2)
        .apiInfo(apiInfo())
        .securitySchemes(newArrayList(new BasicAuth("test")))
        .genericModelSubstitutes(ResponseEntity.class)
        .forCodeGeneration(true)
        .genericModelSubstitutes(ResponseEntity.class)
        .directModelSubstitute(org.joda.time.LocalDate.class, String.class)
        .directModelSubstitute(org.joda.time.LocalDateTime.class, Date.class)
        .directModelSubstitute(org.joda.time.DateTime.class, Date.class)
        .directModelSubstitute(java.time.LocalDate.class, String.class)
        .directModelSubstitute(java.time.ZonedDateTime.class, Date.class)
        .directModelSubstitute(java.time.LocalDateTime.class, Date.class)
        .select()
        .paths(regex(DEFAULT_INCLUDE_PATTERN))
        .build();
    watch.stop();
    log.debug("Started Swagger in {} ms", watch.getTotalTimeMillis());
    return docket;
}
 
Example #3
Source File: SwaggerConfig.java    From angularjs-springmvc-sample-boot with Apache License 2.0 6 votes vote down vote up
@Bean
public Docket userApi() {
    AuthorizationScope[] authScopes = new AuthorizationScope[1];
    authScopes[0] = new AuthorizationScopeBuilder()
            .scope("read")
            .description("read access")
            .build();
    SecurityReference securityReference = SecurityReference.builder()
            .reference("test")
            .scopes(authScopes)
            .build();
    ArrayList<SecurityContext> securityContexts = Lists.newArrayList(
            SecurityContext.builder()
                    .securityReferences(Lists.newArrayList(securityReference))
                    .build()
    );
    return new Docket(DocumentationType.SWAGGER_2)
            .directModelSubstitute(LocalDateTime.class, String.class)
            .ignoredParameterTypes(User.class)
            .securitySchemes(Lists.newArrayList(new BasicAuth("test")))
            .securityContexts(securityContexts)
            .apiInfo(apiInfo())
            .select()
            .paths(apiPaths())
            .build();
}
 
Example #4
Source File: Application.java    From springfox-demos with Apache License 2.0 6 votes vote down vote up
@Bean
public Docket userApi() {
  AuthorizationScope[] authScopes = new AuthorizationScope[1];
  authScopes[0] = new AuthorizationScopeBuilder()
      .scope("read")
      .description("read access")
      .build();
  SecurityReference securityReference = SecurityReference.builder()
      .reference("test")
      .scopes(authScopes)
      .build();

  List<SecurityContext> securityContexts =
      Collections.singletonList(
          SecurityContext.builder()
              .securityReferences(Collections.singletonList(securityReference))
              .build());
  return new Docket(DocumentationType.SWAGGER_2)
      .securitySchemes(Collections.singletonList(new BasicAuth("test")))
      .securityContexts(securityContexts)
      .groupName("user-api")
      .apiInfo(apiInfo())
      .select()
      .paths(input -> input.contains("user"))
      .build();
}
 
Example #5
Source File: OnrampSwaggerConfiguration.java    From data-highway with Apache License 2.0 5 votes vote down vote up
@Bean
public Docket onrampSwagger() {
  return new Docket(SWAGGER_2)
      .groupName("onramp")
      .securitySchemes(Collections.singletonList(new BasicAuth(BASIC_AUTH)))
      .securityContexts(Collections.singletonList(securityContext()))
      .apiInfo(new ApiInfoBuilder().title("Onramp").build())
      .useDefaultResponseMessages(false)
      .tags(new Tag("onramp", "Submit messages"))
      .select()
      .apis(RequestHandlerSelectors.any())
      .paths(PathSelectors.regex("/onramp.*"))
      .build();
}
 
Example #6
Source File: PaverSwaggerConfiguration.java    From data-highway with Apache License 2.0 5 votes vote down vote up
@Bean
public Docket paverSwagger() {
  return new Docket(SWAGGER_2)
      .groupName("paver")
      .securitySchemes(Collections.singletonList(new BasicAuth(BASIC_AUTH)))
      .securityContexts(Collections.singletonList(securityContext()))
      .apiInfo(new ApiInfoBuilder().title("Paver").build())
      .useDefaultResponseMessages(false)
      .tags(new Tag("road", "Administer roads"), new Tag("schema", "Administer schemas"))
      .select()
      .apis(RequestHandlerSelectors.any())
      .paths(PathSelectors.regex("/paver.*"))
      .build();
}
 
Example #7
Source File: SwaggerConfig.java    From pacbot with Apache License 2.0 5 votes vote down vote up
private List<? extends SecurityScheme> chooseSecuritSchema() {
	if (dataSource.equalsIgnoreCase("db") || dataSource.equalsIgnoreCase("ldap")) {
		return newArrayList(new BasicAuth(BASIC_AUTH));
	} else if (dataSource.equalsIgnoreCase("azuread")) {
		return newArrayList(oauth());
	}
	return newArrayList(apiKey());
}
 
Example #8
Source File: MainController.java    From steady with Apache License 2.0 5 votes vote down vote up
/**
 * <p>adminApi.</p>
 *
 * @return a {@link springfox.documentation.spring.web.plugins.Docket} object.
 */
@Bean
public Docket adminApi() {
	AuthorizationScope[] authScopes = new AuthorizationScope[1];
       
	authScopes[0] = new AuthorizationScopeBuilder()
               .scope("read")
               .description("read access")
               .build();
       
       SecurityReference securityReference = SecurityReference.builder()
               .reference("test")
               .scopes(authScopes)
               .build();                
               
       ArrayList<SecurityContext> securityContexts = newArrayList(SecurityContext.builder().securityReferences
               (newArrayList(securityReference)).build());
       
	return new Docket(DocumentationType.SWAGGER_2)
               .apiInfo(this.getApiInfo())
               .groupName("config-api")
			.select()
			//.apis(RequestHandlerSelectors.any())
			.paths(this.configPaths())
			.build()
			//.pathMapping("/")
			.securitySchemes(newArrayList(new BasicAuth("test")))
               .securityContexts(securityContexts)
               ;
	
			/*.directModelSubstitute(LocalDate.class, String.class).genericModelSubstitutes(ResponseEntity.class)
			.alternateTypeRules(newRule(typeResolver.resolve(DeferredResult.class, typeResolver.resolve(ResponseEntity.class, WildcardType.class)), typeResolver.resolve(WildcardType.class)))
			.useDefaultResponseMessages(false)
			.globalResponseMessage(RequestMethod.GET, newArrayList(new ResponseMessageBuilder().code(500).message("500 message").responseModel(new ModelRef("Error")).build()))
			.securitySchemes(newArrayList(this.tenantKey())).securityContexts(newArrayList(securityContext()));*/
}
 
Example #9
Source File: SwaggerConfig.java    From spring-ddd-bank with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Bean
public Docket swaggerConfiguration() {
    return new Docket(DocumentationType.SWAGGER_2)
            .select()
            .apis(RequestHandlerSelectors.any())
            .paths(Predicates.or(
                    PathSelectors.regex("/bank.*"),
                    PathSelectors.regex("/client.*")
            ))
            .build()
            .apiInfo(apiInfo())
            .securitySchemes(Arrays.asList(new BasicAuth("basicAuth")));
}
 
Example #10
Source File: SwaggerConfig.java    From quartz-manager with Apache License 2.0 5 votes vote down vote up
@Bean
public Docket api() {
	return new Docket(DocumentationType.SWAGGER_2).select()
			.apis(RequestHandlerSelectors.basePackage("it.fabioformosa.quartzmanager.controllers")) //
			.build() //
			.apiInfo(apiInfo()) //
			.securitySchemes(Arrays.asList(new BasicAuth("basicAuth")))
			.securityContexts(Collections.singletonList(securityContext()));
}