You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by dm...@apache.org on 2019/03/20 12:07:25 UTC

[camel] branch camel-2.x updated: CAMEL-13340: Invalid swagger json/yaml generated for Rest DSL

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

dmvolod pushed a commit to branch camel-2.x
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/camel-2.x by this push:
     new 670488a  CAMEL-13340: Invalid swagger json/yaml generated for Rest DSL
670488a is described below

commit 670488abdc43562cc259049cac9ee295a3c9f893
Author: Dmitry Volodin <dm...@gmail.com>
AuthorDate: Wed Mar 20 15:02:20 2019 +0300

    CAMEL-13340: Invalid swagger json/yaml generated for Rest DSL
---
 .../src/main/java/org/apache/camel/swagger/RestSwaggerSupport.java  | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/components/camel-swagger-java/src/main/java/org/apache/camel/swagger/RestSwaggerSupport.java b/components/camel-swagger-java/src/main/java/org/apache/camel/swagger/RestSwaggerSupport.java
index 8348ec1..c0578fe 100644
--- a/components/camel-swagger-java/src/main/java/org/apache/camel/swagger/RestSwaggerSupport.java
+++ b/components/camel-swagger-java/src/main/java/org/apache/camel/swagger/RestSwaggerSupport.java
@@ -31,10 +31,12 @@ import com.fasterxml.jackson.annotation.JsonInclude;
 import com.fasterxml.jackson.databind.JsonNode;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.fasterxml.jackson.databind.SerializationFeature;
+import io.swagger.jackson.mixin.ResponseSchemaMixin;
 import io.swagger.jaxrs.config.BeanConfig;
 import io.swagger.models.Contact;
 import io.swagger.models.Info;
 import io.swagger.models.License;
+import io.swagger.models.Response;
 import io.swagger.models.Scheme;
 import io.swagger.models.Swagger;
 import io.swagger.util.Yaml;
@@ -228,6 +230,8 @@ public class RestSwaggerSupport {
                 ObjectMapper mapper = new ObjectMapper();
                 mapper.enable(SerializationFeature.INDENT_OUTPUT);
                 mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
+                mapper.addMixIn(Response.class, ResponseSchemaMixin.class);
+                
                 byte[] bytes = mapper.writeValueAsBytes(swagger);
 
                 int len = bytes.length;
@@ -250,6 +254,8 @@ public class RestSwaggerSupport {
                 ObjectMapper mapper = new ObjectMapper();
                 mapper.enable(SerializationFeature.INDENT_OUTPUT);
                 mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
+                mapper.addMixIn(Response.class, ResponseSchemaMixin.class);
+                
                 byte[] jsonData = mapper.writeValueAsBytes(swagger);
 
                 // json to yaml