club.zhcs.openapi.SpringdocAutoConfiguration Maven / Gradle / Ivy
package club.zhcs.openapi;
import org.nutz.lang.Lang;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import io.swagger.v3.oas.annotations.enums.SecuritySchemeIn;
import io.swagger.v3.oas.annotations.enums.SecuritySchemeType;
import io.swagger.v3.oas.annotations.security.SecurityScheme;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.servers.Server;
@AutoConfiguration
@SecurityScheme(
name = "Authorization",
type = SecuritySchemeType.HTTP,
in = SecuritySchemeIn.HEADER,
scheme = "bearer",
bearerFormat = "JWT",
paramName = "Authorization")
@EnableConfigurationProperties(SpringdocConfigurationProperties.class)
public class SpringdocAutoConfiguration {
@Bean
OpenAPI openAPI(SpringdocConfigurationProperties config) {
Server server = config.getServer();
if (server == null) {
return new OpenAPI().info(config.getInfo());
} else {
return new OpenAPI().info(config.getInfo()).servers(Lang.list(config.getServer()));
}
}
@Bean
SwaggerCustomerController swaggerCustomerController(SpringdocConfigurationProperties config) {
return new SwaggerCustomerController(config);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy