Expose swagger.properties to release (#14590)
(cherry picked from commit 8505f1878d)
This commit is contained in:
parent
12511c4e0e
commit
91be4781d3
|
|
@ -30,6 +30,7 @@
|
|||
<includes>
|
||||
<include>*.yaml</include>
|
||||
<include>*.xml</include>
|
||||
<include>swagger.properties</include>
|
||||
</includes>
|
||||
<outputDirectory>conf</outputDirectory>
|
||||
</fileSet>
|
||||
|
|
|
|||
|
|
@ -16,7 +16,11 @@
|
|||
*/
|
||||
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.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
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;
|
||||
|
||||
/**
|
||||
* 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
|
||||
@ConditionalOnWebApplication
|
||||
@PropertySource("classpath:swagger.properties")
|
||||
public class OpenAPIConfiguration implements WebMvcConfigurer {
|
||||
public class SwaggerConfiguration implements WebMvcConfigurer {
|
||||
|
||||
@Autowired
|
||||
private DsVersionDao dsVersionDao;
|
||||
|
||||
private volatile String dsVersion;
|
||||
|
||||
@Bean
|
||||
public OpenAPI apiV1Info1() {
|
||||
return new OpenAPI()
|
||||
.info(new Info()
|
||||
.title("Dolphin Scheduler Api Docs")
|
||||
.description("Dolphin Scheduler Api Docs")
|
||||
.version("V1"));
|
||||
public OpenAPI openAPI() {
|
||||
Info info = new Info()
|
||||
.title("Apache DolphinScheduler Api Docs")
|
||||
.description("Apache DolphinScheduler Api Docs")
|
||||
.version(getDsVersion());
|
||||
return new OpenAPI().info(info);
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
|
@ -58,4 +68,12 @@ public class OpenAPIConfiguration implements WebMvcConfigurer {
|
|||
.pathsToMatch("/v2/**")
|
||||
.build();
|
||||
}
|
||||
|
||||
private String getDsVersion() {
|
||||
if (dsVersion != null) {
|
||||
return dsVersion;
|
||||
}
|
||||
dsVersion = dsVersionDao.selectVersion().map(DsVersion::getVersion).orElse("unknown");
|
||||
return dsVersion;
|
||||
}
|
||||
}
|
||||
|
|
@ -16,3 +16,6 @@
|
|||
#
|
||||
|
||||
springfox.documentation.swagger.v2.path=/api-docs
|
||||
|
||||
# If set to false, will disable swagger-ui
|
||||
springdoc.api-docs.enabled=true
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
}
|
||||
|
|
@ -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> {
|
||||
}
|
||||
|
|
@ -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();
|
||||
|
||||
}
|
||||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
@ -1051,7 +1051,7 @@ CREATE TABLE t_ds_version
|
|||
-- Records of t_ds_version
|
||||
-- ----------------------------
|
||||
INSERT INTO t_ds_version
|
||||
VALUES ('1', '1.4.0');
|
||||
VALUES ('1', 'dev');
|
||||
|
||||
|
||||
-- ----------------------------
|
||||
|
|
|
|||
|
|
@ -1042,7 +1042,7 @@ CREATE TABLE `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');
|
||||
|
||||
|
||||
-- ----------------------------
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
|
||||
-- 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
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
3.0.0
|
||||
dev
|
||||
|
|
|
|||
|
|
@ -112,19 +112,6 @@ security:
|
|||
trust-store: "/ldapkeystore.jks"
|
||||
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:
|
||||
listen-port: 5678
|
||||
|
|
|
|||
Loading…
Reference in New Issue