From b0d2d1116b8160af6a3810403b04579d20b1b04e Mon Sep 17 00:00:00 2001 From: Nadezhda Makarkina Date: Mon, 27 Apr 2015 13:25:08 +0300 Subject: [PATCH] Generation of operations with multiple tags has been fixed #356 --- .../codegen/languages/StaticHtmlGenerator.java | 18 ++++++++++++++++++ .../src/main/resources/htmlDocs/index.mustache | 1 + .../main/resources/htmlDocs/style.css.mustache | 15 +++++++++++++++ 3 files changed, 34 insertions(+) diff --git a/modules/swagger-codegen/src/main/java/com/wordnik/swagger/codegen/languages/StaticHtmlGenerator.java b/modules/swagger-codegen/src/main/java/com/wordnik/swagger/codegen/languages/StaticHtmlGenerator.java index b4e46bd175f..7186f24a0e0 100644 --- a/modules/swagger-codegen/src/main/java/com/wordnik/swagger/codegen/languages/StaticHtmlGenerator.java +++ b/modules/swagger-codegen/src/main/java/com/wordnik/swagger/codegen/languages/StaticHtmlGenerator.java @@ -1,6 +1,7 @@ package com.wordnik.swagger.codegen.languages; import com.wordnik.swagger.codegen.*; +import com.wordnik.swagger.models.Operation; import com.wordnik.swagger.models.properties.*; import com.wordnik.swagger.util.Json; @@ -8,6 +9,7 @@ import java.util.*; import java.io.File; public class StaticHtmlGenerator extends DefaultCodegen implements CodegenConfig { + private static final String ALL_OPERATIONS = ""; protected String invokerPackage = "com.wordnik.client"; protected String groupId = "com.wordnik"; protected String artifactId = "swagger-client"; @@ -76,4 +78,20 @@ public class StaticHtmlGenerator extends DefaultCodegen implements CodegenConfig } return objs; } + + @Override + public void addOperationToGroup(String tag, String resourcePath, Operation operation, CodegenOperation co, Map> operations) { + List opList = operations.get(ALL_OPERATIONS); + if(opList == null) { + opList = new ArrayList(); + operations.put(ALL_OPERATIONS, opList); + } + for (CodegenOperation addedOperation: opList){ + if (addedOperation.operationId.equals(co.operationId) && addedOperation.path.equals(co.path) && addedOperation.httpMethod.equals(co.httpMethod)) { + addedOperation.tags.addAll(co.tags); + return; + } + } + opList.add(co); + } } \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/htmlDocs/index.mustache b/modules/swagger-codegen/src/main/resources/htmlDocs/index.mustache index 8e228257951..3f74c63de3b 100644 --- a/modules/swagger-codegen/src/main/resources/htmlDocs/index.mustache +++ b/modules/swagger-codegen/src/main/resources/htmlDocs/index.mustache @@ -20,6 +20,7 @@ {{#operations}}{{#operation}}
{{httpMethod}}: {{path}}
+
{{#tags}}{{this}}{{/tags}}
{{nickname}} {{summary}}
{{notes}}
diff --git a/modules/swagger-codegen/src/main/resources/htmlDocs/style.css.mustache b/modules/swagger-codegen/src/main/resources/htmlDocs/style.css.mustache index 0421bcc8c3c..14ab06a7f7e 100644 --- a/modules/swagger-codegen/src/main/resources/htmlDocs/style.css.mustache +++ b/modules/swagger-codegen/src/main/resources/htmlDocs/style.css.mustache @@ -54,6 +54,7 @@ hr { pre { padding: 10px; + margin-bottom: 2px; } pre.get { @@ -134,3 +135,17 @@ code { .param-header { font-weight: bold; } + +.method-tags { + text-align: right; +} + +.method-tag { + background: none repeat scroll 0% 0% #24A600; + border-radius: 3px; + padding: 2px 10px; + margin: 2px; + color: #FFF; + display: inline-block; + text-decoration: none; +} \ No newline at end of file