springfox.documentation.builders.AuthorizationScopeBuilder Java Examples

The following examples show how to use springfox.documentation.builders.AuthorizationScopeBuilder. 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: 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 #2
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 #3
Source File: MainController.java    From steady with Apache License 2.0 5 votes vote down vote up
/**
 * <p>userApi.</p>
 *
 * @return a {@link springfox.documentation.spring.web.plugins.Docket} object.
 */
@Bean
public Docket userApi() {
	AuthorizationScope[] authScopes = new AuthorizationScope[1];
	
	authScopes[0] = new AuthorizationScopeBuilder()
               .scope("read")
               .description("read access")
               .build();
	
	SecurityReference securityReference1 = SecurityReference.builder()
               .reference("tenant")
               .scopes(authScopes)
               .build();                
       
	SecurityReference securityReference2 = SecurityReference.builder()
               .reference("space")
               .scopes(authScopes)
               .build();   
	
       ArrayList<SecurityContext> securityContexts = newArrayList(SecurityContext.builder().securityReferences
               (newArrayList(securityReference1, securityReference2)).build());
	
	return new Docket(DocumentationType.SWAGGER_2)
			.groupName("user-api")
			.apiInfo(this.getApiInfo())
			.select()
			//.apis(RequestHandlerSelectors.any())
			.paths(this.userPaths())
			.build()
			//.pathMapping("/")
			.securitySchemes(newArrayList(this.tenantKey(), this.spaceKey()))
               .securityContexts(securityContexts)
			;
}
 
Example #4
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()));*/
}