content: package cn.org.alan.exam.config;
  
  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.ParameterBuilder;
  import springfox.documentation.builders.PathSelectors;
  import springfox.documentation.builders.RequestHandlerSelectors;
  import springfox.documentation.schema.ModelRef;
  import springfox.documentation.service.ApiInfo;
  import springfox.documentation.service.Parameter;
  import springfox.documentation.spi.DocumentationType;
  import springfox.documentation.spring.web.plugins.Docket;
  import springfox.documentation.swagger2.annotations.EnableSwagger2;
  
  import java.util.ArrayList;
  import java.util.List;
  
  /**
   * 说明：
   * Swagger配置
   *
   * @Author Alan
   * @Version 1.0
   * @Date 2025/3/18 7:30 PM
   */
  @Configuration
  // 开启Swagger
  @EnableSwagger2
  public class SwaggerConfig {
      @Bean
      public Docket api() {
          return new Docket(DocumentationType.SWAGGER_2)
                  .apiInfo(apiInfo())
                  .globalOperationParameters(parameters())
                  .select()
                  .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
                  .paths(PathSelectors.any())
                  .build();
      }
  
      /**
       * 配置文档信息
       * @return
       */
      private ApiInfo apiInfo() {
          return new ApiInfoBuilder()
                  .title("在线考试系统接口文档")
                  .description("本接口文档阅读对象：WEB服务前后端开发人员")
                  .version("1.0")
                  .build();
      }
  
      private List<Parameter> parameters() {
          Parameter tokentPar = new ParameterBuilder()
                  .name("Authorization")
                  .description("认证token")
                  .modelRef(new ModelRef("string"))
                  .parameterType("header")
                  .required(false)
                  .build();
  
          List<Parameter> parameters = new ArrayList<>();
          parameters.add(tokentPar);
          return parameters;
      }
  }