You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@linkis.apache.org by pe...@apache.org on 2022/07/07 11:31:37 UTC
[incubator-linkis] branch dev-1.2.0 updated: Support knif4j (#2434)
This is an automated email from the ASF dual-hosted git repository.
peacewong pushed a commit to branch dev-1.2.0
in repository https://gitbox.apache.org/repos/asf/incubator-linkis.git
The following commit(s) were added to refs/heads/dev-1.2.0 by this push:
new f7c72e2be Support knif4j (#2434)
f7c72e2be is described below
commit f7c72e2bef589ac9d3b14850ddd69011fd9d3c00
Author: Casion <ca...@gmail.com>
AuthorDate: Thu Jul 7 19:31:31 2022 +0800
Support knif4j (#2434)
* adjust swagger
---
.gitignore | 1 +
linkis-commons/linkis-knife4j/pom.xml | 68 ----------------------
linkis-commons/linkis-module/pom.xml | 7 +++
.../org/apache/linkis/server}/Knife4jConfig.scala | 34 +++++------
linkis-commons/pom.xml | 1 -
.../package/conf/linkis-mg-gateway.properties | 4 +-
linkis-dist/package/conf/linkis.properties | 2 +-
linkis-dist/pom.xml | 13 -----
.../linkis-gateway-authentication/pom.xml | 14 +++++
.../src/main/assembly/distribution.xml | 6 ++
10 files changed, 46 insertions(+), 104 deletions(-)
diff --git a/.gitignore b/.gitignore
index a0dae0888..9978b4c26 100644
--- a/.gitignore
+++ b/.gitignore
@@ -29,4 +29,5 @@ out/
target/
# log folder
+*.log
logs/
\ No newline at end of file
diff --git a/linkis-commons/linkis-knife4j/pom.xml b/linkis-commons/linkis-knife4j/pom.xml
deleted file mode 100644
index a993c6555..000000000
--- a/linkis-commons/linkis-knife4j/pom.xml
+++ /dev/null
@@ -1,68 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one or more
- ~ contributor license agreements. See the NOTICE file distributed with
- ~ this work for additional information regarding copyright ownership.
- ~ The ASF licenses this file to You 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.
- -->
-<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">
- <parent>
- <artifactId>linkis</artifactId>
- <groupId>org.apache.linkis</groupId>
- <version>1.1.3</version>
- </parent>
- <modelVersion>4.0.0</modelVersion>
-
- <artifactId>linkis-knife4j</artifactId>
- <packaging>jar</packaging>
-
- <dependencies>
- <!--add knif2 dependency-->
- <dependency>
- <groupId>com.github.xiaoymin</groupId>
- <artifactId>knife4j-spring-boot-starter</artifactId>
- <version>${knife4j.version}</version>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-webmvc</artifactId>
- <version>${spring.version}</version>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-deploy-plugin</artifactId>
- </plugin>
-
- <plugin>
- <groupId>net.alchim31.maven</groupId>
- <artifactId>scala-maven-plugin</artifactId>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jar-plugin</artifactId>
- </plugin>
- </plugins>
- <resources>
- <resource>
- <directory>src/main/resources</directory>
- </resource>
- </resources>
- <finalName>${project.artifactId}-${project.version}</finalName>
- </build>
-</project>
\ No newline at end of file
diff --git a/linkis-commons/linkis-module/pom.xml b/linkis-commons/linkis-module/pom.xml
index 752cb497f..4958d90b0 100644
--- a/linkis-commons/linkis-module/pom.xml
+++ b/linkis-commons/linkis-module/pom.xml
@@ -37,6 +37,13 @@
<version>${linkis.version}</version>
</dependency>
+ <!--add knif2 dependency-->
+ <dependency>
+ <groupId>com.github.xiaoymin</groupId>
+ <artifactId>knife4j-spring-boot-starter</artifactId>
+ <version>${knife4j.version}</version>
+ </dependency>
+
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
diff --git a/linkis-commons/linkis-knife4j/src/main/scala/org/apache/linkis/knife4j/conf/Knife4jConfig/Knife4jConfig.scala b/linkis-commons/linkis-module/src/main/scala/org/apache/linkis/server/Knife4jConfig.scala
similarity index 76%
rename from linkis-commons/linkis-knife4j/src/main/scala/org/apache/linkis/knife4j/conf/Knife4jConfig/Knife4jConfig.scala
rename to linkis-commons/linkis-module/src/main/scala/org/apache/linkis/server/Knife4jConfig.scala
index 554f5c6c3..92c44d616 100644
--- a/linkis-commons/linkis-knife4j/src/main/scala/org/apache/linkis/knife4j/conf/Knife4jConfig/Knife4jConfig.scala
+++ b/linkis-commons/linkis-module/src/main/scala/org/apache/linkis/server/Knife4jConfig.scala
@@ -1,5 +1,3 @@
-package org.apache.linkis.knife4j.conf.Knife4jConfig
-
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -16,27 +14,22 @@ package org.apache.linkis.knife4j.conf.Knife4jConfig
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+package org.apache.linkis.server
-import org.springframework.context.annotation.Bean
-import org.springframework.web.servlet.config.annotation.WebMvcConfigurer
import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j
-import org.springframework.context.annotation.Bean
-import org.springframework.context.annotation.Configuration
-import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry
-import org.springframework.web.servlet.config.annotation.ViewControllerRegistry
-import org.springframework.web.servlet.config.annotation.WebMvcConfigurer
-import springfox.documentation.builders.ApiInfoBuilder
-import springfox.documentation.builders.PathSelectors
-import springfox.documentation.builders.RequestHandlerSelectors
+import org.springframework.beans.factory.annotation.Value
+import org.springframework.context.annotation.{Bean, Configuration}
+import org.springframework.web.servlet.config.annotation.{ResourceHandlerRegistry, ViewControllerRegistry, WebMvcConfigurer}
+import springfox.documentation.builders.{ApiInfoBuilder, PathSelectors, RequestHandlerSelectors}
import springfox.documentation.service.ApiInfo
import springfox.documentation.spi.DocumentationType
import springfox.documentation.spring.web.plugins.Docket
import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc
-import org.springframework.beans.factory.annotation.Value
-/**
+/*
* it is very easy to enable knife when you want to use apiDoc(based on swagger2)
* you can follow these steps to enable
+ * <pre>
* 1, open application-linkis.yml and set knife4j.production=false
* 2, open linkis.properties and set wds.linkis.test.mode=true ## it will be renamed as linkis.test.mode in future release
* 3, restart the service and you can visit http://ip:port/api/rest_j/v1/doc.html
@@ -46,29 +39,30 @@ import org.springframework.beans.factory.annotation.Value
* 2, open linkis.propertes ,and set wds.linkis.server.user.restful.uri.pass.auth=/api/rest_j/v1/doc.html,/api/rest_j/v1/swagger-resources,/api/rest_j/v1/webjars,/api/rest_j/v1/v2/api-docs
* 3, restart the service and you can visit http://ip:port/api/rest_j/v1/doc.html
* 4, in your browser,add dataworkcloud_inner_request=true, bdp-user-ticket-id's value and workspaceId's value into cookie
+ * </pre>
*/
@EnableSwagger2WebMvc
@EnableKnife4j
@Configuration
class Knife4jConfig extends WebMvcConfigurer {
- @Value("${spring.application.name}") private val appName = "linkis service"
+ @Value("${spring.application.name}") private var appName = "linkis service"
@Bean(Array("defaultApi2"))
def defaultApi2() : Docket = {
val docket = new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo())
- //分组名称
+ //set group name
.groupName("RESTAPI")
.select()
- //这里指定Controller扫描包路径
+ //specifies the controller scan package path
.apis(RequestHandlerSelectors.basePackage("org.apache.linkis"))
.paths(PathSelectors.any())
.build()
docket
}
- def apiInfo() : ApiInfo ={
+ def apiInfo() : ApiInfo = {
val apiInfo = new ApiInfoBuilder()
.title(appName)
.description("Linkis micro service RESTful APIs")
@@ -77,12 +71,12 @@ class Knife4jConfig extends WebMvcConfigurer {
apiInfo
}
- override def addResourceHandlers( registry : ResourceHandlerRegistry): Unit = {
+ override def addResourceHandlers(registry: ResourceHandlerRegistry): Unit = {
registry.addResourceHandler("/api/rest_j/v1/doc.html**").addResourceLocations("classpath:/META-INF/resources/doc.html")
registry.addResourceHandler("/api/rest_j/v1/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/")
}
- override def addViewControllers(registry : ViewControllerRegistry ) : Unit = {
+ override def addViewControllers(registry: ViewControllerRegistry): Unit = {
registry.addRedirectViewController("/api/rest_j/v1/v2/api-docs", "/v2/api-docs")
registry.addRedirectViewController("/api/rest_j/v1/swagger-resources/configuration/ui", "/swagger-resources/configuration/ui")
registry.addRedirectViewController("/api/rest_j/v1/swagger-resources/configuration/security", "/swagger-resources/configuration/security")
diff --git a/linkis-commons/pom.xml b/linkis-commons/pom.xml
index 4b515ada2..23afc9f7f 100644
--- a/linkis-commons/pom.xml
+++ b/linkis-commons/pom.xml
@@ -38,7 +38,6 @@
<module>linkis-mybatis</module>
<module>linkis-rpc</module>
<module>linkis-storage</module>
- <module>linkis-knife4j</module>
</modules>
</project>
\ No newline at end of file
diff --git a/linkis-dist/package/conf/linkis-mg-gateway.properties b/linkis-dist/package/conf/linkis-mg-gateway.properties
index 0eb409290..a43b50f94 100644
--- a/linkis-dist/package/conf/linkis-mg-gateway.properties
+++ b/linkis-dist/package/conf/linkis-mg-gateway.properties
@@ -32,4 +32,6 @@ wds.linkis.ldap.proxy.userNameFormat=
wds.linkis.admin.user=hadoop
#wds.linkis.admin.password=
##Spring
-spring.server.port=9001
\ No newline at end of file
+spring.server.port=9001
+
+wds.linkis.server.component.exclude.classes=org.apache.linkis.server.Knife4jConfig
\ No newline at end of file
diff --git a/linkis-dist/package/conf/linkis.properties b/linkis-dist/package/conf/linkis.properties
index 6fa8076ea..2bc8d17bf 100644
--- a/linkis-dist/package/conf/linkis.properties
+++ b/linkis-dist/package/conf/linkis.properties
@@ -51,7 +51,7 @@ wds.linkis.home=/appcom/Install/LinkisInstall
#Linkis governance station administrators
wds.linkis.governance.station.admin=hadoop
wds.linkis.gateway.conf.publicservice.list=query,jobhistory,application,configuration,filesystem,udf,variable,microservice,errorcode,bml,datasource
-wds.linkis.server.user.restful.uri.pass.auth=/actuator/prometheus,/api/rest_j/v1/offline
+wds.linkis.server.user.restful.uri.pass.auth=/actuator/prometheus,/api/rest_j/v1/offline,/api/rest_j/v1/doc.html,/api/rest_j/v1/swagger-resources,/api/rest_j/v1/webjars,/api/rest_j/v1/v2/api-docs
wds.linkis.gateway.conf.metadataquery.list=metadatamanager,metadataquery
spring.spring.servlet.multipart.max-file-size=500MB
diff --git a/linkis-dist/pom.xml b/linkis-dist/pom.xml
index 81039bc19..9efe7740f 100644
--- a/linkis-dist/pom.xml
+++ b/linkis-dist/pom.xml
@@ -153,19 +153,6 @@
<version>1.9.4</version>
</dependency>
- <!--add knif4j-->
- <dependency>
- <groupId>org.apache.linkis</groupId>
- <artifactId>linkis-knife4j</artifactId>
- <version>${linkis.version}</version>
- <exclusions>
- <exclusion>
- <groupId>org.springframework</groupId>
- <artifactId>spring-webmvc</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
-
</dependencies>
<build>
diff --git a/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-authentication/pom.xml b/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-authentication/pom.xml
index 928a8bc60..00a898bf0 100644
--- a/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-authentication/pom.xml
+++ b/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-authentication/pom.xml
@@ -52,6 +52,20 @@
<artifactId>linkis-module</artifactId>
<scope>provided</scope>
<version>${linkis.version}</version>
+ <exclusions>
+ <exclusion>
+ <artifactId>*</artifactId>
+ <groupId>com.github.xiaoymin</groupId>
+ </exclusion>
+ <exclusion>
+ <artifactId>*</artifactId>
+ <groupId>io.springfox</groupId>
+ </exclusion>
+ <exclusion>
+ <artifactId>*</artifactId>
+ <groupId>io.swagger</groupId>
+ </exclusion>
+ </exclusions>
</dependency>
</dependencies>
diff --git a/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-server-support/src/main/assembly/distribution.xml b/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-server-support/src/main/assembly/distribution.xml
index 7a84bdc26..f763b0b10 100644
--- a/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-server-support/src/main/assembly/distribution.xml
+++ b/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-server-support/src/main/assembly/distribution.xml
@@ -38,6 +38,12 @@
<unpack>false</unpack>
<useStrictFiltering>false</useStrictFiltering>
<useTransitiveFiltering>true</useTransitiveFiltering>
+
+ <excludes>
+ <exclude>com.github.xiaoymin:*:jar</exclude>
+ <exclude>io.springfox:*:jar</exclude>
+ <exclude>io.swagger:*:jar</exclude>
+ </excludes>
</dependencySet>
</dependencySets>
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@linkis.apache.org
For additional commands, e-mail: commits-help@linkis.apache.org