You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by se...@apache.org on 2017/08/30 14:28:53 UTC

cxf git commit: Making sure Swagger2Feature setLicense(null) still works

Repository: cxf
Updated Branches:
  refs/heads/master 76145af39 -> df0c72713


Making sure Swagger2Feature setLicense(null) still works


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

Branch: refs/heads/master
Commit: df0c727132630165ff2c58d93c1f0cfc7eb68a4c
Parents: 76145af
Author: Sergey Beryozkin <sb...@gmail.com>
Authored: Wed Aug 30 15:28:33 2017 +0100
Committer: Sergey Beryozkin <sb...@gmail.com>
Committed: Wed Aug 30 15:28:33 2017 +0100

----------------------------------------------------------------------
 .../jaxrs/swagger/AbstractSwaggerFeature.java   |  2 ++
 .../cxf/jaxrs/swagger/Swagger2Feature.java      | 28 ++++++++++----------
 2 files changed, 16 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/df0c7271/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 e1da558..a2f9a4c 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
@@ -37,6 +37,7 @@ public abstract class AbstractSwaggerFeature extends AbstractFeature {
         SWAGGER_JAXRS_AVAILABLE = isSwaggerJaxRsAvailable();
     }
 
+    protected boolean licenseWasSet;
     private boolean runAsFilter;
     private boolean activateOnlyIfJaxrsSupported;
     private String resourcePackage;
@@ -144,6 +145,7 @@ public abstract class AbstractSwaggerFeature extends AbstractFeature {
         return license;
     }
     public void setLicense(String license) {
+        this.licenseWasSet = true;
         this.license = license;
     }
     public String getLicenseUrl() {

http://git-wip-us.apache.org/repos/asf/cxf/blob/df0c7271/rt/rs/description-swagger/src/main/java/org/apache/cxf/jaxrs/swagger/Swagger2Feature.java
----------------------------------------------------------------------
diff --git a/rt/rs/description-swagger/src/main/java/org/apache/cxf/jaxrs/swagger/Swagger2Feature.java b/rt/rs/description-swagger/src/main/java/org/apache/cxf/jaxrs/swagger/Swagger2Feature.java
index d27551b..eab36a6 100644
--- a/rt/rs/description-swagger/src/main/java/org/apache/cxf/jaxrs/swagger/Swagger2Feature.java
+++ b/rt/rs/description-swagger/src/main/java/org/apache/cxf/jaxrs/swagger/Swagger2Feature.java
@@ -285,24 +285,24 @@ public class Swagger2Feature extends AbstractSwaggerFeature {
         
         // license
         String theLicense = getLicense();
-        if (theLicense == null && props != null) {
-            theLicense = props.getProperty(LICENSE_PROPERTY);
-        }
-        if (theLicense == null) {
-            theLicense = DEFAULT_LICENSE_VALUE;
-        } else if (theLicense.isEmpty()) {
-            theLicense = null;
+        if (theLicense == null && !licenseWasSet) {
+            if (props != null) {
+                theLicense = props.getProperty(LICENSE_PROPERTY);
+                if (theLicense.isEmpty()) {
+                    theLicense = null;
+                }
+            } else {
+                theLicense = DEFAULT_LICENSE_VALUE;
+            }
         }
         beanConfig.setLicense(theLicense);
         
         // license url
-        String theLicenseUrl = null;
-        if (!DEFAULT_LICENSE_VALUE.equals(theLicense)) {
-            theLicenseUrl = getLicenseUrl();
-            if (theLicenseUrl == null && props != null) {
-                theLicenseUrl = props.getProperty(LICENSE_URL_PROPERTY);
-            }
-        } else {
+        String theLicenseUrl = getLicenseUrl();
+        if (theLicenseUrl == null && props != null) {
+            theLicenseUrl = props.getProperty(LICENSE_URL_PROPERTY);
+        }
+        if (theLicenseUrl == null && DEFAULT_LICENSE_VALUE.equals(theLicense)) {
             theLicenseUrl = DEFAULT_LICENSE_URL;
         }
         beanConfig.setLicenseUrl(theLicenseUrl);