From 4decc1a2736fdc7c919f958bbe9c2efca22262b8 Mon Sep 17 00:00:00 2001 From: Malachi Jones Date: Thu, 7 Mar 2019 10:38:26 +0000 Subject: [PATCH] [HTML2] Rendered docs are incomplete - Simple aliased types are now passed to the generator - Body parameters are now provided with their schemas - Schema block is now visibile in the generated documentation --- .../openapitools/codegen/DefaultCodegen.java | 4 +- .../codegen/DefaultGenerator.java | 12 +- .../main/resources/htmlDocs2/index.mustache | 36 +- .../main/resources/htmlDocs2/paramB.mustache | 6 +- .../html2/.openapi-generator/VERSION | 2 +- samples/documentation/html2/index.html | 668 +++++++++++------- 6 files changed, 470 insertions(+), 258 deletions(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java index acb24f48f361..6fa2e8aa0fc3 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java @@ -4947,7 +4947,9 @@ public CodegenParameter fromRequestBody(RequestBody body, Set imports, S // set nullable setParameterNullable(codegenParameter, codegenProperty); } - + // Adding JsonSchema for body request in case that is not present. + if(codegenParameter.jsonSchema == null) + codegenParameter.jsonSchema = Json.pretty(body); // set the parameter's example value // should be overridden by lang codegen setParameterExampleValue(codegenParameter, body); diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java index 8e1e40d79f3c..996d91fe6aa4 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java @@ -488,12 +488,12 @@ private Model getParent(Model model) { // TODO revise below as we've already performed unaliasing so that the isAlias check may be removed Map modelTemplate = (Map) ((List) models.get("models")).get(0); // Special handling of aliases only applies to Java - if (modelTemplate != null && modelTemplate.containsKey("model")) { - CodegenModel m = (CodegenModel) modelTemplate.get("model"); - if (m.isAlias) { - continue; // Don't create user-defined classes for aliases - } - } + // if (modelTemplate != null && modelTemplate.containsKey("model")) { + // CodegenModel m = (CodegenModel) modelTemplate.get("model"); + // if (m.isAlias) { + // continue; // Don't create user-defined classes for aliases + // } + // } allModels.add(modelTemplate); diff --git a/modules/openapi-generator/src/main/resources/htmlDocs2/index.mustache b/modules/openapi-generator/src/main/resources/htmlDocs2/index.mustache index 577ab978d2b1..0ad5141f852b 100644 --- a/modules/openapi-generator/src/main/resources/htmlDocs2/index.mustache +++ b/modules/openapi-generator/src/main/resources/htmlDocs2/index.mustache @@ -101,6 +101,33 @@ //Convert elements with "marked" class to markdown processMarked(); }); + + function findNode(id, currentNode) { + var currentChild, + result; + + if ( Object.keys(currentNode)[0] == id) { + return currentNode; + } else { + // Use a for loop instead of forEach to avoid nested functions + // Otherwise "return" will not work properly + for(var propt in currentNode){ + currentChild = currentNode[propt] + if (id == propt) { + return currentChild; + } else { + // Search in the current child + if (typeof(currentNode[propt]) === 'object') { + result = findNode(id, currentChild); + if (result != false) + return result; + } + } + } + // The node has not been found and we have no more options + return false; + } + }