Skip to content

Commit

Permalink
添加 solon.docs.openapi2 插件
Browse files Browse the repository at this point in the history
  • Loading branch information
noear committed Jul 30, 2023
1 parent 8ad0dfa commit 73cd50b
Show file tree
Hide file tree
Showing 14 changed files with 112 additions and 19 deletions.
3 changes: 3 additions & 0 deletions __release/solon-base-bundle/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
<module>../../solon-projects/solon-base/solon.data.shardingds</module>

<module>../../solon-projects/solon-base/solon.docs</module>
<module>../../solon-projects/solon-base/solon.docs.openapi2</module>
<module>../../solon-projects/solon-base/solon.docs.openapi3</module>

<module>../../solon-projects/solon-base/solon.auth</module>
<module>../../solon-projects/solon-base/solon.test</module>
<module>../../solon-projects/solon-base/solon.validation</module>
Expand Down
11 changes: 11 additions & 0 deletions solon-parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
<snakeyaml.version>2.0</snakeyaml.version>

<swagger.version>1.6.11</swagger.version>
<swagger2.version>2.2.15</swagger2.version>
<knife4j.version>4.1.0</knife4j.version>

<jackson.version>2.14.3</jackson.version>
Expand Down Expand Up @@ -403,6 +404,16 @@
<artifactId>solon.docs</artifactId>
<version>${solon.version}</version>
</dependency>
<dependency>
<groupId>org.noear</groupId>
<artifactId>solon.docs.openapi2</artifactId>
<version>${solon.version}</version>
</dependency>
<dependency>
<groupId>org.noear</groupId>
<artifactId>solon.docs.openapi3</artifactId>
<version>${solon.version}</version>
</dependency>
<dependency>
<groupId>org.noear</groupId>
<artifactId>solon.auth</artifactId>
Expand Down
45 changes: 45 additions & 0 deletions solon-projects/solon-base/solon.docs.openapi2/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?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>org.noear</groupId>
<artifactId>solon-parent</artifactId>
<version>2.4.2-SNAPSHOT</version>
<relativePath>../../../solon-parent/pom.xml</relativePath>
</parent>

<artifactId>solon.docs.openapi2</artifactId>
<packaging>jar</packaging>

<dependencies>
<dependency>
<groupId>org.noear</groupId>
<artifactId>solon.docs</artifactId>
</dependency>

<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
<version>${swagger.version}</version>
</dependency>

<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-models</artifactId>
<version>${swagger.version}</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
<exclusion>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -1,25 +1,22 @@
package org.noear.solon.docs.openapi2;

import io.swagger.annotations.*;
import io.swagger.models.*;
import io.swagger.models.ExternalDocs;
import io.swagger.models.Info;
import io.swagger.models.Tag;
import io.swagger.models.parameters.*;
import io.swagger.models.*;
import io.swagger.models.parameters.Parameter;
import io.swagger.models.parameters.*;
import io.swagger.models.properties.*;
import io.swagger.models.refs.RefFormat;

import io.swagger.solon.annotation.ApiNoAuthorize;
import io.swagger.solon.annotation.ApiRes;
import io.swagger.solon.annotation.ApiResProperty;

import org.noear.solon.Solon;
import org.noear.solon.Utils;
import org.noear.solon.core.handle.*;
import org.noear.solon.core.route.Routing;
import org.noear.solon.core.util.GenericUtil;

import org.noear.solon.core.wrap.ClassWrap;
import org.noear.solon.core.wrap.FieldWrap;
import org.noear.solon.core.wrap.ParamWrap;
Expand Down
22 changes: 22 additions & 0 deletions solon-projects/solon-base/solon.docs/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,28 @@
</exclusions>
</dependency>

<dependency>
<groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-annotations</artifactId>
<version>${swagger2.version}</version>
</dependency>

<dependency>
<groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-models</artifactId>
<version>${swagger2.version}</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
<exclusion>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ public class DocDocket {
private Map<String, Object> vendorExtensions = new LinkedHashMap<>();


public DocDocket(DocType docType) {
this.version = docType.getVersion();
}

public String version() {
return version;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package org.noear.solon.docs;

/**
* @author noear
* @since 2.4
*/
public enum DocType {
SWAGGER_2("2.0"),
SWAGGER_3("3.0");

String version;

DocType(String version) {
this.version = version;
}

public String getVersion() {
return version;
}
}

This file was deleted.

2 changes: 1 addition & 1 deletion solon-projects/solon-tool/solon-openapi2-knife4j/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<dependencies>
<dependency>
<groupId>org.noear</groupId>
<artifactId>solon.docs</artifactId>
<artifactId>solon.docs.openapi2</artifactId>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.swagger.demo.model.HttpCodes;

import org.noear.solon.docs.ApiEnum;
import org.noear.solon.docs.DocType;
import org.noear.solon.docs.models.ApiInfo;
import org.noear.solon.docs.DocDocket;

Expand Down Expand Up @@ -36,7 +37,7 @@ public DocDocket adminApi(@Inject("${swagger.adminApi}") DocDocket docket) {
*/
@Bean("appApi")
public DocDocket appApi() {
return new DocDocket()
return new DocDocket(DocType.SWAGGER_2)
.groupName("app端接口")
.schemes(ApiEnum.SCHEMES_HTTP)
.globalResult(Result.class)
Expand All @@ -51,7 +52,7 @@ public DocDocket appApi() {
*/
@Bean("gatewayApi")
public DocDocket gatewayApi() {
return new DocDocket()
return new DocDocket(DocType.SWAGGER_2)
.groupName("gateway端接口")
.schemes(ApiEnum.SCHEMES_HTTP)
.globalResult(Result.class)
Expand All @@ -63,7 +64,7 @@ public DocDocket gatewayApi() {

// @Bean("appApi")
public DocDocket appApi2() {
return new DocDocket()
return new DocDocket(DocType.SWAGGER_2)
.groupName("app端接口")
.info(new ApiInfo().title("在线文档")
.description("在线API文档")
Expand Down

0 comments on commit 73cd50b

Please sign in to comment.