cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject cxf git commit: [CXF-7464] aligned default values between Java2Swagger plugin and Swagger2Feature, use version from resource package by default
Date Mon, 07 Aug 2017 13:44:00 GMT
Repository: cxf
Updated Branches:
  refs/heads/master 468edbdcb -> ffccaf15e


[CXF-7464] aligned default values between Java2Swagger plugin and Swagger2Feature, use version
from resource package by default


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/ffccaf15
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/ffccaf15
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/ffccaf15

Branch: refs/heads/master
Commit: ffccaf15e88ff8fe5b0c2c94cc7f4897792bb4e7
Parents: 468edbd
Author: Dennis Kieselhorst <deki@apache.org>
Authored: Mon Aug 7 15:43:45 2017 +0200
Committer: Dennis Kieselhorst <deki@apache.org>
Committed: Mon Aug 7 15:43:45 2017 +0200

----------------------------------------------------------------------
 .../src/main/resources/context.xml              |  1 +
 .../src/main/webapp/WEB-INF/context.xml         |  2 ++
 .../rs/service/SampleRestApplication.java       |  6 +++++-
 .../java2swagger/Java2SwaggerMojo.java          | 20 +++++++-------------
 .../jaxrs/swagger/AbstractSwaggerFeature.java   |  8 ++++----
 .../cxf/jaxrs/swagger/Swagger2Customizer.java   | 16 ++++++++++++++++
 6 files changed, 35 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/ffccaf15/distribution/src/main/release/samples/jax_rs/description_swagger2_spring/src/main/resources/context.xml
----------------------------------------------------------------------
diff --git a/distribution/src/main/release/samples/jax_rs/description_swagger2_spring/src/main/resources/context.xml
b/distribution/src/main/release/samples/jax_rs/description_swagger2_spring/src/main/resources/context.xml
index cc4b64f..f25be5e 100644
--- a/distribution/src/main/release/samples/jax_rs/description_swagger2_spring/src/main/resources/context.xml
+++ b/distribution/src/main/release/samples/jax_rs/description_swagger2_spring/src/main/resources/context.xml
@@ -37,6 +37,7 @@
 
     <!-- CXF Swagger2Feature -->  
     <bean id="swagger2Feature" class="org.apache.cxf.jaxrs.swagger.Swagger2Feature">
+        <property name="title" value="Sample REST Application" />
     </bean>
 
     <cxf:bus>

http://git-wip-us.apache.org/repos/asf/cxf/blob/ffccaf15/distribution/src/main/release/samples/jax_rs/description_swagger2_web/src/main/webapp/WEB-INF/context.xml
----------------------------------------------------------------------
diff --git a/distribution/src/main/release/samples/jax_rs/description_swagger2_web/src/main/webapp/WEB-INF/context.xml
b/distribution/src/main/release/samples/jax_rs/description_swagger2_web/src/main/webapp/WEB-INF/context.xml
index ef46430..914329c 100644
--- a/distribution/src/main/release/samples/jax_rs/description_swagger2_web/src/main/webapp/WEB-INF/context.xml
+++ b/distribution/src/main/release/samples/jax_rs/description_swagger2_web/src/main/webapp/WEB-INF/context.xml
@@ -42,6 +42,7 @@
 
     <!-- Swagger2Feature for the first Endpoint -->  
     <bean id="swagger2Feature" class="org.apache.cxf.jaxrs.swagger.Swagger2Feature">
+        <property name="title" value="Sample REST Application"/>
         <property name="usePathBasedConfig" value="true"/>
         <property name="scan" value="false"/>
     </bean>
@@ -65,6 +66,7 @@
 
     <!-- Swagger2Feature for the second Endpoint -->  
     <bean id="swagger2Feature2" class="org.apache.cxf.jaxrs.swagger.Swagger2Feature">
+        <property name="title" value="Sample REST Application"/>
         <property name="usePathBasedConfig" value="true"/>
         <property name="scan" value="false"/>
     </bean>

http://git-wip-us.apache.org/repos/asf/cxf/blob/ffccaf15/distribution/src/main/release/samples/jax_rs/spring_boot/src/main/java/sample/rs/service/SampleRestApplication.java
----------------------------------------------------------------------
diff --git a/distribution/src/main/release/samples/jax_rs/spring_boot/src/main/java/sample/rs/service/SampleRestApplication.java
b/distribution/src/main/release/samples/jax_rs/spring_boot/src/main/java/sample/rs/service/SampleRestApplication.java
index 4d8b54b..0e492e9 100644
--- a/distribution/src/main/release/samples/jax_rs/spring_boot/src/main/java/sample/rs/service/SampleRestApplication.java
+++ b/distribution/src/main/release/samples/jax_rs/spring_boot/src/main/java/sample/rs/service/SampleRestApplication.java
@@ -18,6 +18,7 @@
  */
 package sample.rs.service;
 import java.util.Arrays;
+import java.util.Collections;
 
 import org.apache.cxf.Bus;
 import org.apache.cxf.endpoint.Server;
@@ -46,7 +47,10 @@ public class SampleRestApplication {
         endpoint.setBus(bus);
         endpoint.setServiceBeans(Arrays.<Object>asList(new HelloServiceImpl1(), new
HelloServiceImpl2()));
         endpoint.setAddress("/");
-        endpoint.setFeatures(Arrays.asList(new Swagger2Feature()));
+        Swagger2Feature swagger2Feature = new Swagger2Feature();
+        swagger2Feature.setTitle("Sample REST Application");
+        swagger2Feature.setDescription("The Application");
+        endpoint.setFeatures(Collections.singletonList(swagger2Feature));
         return endpoint.create();
     }
 }

http://git-wip-us.apache.org/repos/asf/cxf/blob/ffccaf15/maven-plugins/java2swagger-plugin/src/main/java/org/apache/cxf/maven_plugin/java2swagger/Java2SwaggerMojo.java
----------------------------------------------------------------------
diff --git a/maven-plugins/java2swagger-plugin/src/main/java/org/apache/cxf/maven_plugin/java2swagger/Java2SwaggerMojo.java
b/maven-plugins/java2swagger-plugin/src/main/java/org/apache/cxf/maven_plugin/java2swagger/Java2SwaggerMojo.java
index 04a2f2b..a585366 100644
--- a/maven-plugins/java2swagger-plugin/src/main/java/org/apache/cxf/maven_plugin/java2swagger/Java2SwaggerMojo.java
+++ b/maven-plugins/java2swagger-plugin/src/main/java/org/apache/cxf/maven_plugin/java2swagger/Java2SwaggerMojo.java
@@ -26,7 +26,6 @@ import java.io.IOException;
 import java.lang.annotation.Annotation;
 import java.net.URL;
 import java.net.URLClassLoader;
-import java.util.ArrayList;
 import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Set;
@@ -93,7 +92,7 @@ public class Java2SwaggerMojo extends AbstractMojo {
     
     
     /**
-     * @parameter default-value="users@cxf.apache.org"
+     * @parameter
      */
     private String contact;
     
@@ -109,7 +108,7 @@ public class Java2SwaggerMojo extends AbstractMojo {
     private String licenseUrl;
     
     /**
-     * @parameter default-value="example.cxf.apache.org:8181"
+     * @parameter
      */
     private String host;
 
@@ -294,22 +293,17 @@ public class Java2SwaggerMojo extends AbstractMojo {
         License swaggerLicense = new License();
         swaggerLicense.name(this.license)
             .url(this.licenseUrl);
-        swaggerContact.email(this.contact)
-            .name("Apache CXF")
-            .url("http://cxf.apache.org/");
+        swaggerContact.name(this.contact);
         info.version(this.version)
             .description(this.description)
             .contact(swaggerContact)
             .license(swaggerLicense)
             .title(this.title);
         swagger.setInfo(info);
-        if (this.schemes == null || this.schemes.size() == 0) {
-            this.schemes = new ArrayList<String>();
-            this.schemes.add("http");
-            this.schemes.add("https");
-        }
-        for (String scheme : this.schemes) {
-            swagger.scheme(Scheme.forValue(scheme));
+        if (this.schemes != null) {
+            for (String scheme : this.schemes) {
+                swagger.scheme(Scheme.forValue(scheme));
+            }
         }
         swagger.setHost(this.host);
         swagger.setBasePath(this.basePath);

http://git-wip-us.apache.org/repos/asf/cxf/blob/ffccaf15/rt/rs/description-swagger/src/main/java/org/apache/cxf/jaxrs/swagger/AbstractSwaggerFeature.java
----------------------------------------------------------------------
diff --git a/rt/rs/description-swagger/src/main/java/org/apache/cxf/jaxrs/swagger/AbstractSwaggerFeature.java
b/rt/rs/description-swagger/src/main/java/org/apache/cxf/jaxrs/swagger/AbstractSwaggerFeature.java
index f7eb778..d5135ae 100644
--- a/rt/rs/description-swagger/src/main/java/org/apache/cxf/jaxrs/swagger/AbstractSwaggerFeature.java
+++ b/rt/rs/description-swagger/src/main/java/org/apache/cxf/jaxrs/swagger/AbstractSwaggerFeature.java
@@ -41,12 +41,12 @@ public abstract class AbstractSwaggerFeature extends AbstractFeature {
     protected boolean runAsFilter;
     private boolean activateOnlyIfJaxrsSupported;
     private String resourcePackage;
-    private String version = "1.0.0";
+    private String version;
     // depending on swagger version basePath is set differently
     private String basePath;
-    private String title = "Sample REST Application";
-    private String description = "The Application";
-    private String contact = "users@cxf.apache.org";
+    private String title;
+    private String description;
+    private String contact;
     private String license = "Apache 2.0 License";
     private String licenseUrl = "http://www.apache.org/licenses/LICENSE-2.0.html";
     private String termsOfServiceUrl;

http://git-wip-us.apache.org/repos/asf/cxf/blob/ffccaf15/rt/rs/description-swagger/src/main/java/org/apache/cxf/jaxrs/swagger/Swagger2Customizer.java
----------------------------------------------------------------------
diff --git a/rt/rs/description-swagger/src/main/java/org/apache/cxf/jaxrs/swagger/Swagger2Customizer.java
b/rt/rs/description-swagger/src/main/java/org/apache/cxf/jaxrs/swagger/Swagger2Customizer.java
index bbfc4b7..8f75df7 100644
--- a/rt/rs/description-swagger/src/main/java/org/apache/cxf/jaxrs/swagger/Swagger2Customizer.java
+++ b/rt/rs/description-swagger/src/main/java/org/apache/cxf/jaxrs/swagger/Swagger2Customizer.java
@@ -49,6 +49,8 @@ public class Swagger2Customizer {
 
     protected boolean replaceTags;
 
+    protected boolean applyDefaultVersion = true;
+
     protected DocumentationProvider javadocProvider;
 
     protected List<ClassResourceInfo> cris;
@@ -137,6 +139,7 @@ public class Swagger2Customizer {
                 }
             });
         }
+        applyDefaultVersion(data);
         return data;
     }
 
@@ -162,6 +165,16 @@ public class Swagger2Customizer {
         return StringUtils.EMPTY.equals(normalizedPath.toString()) ? "/" : normalizedPath.toString();
     }
 
+    protected void applyDefaultVersion(Swagger data) {
+        if (applyDefaultVersion && data.getInfo() != null && data.getInfo().getVersion()
== null
+                && beanConfig != null && beanConfig.getResourcePackage()
!= null) {
+            Package resourcePackage = Package.getPackage(beanConfig.getResourcePackage());
+            if (resourcePackage != null) {
+                data.getInfo().setVersion(resourcePackage.getImplementationVersion());
+            }
+        }
+    }
+
     /**
      * Allows to add parameters to the list, related to an {@link Operation} instance; the
method is invoked
      * for all instances available.
@@ -208,6 +221,9 @@ public class Swagger2Customizer {
 
     public void setBeanConfig(BeanConfig beanConfig) {
         this.beanConfig = beanConfig;
+    }
 
+    public void setApplyDefaultVersion(boolean applyDefaultVersion) {
+        this.applyDefaultVersion = applyDefaultVersion;
     }
 }


Mime
View raw message