All Downloads are FREE. Search and download functionalities are using the official Maven repository.

club.zhcs.openapi.SpringdocAutoConfiguration Maven / Gradle / Ivy

There is a newer version: 3.3.4
Show newest version
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