From 7e7ca01aa411ec41301958bf1a7232fe56b6f927 Mon Sep 17 00:00:00 2001 From: Denis Bazhenov Date: Tue, 1 Nov 2016 18:21:30 +1000 Subject: [PATCH] Newline escaping disabled for HTML and HTML2 generators (#4099) * Newline escaping disabled Newline escaping disabled for HTML and HTML2 generators. Escaping failing Markdown processors to work correctly on descriptions * HTML examples updated --- .../languages/StaticHtml2Generator.java | 6 ++ .../languages/StaticHtmlGenerator.java | 6 ++ samples/html/index.html | 88 +++++++++---------- samples/html2/index.html | 2 +- 4 files changed, 57 insertions(+), 45 deletions(-) diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/StaticHtml2Generator.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/StaticHtml2Generator.java index 1979d0c19134..2907c1dfc435 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/StaticHtml2Generator.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/StaticHtml2Generator.java @@ -65,6 +65,12 @@ public class StaticHtml2Generator extends DefaultCodegen implements CodegenConfi return "html2"; } + @Override + public String escapeText(String input) { + // newline escaping disabled for HTML documentation for markdown to work correctly + return input; + } + @Override public String getHelp() { return "Generates a static HTML file."; diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/StaticHtmlGenerator.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/StaticHtmlGenerator.java index 541bf98e6ad9..2fe4cd7b6657 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/StaticHtmlGenerator.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/StaticHtmlGenerator.java @@ -60,6 +60,12 @@ public class StaticHtmlGenerator extends DefaultCodegen implements CodegenConfig importMapping = new HashMap(); } + @Override + public String escapeText(String input) { + // newline escaping disabled for HTML documentation for markdown to work correctly + return input; + } + @Override public CodegenType getTag() { return CodegenType.DOCUMENTATION; diff --git a/samples/html/index.html b/samples/html/index.html index 425b46386d2a..850fa5752d08 100644 --- a/samples/html/index.html +++ b/samples/html/index.html @@ -355,18 +355,18 @@ font-style: italic;

Example data

Content-Type: application/json
[ {
-  "tags" : [ {
-    "id" : 123456789,
-    "name" : "aeiou"
-  } ],
+  "photoUrls" : [ "aeiou" ],
+  "name" : "doggie",
   "id" : 123456789,
   "category" : {
-    "id" : 123456789,
-    "name" : "aeiou"
+    "name" : "aeiou",
+    "id" : 123456789
   },
-  "status" : "aeiou",
-  "name" : "doggie",
-  "photoUrls" : [ "aeiou" ]
+  "tags" : [ {
+    "name" : "aeiou",
+    "id" : 123456789
+  } ],
+  "status" : "aeiou"
 } ]

Produces

@@ -428,18 +428,18 @@ font-style: italic;

Example data

Content-Type: application/json
[ {
-  "tags" : [ {
-    "id" : 123456789,
-    "name" : "aeiou"
-  } ],
+  "photoUrls" : [ "aeiou" ],
+  "name" : "doggie",
   "id" : 123456789,
   "category" : {
-    "id" : 123456789,
-    "name" : "aeiou"
+    "name" : "aeiou",
+    "id" : 123456789
   },
-  "status" : "aeiou",
-  "name" : "doggie",
-  "photoUrls" : [ "aeiou" ]
+  "tags" : [ {
+    "name" : "aeiou",
+    "id" : 123456789
+  } ],
+  "status" : "aeiou"
 } ]

Produces

@@ -501,18 +501,18 @@ font-style: italic;

Example data

Content-Type: application/json
{
-  "tags" : [ {
-    "id" : 123456789,
-    "name" : "aeiou"
-  } ],
+  "photoUrls" : [ "aeiou" ],
+  "name" : "doggie",
   "id" : 123456789,
   "category" : {
-    "id" : 123456789,
-    "name" : "aeiou"
+    "name" : "aeiou",
+    "id" : 123456789
   },
-  "status" : "aeiou",
-  "name" : "doggie",
-  "photoUrls" : [ "aeiou" ]
+  "tags" : [ {
+    "name" : "aeiou",
+    "id" : 123456789
+  } ],
+  "status" : "aeiou"
 }

Produces

@@ -677,9 +677,9 @@ font-style: italic;

Example data

Content-Type: application/json
{
-  "message" : "aeiou",
   "code" : 123,
-  "type" : "aeiou"
+  "type" : "aeiou",
+  "message" : "aeiou"
 }

Produces

@@ -816,12 +816,12 @@ font-style: italic;

Example data

Content-Type: application/json
{
-  "id" : 123456789,
   "petId" : 123456789,
-  "complete" : true,
-  "status" : "aeiou",
   "quantity" : 123,
-  "shipDate" : "2000-01-23T04:56:07.000+00:00"
+  "id" : 123456789,
+  "shipDate" : "2000-01-23T04:56:07.000+00:00",
+  "complete" : true,
+  "status" : "aeiou"
 }

Produces

@@ -884,12 +884,12 @@ font-style: italic;

Example data

Content-Type: application/json
{
-  "id" : 123456789,
   "petId" : 123456789,
-  "complete" : true,
-  "status" : "aeiou",
   "quantity" : 123,
-  "shipDate" : "2000-01-23T04:56:07.000+00:00"
+  "id" : 123456789,
+  "shipDate" : "2000-01-23T04:56:07.000+00:00",
+  "complete" : true,
+  "status" : "aeiou"
 }

Produces

@@ -1103,14 +1103,14 @@ font-style: italic;

Example data

Content-Type: application/json
{
-  "id" : 123456789,
-  "lastName" : "aeiou",
-  "phone" : "aeiou",
-  "username" : "aeiou",
-  "email" : "aeiou",
-  "userStatus" : 123,
   "firstName" : "aeiou",
-  "password" : "aeiou"
+  "lastName" : "aeiou",
+  "password" : "aeiou",
+  "userStatus" : 123,
+  "phone" : "aeiou",
+  "id" : 123456789,
+  "email" : "aeiou",
+  "username" : "aeiou"
 }

Produces

diff --git a/samples/html2/index.html b/samples/html2/index.html index f454250971ef..d9fba0bb5e54 100644 --- a/samples/html2/index.html +++ b/samples/html2/index.html @@ -9941,7 +9941,7 @@ try {
- Generated 2016-10-17T21:36:47.443+11:00 + Generated 2016-10-29T22:48:30.116+11:00