| | |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import io.swagger.v3.oas.annotations.responses.ApiResponse; |
| | | import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; |
| | | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; |
| | | import org.springframework.boot.context.properties.EnableConfigurationProperties; |
| | |
| | | @ConditionalOnMissingBean(OpenAPI.class) |
| | | public OpenAPI openApi(SpringDocProperties properties) |
| | | { |
| | | return new OpenAPI().components(new Components() |
| | | // 设置认证的请求头 |
| | | .addSecuritySchemes("apikey", securityScheme())) |
| | | .addSecurityItem(new SecurityRequirement().addList("apikey")) |
| | | .info(convertInfo(properties.getInfo())) |
| | | .servers(servers(properties.getGatewayUrl())); |
| | | OpenAPI servers = new OpenAPI().components(new Components() |
| | | // 设置认证的请求头 |
| | | .addSecuritySchemes("apikey", securityScheme())) |
| | | .addSecurityItem(new SecurityRequirement().addList("apikey")) |
| | | .info(convertInfo(properties.getInfo())) |
| | | .servers(servers(properties.getGatewayUrl())); |
| | | return servers; |
| | | } |
| | | |
| | | public SecurityScheme securityScheme() |
| | |
| | | .in(SecurityScheme.In.HEADER) |
| | | .scheme("Bearer"); |
| | | } |
| | | |
| | | private Info convertInfo(SpringDocProperties.InfoProperties infoProperties) |
| | | { |
| | | Info info = new Info(); |