Guest User

Untitled

a guest
Dec 14th, 2019
87
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.example.proarea.config;
  2.  
  3.  
  4. import io.swagger.models.auth.In;
  5. import org.springframework.context.annotation.Bean;
  6. import org.springframework.context.annotation.Configuration;
  7. import springfox.documentation.builders.PathSelectors;
  8. import springfox.documentation.builders.RequestHandlerSelectors;
  9. import springfox.documentation.service.ApiKey;
  10. import springfox.documentation.service.SecurityScheme;
  11. import springfox.documentation.spi.DocumentationType;
  12. import springfox.documentation.spring.web.plugins.Docket;
  13.  
  14. import java.util.Collections;
  15.  
  16. @Configuration
  17. public class SwaggerConfig {
  18.  
  19. private static final String AUTHORIZATION_HEADER = "Authorization";
  20.  
  21. @Bean
  22. public Docket docket() {
  23. return new Docket(DocumentationType.SWAGGER_2)
  24. .select()
  25. .apis(RequestHandlerSelectors.basePackage("com.example.proarea.controllers"))
  26. .paths(PathSelectors.any())
  27. .build()
  28. .securitySchemes(Collections.singletonList(bearerToken()));
  29. }
  30.  
  31. //this been use for adding header as parameter
  32. @Bean
  33. public SecurityScheme bearerToken() {
  34. return new ApiKey(AUTHORIZATION_HEADER, AUTHORIZATION_HEADER, In.HEADER.name());
  35. }
  36.  
  37. }
RAW Paste Data