camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject camel git commit: CAMEL-7800: camel-swagger-java - work in progress
Date Fri, 18 Sep 2015 10:43:26 GMT
Repository: camel
Updated Branches:
  refs/heads/swagger c4a4d5341 -> 5b5b834b4


CAMEL-7800: camel-swagger-java - work in progress


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

Branch: refs/heads/swagger
Commit: 5b5b834b417de069047791a941d44971d1527b86
Parents: c4a4d53
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Fri Sep 18 12:44:44 2015 +0200
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Fri Sep 18 12:44:44 2015 +0200

----------------------------------------------------------------------
 .../main/java/org/apache/camel/swagger/RestSwaggerReader.java | 5 ++++-
 .../org/apache/camel/swagger/RestSwaggerReaderModelTest.java  | 7 ++++++-
 .../camel-swagger-java/src/test/resources/log4j.properties    | 2 +-
 3 files changed, 11 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/5b5b834b/components/camel-swagger-java/src/main/java/org/apache/camel/swagger/RestSwaggerReader.java
----------------------------------------------------------------------
diff --git a/components/camel-swagger-java/src/main/java/org/apache/camel/swagger/RestSwaggerReader.java
b/components/camel-swagger-java/src/main/java/org/apache/camel/swagger/RestSwaggerReader.java
index 90f5956..a83c03d 100644
--- a/components/camel-swagger-java/src/main/java/org/apache/camel/swagger/RestSwaggerReader.java
+++ b/components/camel-swagger-java/src/main/java/org/apache/camel/swagger/RestSwaggerReader.java
@@ -190,7 +190,10 @@ public class RestSwaggerReader {
             }
 
             for (RestOperationResponseMsgDefinition msg : verb.getResponseMsgs()) {
-                Response response = new Response();
+                Response response = op.getResponses().get("" + msg.getCode());
+                if (response == null) {
+                    response = new Response();
+                }
                 response.setDescription(msg.getMessage());
                 op.addResponse("" + msg.getCode(), response);
             }

http://git-wip-us.apache.org/repos/asf/camel/blob/5b5b834b/components/camel-swagger-java/src/test/java/org/apache/camel/swagger/RestSwaggerReaderModelTest.java
----------------------------------------------------------------------
diff --git a/components/camel-swagger-java/src/test/java/org/apache/camel/swagger/RestSwaggerReaderModelTest.java
b/components/camel-swagger-java/src/test/java/org/apache/camel/swagger/RestSwaggerReaderModelTest.java
index d899613..301421f 100644
--- a/components/camel-swagger-java/src/test/java/org/apache/camel/swagger/RestSwaggerReaderModelTest.java
+++ b/components/camel-swagger-java/src/test/java/org/apache/camel/swagger/RestSwaggerReaderModelTest.java
@@ -48,6 +48,7 @@ public class RestSwaggerReaderModelTest extends CamelTestSupport {
                     .consumes("application/json").produces("application/json")
 
                     .get("/{id}").description("Find user by id").outType(User.class)
+                        .responseMessage().message("The user returned").endResponseMessage()
                         .param().name("id").type(RestParamType.path).description("The id
of the user to get").dataType("integer").endParam()
                         .to("bean:userService?method=getUser(${header.id})")
 
@@ -56,6 +57,7 @@ public class RestSwaggerReaderModelTest extends CamelTestSupport {
                         .to("bean:userService?method=updateUser")
 
                     .get("/findAll").description("Find all users").outTypeList(User.class)
+                        .responseMessage().message("All the found users").endResponseMessage()
                         .to("bean:userService?method=listUsers");
             }
         };
@@ -70,6 +72,9 @@ public class RestSwaggerReaderModelTest extends CamelTestSupport {
         config.setHost("localhost:8080");
         config.setSchemes(new String[]{"http"});
         config.setBasePath("/api");
+        config.setTitle("Camel User store");
+        config.setLicense("Apache 2.0");
+        config.setLicenseUrl("http://www.apache.org/licenses/LICENSE-2.0.html");
         RestSwaggerReader reader = new RestSwaggerReader();
 
         Swagger swagger = reader.read(rest, config, new DefaultClassResolver());
@@ -83,7 +88,7 @@ public class RestSwaggerReaderModelTest extends CamelTestSupport {
         log.info(json);
 
         assertTrue(json.contains("\"host\" : \"localhost:8080\""));
-        assertTrue(json.contains("\"description\" : \"Output type\""));
+        assertTrue(json.contains("\"description\" : \"The user returned\""));
         assertTrue(json.contains("\"$ref\" : \"#/definitions/User\""));
         assertTrue(json.contains("\"x-className\""));
         assertTrue(json.contains("\"format\" : \"org.apache.camel.swagger.User\""));

http://git-wip-us.apache.org/repos/asf/camel/blob/5b5b834b/components/camel-swagger-java/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/components/camel-swagger-java/src/test/resources/log4j.properties b/components/camel-swagger-java/src/test/resources/log4j.properties
index e5d9b29..6e040b0 100644
--- a/components/camel-swagger-java/src/test/resources/log4j.properties
+++ b/components/camel-swagger-java/src/test/resources/log4j.properties
@@ -18,7 +18,7 @@
 #
 # The logging properties used for testing.
 #
-log4j.rootLogger=INFO, out
+log4j.rootLogger=INFO, file
 
 # uncomment the following to enable camel debugging
 #log4j.logger.org.apache.camel.swagger=TRACE


Mime
View raw message