ÎļþÃû´Ó ruoyi-common/ruoyi-common-doc/src/main/java/org/dromara/common/doc/config/SwaggerConfig.java ÐÞ¸Ä |
| | |
| | | package org.dromara.common.doc.config; |
| | | |
| | | import org.dromara.common.core.utils.StringUtils; |
| | | import org.dromara.common.doc.config.properties.SwaggerProperties; |
| | | import org.dromara.common.doc.handler.OpenApiHandler; |
| | | import io.swagger.v3.oas.models.OpenAPI; |
| | | import io.swagger.v3.oas.models.Paths; |
| | | import io.swagger.v3.oas.models.info.Info; |
| | | import io.swagger.v3.oas.models.security.SecurityRequirement; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.dromara.common.core.utils.StringUtils; |
| | | import org.dromara.common.doc.config.properties.SpringDocProperties; |
| | | import org.dromara.common.doc.handler.OpenApiHandler; |
| | | import org.springdoc.core.configuration.SpringDocConfiguration; |
| | | import org.springdoc.core.customizers.OpenApiBuilderCustomizer; |
| | | import org.springdoc.core.customizers.OpenApiCustomizer; |
| | |
| | | */ |
| | | @RequiredArgsConstructor |
| | | @AutoConfiguration(before = SpringDocConfiguration.class) |
| | | @EnableConfigurationProperties(SwaggerProperties.class) |
| | | @EnableConfigurationProperties(SpringDocProperties.class) |
| | | @ConditionalOnProperty(name = "springdoc.api-docs.enabled", havingValue = "true", matchIfMissing = true) |
| | | public class SwaggerConfig { |
| | | public class SpringDocConfig { |
| | | |
| | | private final ServerProperties serverProperties; |
| | | |
| | | @Bean |
| | | @ConditionalOnMissingBean(OpenAPI.class) |
| | | public OpenAPI openApi(SwaggerProperties swaggerProperties) { |
| | | public OpenAPI openApi(SpringDocProperties swaggerProperties) { |
| | | OpenAPI openApi = new OpenAPI(); |
| | | // ææ¡£åºæ¬ä¿¡æ¯ |
| | | SwaggerProperties.InfoProperties infoProperties = swaggerProperties.getInfo(); |
| | | SpringDocProperties.InfoProperties infoProperties = swaggerProperties.getInfo(); |
| | | Info info = convertInfo(infoProperties); |
| | | openApi.info(info); |
| | | // æ©å±ææ¡£ä¿¡æ¯ |
| | |
| | | return openApi; |
| | | } |
| | | |
| | | private Info convertInfo(SwaggerProperties.InfoProperties infoProperties) { |
| | | private Info convertInfo(SpringDocProperties.InfoProperties infoProperties) { |
| | | Info info = new Info(); |
| | | info.setTitle(infoProperties.getTitle()); |
| | | info.setDescription(infoProperties.getDescription()); |