【7.6.0】【框架改造】删掉openapi模块

pull/55/head
fengshuonan 2023-05-09 18:20:22 +08:00
parent fbeb815a27
commit 674502dfdf
12 changed files with 0 additions and 462 deletions

View File

@ -1 +0,0 @@
openapi接口文档适配

View File

@ -1,36 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>cn.stylefeng.roses</groupId>
<artifactId>kernel-d-openapi</artifactId>
<version>7.6.0</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>openapi-api</artifactId>
<packaging>jar</packaging>
<dependencies>
<!-- 开发规则 -->
<dependency>
<groupId>cn.stylefeng.roses</groupId>
<artifactId>kernel-a-rule</artifactId>
<version>${roses.version}</version>
</dependency>
<!--资源模块的api-->
<dependency>
<groupId>cn.stylefeng.roses</groupId>
<artifactId>scanner-api</artifactId>
<version>${roses.version}</version>
</dependency>
</dependencies>
</project>

View File

@ -1,40 +0,0 @@
/*
* Copyright [2020-2030] [https://www.stylefeng.cn]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* GunsAPACHE LICENSE 2.0使
*
* 1.LICENSE
* 2.Guns
* 3.
* 4. https://gitee.com/stylefeng/guns
* 5. https://gitee.com/stylefeng/guns
* 6.
*/
package cn.stylefeng.roses.kernel.openapi.api.constants;
/**
* OpenApi
*
* @author caiti
* @since 2022-11-11
*/
public interface OpenApiConstants {
/**
* OpenApi
*/
String OPENAPI_MODULE_NAME = "kernel-d-openapi";
}

View File

@ -1,43 +0,0 @@
/*
* Copyright [2020-2030] [https://www.stylefeng.cn]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* GunsAPACHE LICENSE 2.0使
*
* 1.LICENSE
* 2.Guns
* 3.
* 4. https://gitee.com/stylefeng/guns
* 5. https://gitee.com/stylefeng/guns
* 6.
*/
package cn.stylefeng.roses.kernel.openapi.api.exception;
import cn.stylefeng.roses.kernel.openapi.api.constants.OpenApiConstants;
import cn.stylefeng.roses.kernel.rule.exception.AbstractExceptionEnum;
import cn.stylefeng.roses.kernel.rule.exception.base.ServiceException;
/**
* OpenApi
*
* @author caiti
* @since 2022-11-11
*/
public class OpenApiException extends ServiceException {
public OpenApiException(AbstractExceptionEnum exceptionEnum) {
super(OpenApiConstants.OPENAPI_MODULE_NAME, exceptionEnum);
}
}

View File

@ -1,35 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>cn.stylefeng.roses</groupId>
<artifactId>kernel-d-openapi</artifactId>
<version>7.6.0</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>openapi-sdk-springdoc</artifactId>
<packaging>jar</packaging>
<dependencies>
<!-- openapi接口文档模块 -->
<dependency>
<groupId>cn.stylefeng.roses</groupId>
<artifactId>openapi-api</artifactId>
<version>${roses.version}</version>
</dependency>
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-webmvc-core</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -1,77 +0,0 @@
/*
* Copyright [2020-2030] [https://www.stylefeng.cn]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* GunsAPACHE LICENSE 2.0使
*
* 1.LICENSE
* 2.Guns
* 3.
* 4. https://gitee.com/stylefeng/guns
* 5. https://gitee.com/stylefeng/guns
* 6.
*/
package cn.stylefeng.roses.kernel.springdoc.converter;
import cn.stylefeng.roses.kernel.rule.annotation.ChineseDescription;
import io.swagger.v3.core.converter.AnnotatedType;
import io.swagger.v3.core.converter.ModelConverter;
import io.swagger.v3.core.converter.ModelConverterContext;
import io.swagger.v3.oas.models.media.Schema;
import java.lang.annotation.Annotation;
import java.util.Iterator;
import java.util.Objects;
/**
*
*
* @author caiti
* @since 2022-11-11
*/
public class GunsModelConverterImpl implements ModelConverter {
@Override
public Schema resolve(AnnotatedType annotatedType, ModelConverterContext context, Iterator<ModelConverter> chain) {
Schema schema = next(annotatedType, context, chain);
Annotation[] ctxAnnotations = annotatedType.getCtxAnnotations();
if (Objects.isNull(ctxAnnotations)) {
return schema;
}
ChineseDescription chineseDescription = null;
for (Annotation ctxAnnotation : ctxAnnotations) {
if (ctxAnnotation instanceof ChineseDescription) {
chineseDescription = (ChineseDescription) ctxAnnotation;
break;
}
}
if (chineseDescription == null) {
return schema;
}
if (schema != null) {
schema.setDescription(chineseDescription.value());
}
return schema;
}
private Schema next(AnnotatedType annotatedType, ModelConverterContext context, Iterator<ModelConverter> chain) {
if (chain.hasNext()) {
return chain.next().resolve(annotatedType, context, chain);
} else {
return null;
}
}
}

View File

@ -1,108 +0,0 @@
/*
* Copyright [2020-2030] [https://www.stylefeng.cn]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* GunsAPACHE LICENSE 2.0使
*
* 1.LICENSE
* 2.Guns
* 3.
* 4. https://gitee.com/stylefeng/guns
* 5. https://gitee.com/stylefeng/guns
* 6.
*/
package cn.stylefeng.roses.kernel.springdoc.providers;
import cn.stylefeng.roses.kernel.rule.annotation.ChineseDescription;
import cn.stylefeng.roses.kernel.scanner.api.annotation.ApiResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.GetResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.PostResource;
import org.springdoc.core.providers.JavadocProvider;
import org.springframework.core.annotation.AnnotatedElementUtils;
import org.springframework.lang.Nullable;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.Map;
/**
*
*
* @author caiti
* @since 2022-11-11
*/
public class GunsJavadocProviderImpl implements JavadocProvider {
@Override
public String getClassJavadoc(Class<?> cl) {
ApiResource annotation = AnnotatedElementUtils.getMergedAnnotation(cl, ApiResource.class);
if (annotation != null) {
return annotation.name();
}
return null;
}
@Override
public String getMethodJavadocDescription(Method method) {
return getResourceName(method);
}
@Override
public String getMethodJavadocReturn(Method method) {
return getResourceName(method);
}
@Nullable
private String getResourceName(Method method) {
GetResource getAnnotation = AnnotatedElementUtils.getMergedAnnotation(method, GetResource.class);
if (getAnnotation != null) {
return getAnnotation.name();
}
PostResource postAnnotation = AnnotatedElementUtils.getMergedAnnotation(method, PostResource.class);
if (postAnnotation != null) {
return postAnnotation.name();
}
ApiResource apiAnnotation = AnnotatedElementUtils.getMergedAnnotation(method, ApiResource.class);
if (apiAnnotation != null) {
return apiAnnotation.name();
}
return null;
}
@Override
public Map<String, String> getMethodJavadocThrows(Method method) {
return null;
}
@Override
public String getParamJavadoc(Method method, String name) {
return null;
}
@Override
public String getFieldJavadoc(Field field) {
ChineseDescription annotation = AnnotatedElementUtils.getMergedAnnotation(field, ChineseDescription.class);
if (annotation != null) {
return annotation.value();
}
return null;
}
@Override
public String getFirstSentence(String text) {
return text;
}
}

View File

@ -1,29 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>cn.stylefeng.roses</groupId>
<artifactId>kernel-d-openapi</artifactId>
<version>7.6.0</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>openapi-spring-boot-starter</artifactId>
<packaging>jar</packaging>
<dependencies>
<!-- openapi接口文档springdoc实现 -->
<dependency>
<groupId>cn.stylefeng.roses</groupId>
<artifactId>openapi-sdk-springdoc</artifactId>
<version>${roses.version}</version>
</dependency>
</dependencies>
</project>

View File

@ -1,56 +0,0 @@
/*
* Copyright [2020-2030] [https://www.stylefeng.cn]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* GunsAPACHE LICENSE 2.0使
*
* 1.LICENSE
* 2.Guns
* 3.
* 4. https://gitee.com/stylefeng/guns
* 5. https://gitee.com/stylefeng/guns
* 6.
*/
package cn.stylefeng.roses.kernel.springdoc.starter;
import cn.stylefeng.roses.kernel.springdoc.converter.GunsModelConverterImpl;
import cn.stylefeng.roses.kernel.springdoc.providers.GunsJavadocProviderImpl;
import io.swagger.v3.core.converter.ModelConverter;
import org.springdoc.core.providers.JavadocProvider;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
/**
* openapi
*
* @author caiti
* @since 2022-11-11
*/
@Configuration
public class SpringdocOpenApiAutoConfiguration {
@Bean
@Order(Ordered.HIGHEST_PRECEDENCE)
public ModelConverter gunsSpringdocModelConverter() {
return new GunsModelConverterImpl();
}
@Bean
public JavadocProvider gunsSpringdocJavadocProvider() {
return new GunsJavadocProviderImpl();
}
}

View File

@ -1,2 +0,0 @@
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
cn.stylefeng.roses.kernel.springdoc.starter.SpringdocOpenApiAutoConfiguration

View File

@ -1,24 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>cn.stylefeng.roses</groupId>
<artifactId>roses-kernel</artifactId>
<version>7.6.0</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>kernel-d-openapi</artifactId>
<packaging>pom</packaging>
<modules>
<module>openapi-api</module>
<module>openapi-spring-boot-starter</module>
<module>openapi-sdk-springdoc</module>
</modules>
</project>

11
pom.xml
View File

@ -58,9 +58,6 @@
<!--office模块-->
<module>kernel-d-office</module>
<!--open api适配-->
<module>kernel-d-openapi</module>
<!--拼音工具模块-->
<module>kernel-d-pinyin</module>
@ -147,7 +144,6 @@
<pinyin4j.version>2.5.0</pinyin4j.version>
<openfeign.version>2.2.6.RELEASE</openfeign.version>
<bcprov.version>1.68</bcprov.version>
<springdoc.version>1.6.12</springdoc.version>
<flyway.version>7.1.1</flyway.version>
</properties>
@ -315,13 +311,6 @@
<version>${getty.version}</version>
</dependency>
<!-- openapi接口文档 -->
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-webmvc-core</artifactId>
<version>${springdoc.version}</version>
</dependency>
</dependencies>
</dependencyManagement>