Browse Source

Expose swagger.properties to release (#14590)

3.2.1-prepare
Wenjun Ruan 1 year ago committed by GitHub
parent
commit
8505f1878d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      dolphinscheduler-api/src/main/assembly/dolphinscheduler-api-server.xml
  2. 34
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/configuration/SwaggerConfiguration.java
  3. 3
      dolphinscheduler-api/src/main/resources/swagger.properties
  4. 35
      dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/DsVersion.java
  5. 25
      dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/DsVersionMapper.java
  6. 28
      dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/repository/DsVersionDao.java
  7. 54
      dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/repository/impl/DsVersionDaoImpl.java
  8. 2
      dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_h2.sql
  9. 2
      dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_mysql.sql
  10. 2
      dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_postgresql.sql
  11. 2
      dolphinscheduler-dao/src/main/resources/sql/soft_version
  12. 13
      dolphinscheduler-standalone-server/src/main/resources/application.yaml

1
dolphinscheduler-api/src/main/assembly/dolphinscheduler-api-server.xml

@ -30,6 +30,7 @@
<includes> <includes>
<include>*.yaml</include> <include>*.yaml</include>
<include>*.xml</include> <include>*.xml</include>
<include>swagger.properties</include>
</includes> </includes>
<outputDirectory>conf</outputDirectory> <outputDirectory>conf</outputDirectory>
</fileSet> </fileSet>

34
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/configuration/OpenAPIConfiguration.java → dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/configuration/SwaggerConfiguration.java

@ -16,7 +16,11 @@
*/ */
package org.apache.dolphinscheduler.api.configuration; package org.apache.dolphinscheduler.api.configuration;
import org.apache.dolphinscheduler.dao.entity.DsVersion;
import org.apache.dolphinscheduler.dao.repository.DsVersionDao;
import org.springdoc.core.GroupedOpenApi; import org.springdoc.core.GroupedOpenApi;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication; import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
@ -27,20 +31,26 @@ import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Info; import io.swagger.v3.oas.models.info.Info;
/** /**
* swager2 config class * Swagger configuration, only enabled when the configuration item api.swagger.enable is true.
* The swagger ui is under <a href="http://${host}:${port}/dolphinscheduler/swagger-ui.html">http://${host}:${port}/dolphinscheduler/swagger-ui.html</a>
*/ */
@Configuration @Configuration
@ConditionalOnWebApplication @ConditionalOnWebApplication
@PropertySource("classpath:swagger.properties") @PropertySource("classpath:swagger.properties")
public class OpenAPIConfiguration implements WebMvcConfigurer { public class SwaggerConfiguration implements WebMvcConfigurer {
@Autowired
private DsVersionDao dsVersionDao;
private volatile String dsVersion;
@Bean @Bean
public OpenAPI apiV1Info1() { public OpenAPI openAPI() {
return new OpenAPI() Info info = new Info()
.info(new Info() .title("Apache DolphinScheduler Api Docs")
.title("Dolphin Scheduler Api Docs") .description("Apache DolphinScheduler Api Docs")
.description("Dolphin Scheduler Api Docs") .version(getDsVersion());
.version("V1")); return new OpenAPI().info(info);
} }
@Bean @Bean
@ -58,4 +68,12 @@ public class OpenAPIConfiguration implements WebMvcConfigurer {
.pathsToMatch("/v2/**") .pathsToMatch("/v2/**")
.build(); .build();
} }
private String getDsVersion() {
if (dsVersion != null) {
return dsVersion;
}
dsVersion = dsVersionDao.selectVersion().map(DsVersion::getVersion).orElse("unknown");
return dsVersion;
}
} }

3
dolphinscheduler-api/src/main/resources/swagger.properties

@ -16,3 +16,6 @@
# #
springfox.documentation.swagger.v2.path=/api-docs springfox.documentation.swagger.v2.path=/api-docs
# If set to false, will disable swagger-ui
springdoc.api-docs.enabled=true

35
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/DsVersion.java

@ -0,0 +1,35 @@
/*
* 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.
*/
package org.apache.dolphinscheduler.dao.entity;
import lombok.Data;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
@Data
@TableName("t_ds_version")
public class DsVersion {
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
private String version;
}

25
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/DsVersionMapper.java

@ -0,0 +1,25 @@
/*
* 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.
*/
package org.apache.dolphinscheduler.dao.mapper;
import org.apache.dolphinscheduler.dao.entity.DsVersion;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
public interface DsVersionMapper extends BaseMapper<DsVersion> {
}

28
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/repository/DsVersionDao.java

@ -0,0 +1,28 @@
/*
* 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.
*/
package org.apache.dolphinscheduler.dao.repository;
import org.apache.dolphinscheduler.dao.entity.DsVersion;
import java.util.Optional;
public interface DsVersionDao extends IDao<DsVersion> {
Optional<DsVersion> selectVersion();
}

54
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/repository/impl/DsVersionDaoImpl.java

@ -0,0 +1,54 @@
/*
* 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.
*/
package org.apache.dolphinscheduler.dao.repository.impl;
import org.apache.dolphinscheduler.dao.entity.DsVersion;
import org.apache.dolphinscheduler.dao.mapper.DsVersionMapper;
import org.apache.dolphinscheduler.dao.repository.BaseDao;
import org.apache.dolphinscheduler.dao.repository.DsVersionDao;
import org.apache.commons.collections4.CollectionUtils;
import java.util.List;
import java.util.Optional;
import lombok.NonNull;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Repository;
@Slf4j
@Repository
public class DsVersionDaoImpl extends BaseDao<DsVersion, DsVersionMapper> implements DsVersionDao {
public DsVersionDaoImpl(@NonNull DsVersionMapper dsVersionMapper) {
super(dsVersionMapper);
}
@Override
public Optional<DsVersion> selectVersion() {
List<DsVersion> dsVersions = mybatisMapper.selectList(null);
if (CollectionUtils.isEmpty(dsVersions)) {
log.info("There is no version information in the database");
}
if (dsVersions.size() > 1) {
log.info("There are multiple version information in the database");
}
return dsVersions.stream().findFirst();
}
}

2
dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_h2.sql

@ -1051,7 +1051,7 @@ CREATE TABLE t_ds_version
-- Records of t_ds_version -- Records of t_ds_version
-- ---------------------------- -- ----------------------------
INSERT INTO t_ds_version INSERT INTO t_ds_version
VALUES ('1', '1.4.0'); VALUES ('1', 'dev');
-- ---------------------------- -- ----------------------------

2
dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_mysql.sql

@ -1042,7 +1042,7 @@ CREATE TABLE `t_ds_version` (
-- ---------------------------- -- ----------------------------
-- Records of t_ds_version -- Records of t_ds_version
-- ---------------------------- -- ----------------------------
INSERT IGNORE INTO `t_ds_version` VALUES ('1', '2.0.2'); INSERT IGNORE INTO `t_ds_version` VALUES ('1', 'dev');
-- ---------------------------- -- ----------------------------

2
dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_postgresql.sql

@ -1040,7 +1040,7 @@ INSERT INTO t_ds_queue(queue_name, queue, create_time, update_time)
VALUES ('default', 'default', '2018-11-29 10:22:33', '2018-11-29 10:22:33'); VALUES ('default', 'default', '2018-11-29 10:22:33', '2018-11-29 10:22:33');
-- Records of t_ds_queue,default queue name : default -- Records of t_ds_queue,default queue name : default
INSERT INTO t_ds_version(version) VALUES ('1.4.0'); INSERT INTO t_ds_version(version) VALUES ('dev');
-- --
-- Table structure for table t_ds_plugin_define -- Table structure for table t_ds_plugin_define

2
dolphinscheduler-dao/src/main/resources/sql/soft_version

@ -1 +1 @@
3.0.0 dev

13
dolphinscheduler-standalone-server/src/main/resources/application.yaml

@ -112,19 +112,6 @@ security:
trust-store: "/ldapkeystore.jks" trust-store: "/ldapkeystore.jks"
trust-store-password: "" trust-store-password: ""
# Traffic control, if you turn on this config, the maximum number of request/s will be limited.
# global max request number per second
# default tenant-level max request number
traffic:
control:
global-switch: false
max-global-qps-rate: 300
tenant-switch: false
default-tenant-qps-rate: 10
#customize-tenant-qps-rate:
# eg.
#tenant1: 11
#tenant2: 20
master: master:
listen-port: 5678 listen-port: 5678

Loading…
Cancel
Save