You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by mi...@apache.org on 2018/10/17 07:44:08 UTC
[incubator-dubbo-ops] branch develop updated: add swagger support
This is an automated email from the ASF dual-hosted git repository.
min pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/incubator-dubbo-ops.git
The following commit(s) were added to refs/heads/develop by this push:
new 755f6d9 add swagger support
755f6d9 is described below
commit 755f6d9138f7efc059fd389f64f65d6b2c67648d
Author: nzomkxia <z8...@gmail.com>
AuthorDate: Wed Oct 17 15:43:57 2018 +0800
add swagger support
---
dubbo-admin-backend/pom.xml | 9 ++++
.../apache/dubbo/admin/SwaggerConfiguration.java | 50 ++++++++++++++++++++++
pom.xml | 14 +++++-
3 files changed, 72 insertions(+), 1 deletion(-)
diff --git a/dubbo-admin-backend/pom.xml b/dubbo-admin-backend/pom.xml
index 6681321..1293667 100644
--- a/dubbo-admin-backend/pom.xml
+++ b/dubbo-admin-backend/pom.xml
@@ -71,6 +71,15 @@
<artifactId>snakeyaml</artifactId>
</dependency>
+ <dependency>
+ <groupId>io.springfox</groupId>
+ <artifactId>springfox-swagger2</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>io.springfox</groupId>
+ <artifactId>springfox-swagger-ui</artifactId>
+ </dependency>
+
</dependencies>
<build>
diff --git a/dubbo-admin-backend/src/main/java/org/apache/dubbo/admin/SwaggerConfiguration.java b/dubbo-admin-backend/src/main/java/org/apache/dubbo/admin/SwaggerConfiguration.java
new file mode 100644
index 0000000..2a416ec
--- /dev/null
+++ b/dubbo-admin-backend/src/main/java/org/apache/dubbo/admin/SwaggerConfiguration.java
@@ -0,0 +1,50 @@
+/*
+ * 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.dubbo.admin;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import springfox.documentation.builders.ApiInfoBuilder;
+import springfox.documentation.builders.PathSelectors;
+import springfox.documentation.builders.RequestHandlerSelectors;
+import springfox.documentation.service.ApiInfo;
+import springfox.documentation.spi.DocumentationType;
+import springfox.documentation.spring.web.plugins.Docket;
+import springfox.documentation.swagger2.annotations.EnableSwagger2;
+
+@Configuration
+@EnableSwagger2
+public class SwaggerConfiguration {
+ @Bean
+ public Docket createRestApi() {
+ return new Docket(DocumentationType.SWAGGER_2)
+ .apiInfo(apiInfo())
+ .select()
+ .apis(RequestHandlerSelectors.basePackage("org.apache.dubbo.admin.controller"))
+ .paths(PathSelectors.any())
+ .build();
+ }
+
+ private ApiInfo apiInfo() {
+ return new ApiInfoBuilder()
+ .title("dubbo ops swagger api")
+ .description("for more information please visit github page: https://github.com/apache/incubator-dubbo-ops")
+ .version("1.0")
+ .build();
+ }
+}
diff --git a/pom.xml b/pom.xml
index e18be9b..e3fa4b4 100644
--- a/pom.xml
+++ b/pom.xml
@@ -42,10 +42,11 @@
<properties>
<main.basedir>${project.basedir}</main.basedir>
<commons-lang3-version>3.7</commons-lang3-version>
- <dubbo-version>2.6.2</dubbo-version>
+ <dubbo-version>2.6.4</dubbo-version>
<curator-version>2.12.0</curator-version>
<fastjson-version>1.2.46</fastjson-version>
<snakeyaml-version>1.22</snakeyaml-version>
+ <springfox-swagger-version>2.9.2</springfox-swagger-version>
</properties>
<dependencyManagement>
@@ -79,6 +80,17 @@
<version>${snakeyaml-version}</version>
</dependency>
+ <dependency>
+ <groupId>io.springfox</groupId>
+ <artifactId>springfox-swagger2</artifactId>
+ <version>${springfox-swagger-version}</version>
+ </dependency>
+ <dependency>
+ <groupId>io.springfox</groupId>
+ <artifactId>springfox-swagger-ui</artifactId>
+ <version>${springfox-swagger-version}</version>
+ </dependency>
+
</dependencies>
</dependencyManagement>