camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [2/3] camel git commit: CAMEL-7800: camel-swagger-java - work in progress
Date Fri, 18 Sep 2015 13:42:49 GMT
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/9bfc912d
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/9bfc912d
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/9bfc912d

Branch: refs/heads/swagger
Commit: 9bfc912d871bfd1d0dd7b252340a637194d31b22
Parents: 3e0fb3c
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Fri Sep 18 15:37:03 2015 +0200
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Fri Sep 18 15:37:03 2015 +0200

----------------------------------------------------------------------
 .../org/apache/camel/swagger/RestSwaggerReader.java    | 13 +++++++++++++
 1 file changed, 13 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/9bfc912d/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 fcfb057..ae9c46f 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
@@ -33,6 +33,7 @@ import io.swagger.models.Path;
 import io.swagger.models.RefModel;
 import io.swagger.models.Response;
 import io.swagger.models.Swagger;
+import io.swagger.models.Tag;
 import io.swagger.models.parameters.BodyParameter;
 import io.swagger.models.parameters.FormParameter;
 import io.swagger.models.parameters.HeaderParameter;
@@ -50,6 +51,7 @@ import org.apache.camel.model.rest.RestOperationResponseMsgDefinition;
 import org.apache.camel.model.rest.RestParamType;
 import org.apache.camel.model.rest.VerbDefinition;
 import org.apache.camel.spi.ClassResolver;
+import org.apache.camel.util.FileUtil;
 import org.apache.camel.util.ObjectHelper;
 
 /**
@@ -91,6 +93,15 @@ public class RestSwaggerReader {
         // must sort the verbs by uri so we group them together when an uri has multiple
operations
         Collections.sort(verbs, new VerbOrdering());
 
+        String pathAsTag = FileUtil.stripLeadingSeparator(rest.getPath());
+        String summary = rest.getDescriptionText();
+
+        // add rest as tag
+        Tag tag = new Tag();
+        tag.description(summary);
+        tag.name(pathAsTag);
+        swagger.addTag(tag);
+
         // gather all types in use
         Set<String> types = new LinkedHashSet<>();
         for (VerbDefinition verb : verbs) {
@@ -129,6 +140,8 @@ public class RestSwaggerReader {
             String opPath = SwaggerHelper.buildUrl(basePath, verb.getUri());
 
             Operation op = new Operation();
+            // group in the same tag
+            op.addTag(pathAsTag);
 
             Path path = swagger.getPath(opPath);
             if (path == null) {


Mime
View raw message