[cxf] branch 3.1.x-fixes updated: [CXF-7637] Support for 'discriminator'

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[cxf] branch 3.1.x-fixes updated: [CXF-7637] Support for 'discriminator'

ilgrosso
This is an automated email from the ASF dual-hosted git repository.

ilgrosso pushed a commit to branch 3.1.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git


The following commit(s) were added to refs/heads/3.1.x-fixes by this push:
     new 26fb2ed  [CXF-7637] Support for 'discriminator'
26fb2ed is described below

commit 26fb2ed79a78c46503330b2f115ef1b0f72a4974
Author: Francesco Chicchiriccò <[hidden email]>
AuthorDate: Tue Feb 13 22:25:27 2018 +0100

    [CXF-7637] Support for 'discriminator'
---
 .../swagger/openapi/SwaggerToOpenApiConversionUtils.java   | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/rt/rs/description-swagger/src/main/java/org/apache/cxf/jaxrs/swagger/openapi/SwaggerToOpenApiConversionUtils.java b/rt/rs/description-swagger/src/main/java/org/apache/cxf/jaxrs/swagger/openapi/SwaggerToOpenApiConversionUtils.java
index 611b9ac..f5358b6 100644
--- a/rt/rs/description-swagger/src/main/java/org/apache/cxf/jaxrs/swagger/openapi/SwaggerToOpenApiConversionUtils.java
+++ b/rt/rs/description-swagger/src/main/java/org/apache/cxf/jaxrs/swagger/openapi/SwaggerToOpenApiConversionUtils.java
@@ -139,8 +139,20 @@ public final class SwaggerToOpenApiConversionUtils {
         }
         comps.setProperty("requestBodies", requestBodiesObj);
         
-        Object s2Defs = sw2.getProperty("definitions");
+        JsonMapObject s2Defs = sw2.getJsonMapProperty("definitions");
         if (s2Defs != null) {
+            for (Object schema : s2Defs.asMap().values()) {
+                if (schema instanceof Map) {
+                    @SuppressWarnings("unchecked")
+                    Map<String, Object> schemaMap = (Map<String, Object>) schema;
+                    Object discriminator = schemaMap.get("discriminator");
+                    if (discriminator != null) {
+                        schemaMap.put("discriminator", new JsonMapObject(
+                                Collections.singletonMap("propertyName", discriminator)));
+                    }
+                }
+            }
+            
             comps.setProperty("schemas", s2Defs);
         }
         JsonMapObject s2SecurityDefs = sw2.getJsonMapProperty("securityDefinitions");

--
To stop receiving notification emails like this one, please contact
[hidden email].