Skip to content

Commit cb4b03f

Browse files
[Core, HTML2] Rendered docs are incomplete (#7510)
Co-authored-by: Malachi Jones <[email protected]>
1 parent f608803 commit cb4b03f

File tree

9 files changed

+726
-601
lines changed

9 files changed

+726
-601
lines changed

modules/openapi-generator/src/main/resources/htmlDocs2/index.mustache

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -103,29 +103,34 @@
103103
});
104104
105105
function findNode(id, currentNode) {
106-
return (Object.keys(currentNode)[0] === id) ? currentNode : findNodeInChildren(id, currentNode);
107-
}
108-
109-
function findNodeInChildren(id, currentNode) {
110-
for (let prop in currentNode) {
111-
if (currentNode.hasOwnProperty(prop)) {
112-
let currentChild = currentNode[prop];
113-
if (id === prop) {
114-
return currentChild;
115-
} else {
116-
// Search in the current child
117-
if (typeof (currentChild) === 'object') {
118-
let result = findNode(id, currentChild);
119-
if (result !== false) {
120-
return result;
106+
var currentChild,
107+
result;
108+
109+
if ( Object.keys(currentNode)[0] == id) {
110+
return currentNode;
111+
} else {
112+
// Use a for loop instead of forEach to avoid nested functions
113+
// Otherwise "return" will not work properly
114+
for(var propt in currentNode){
115+
if (currentNode.hasOwnProperty(propt)) {
116+
currentChild = currentNode[propt]
117+
if (id == propt) {
118+
return currentChild;
119+
} else {
120+
// Search in the current child
121+
if (typeof(currentChild) === 'object') {
122+
result = findNode(id, currentChild);
123+
if (result != false) {
124+
return result;
125+
}
121126
}
122127
}
123128
}
124129
}
130+
// The node has not been found and we have no more options
131+
return false;
125132
}
126-
return false;
127133
}
128-
129134
</script>
130135
<style type="text/css">
131136
{{>fonts}}
@@ -447,7 +452,7 @@
447452
var schemaWrapper = {{{jsonSchema}}};
448453
var schema = findNode('schema',schemaWrapper).schema;
449454
if (!schema) {
450-
schema = schemaWrapper.schema;
455+
schema = schemaWrapper.schema;
451456
}
452457
if (schema.$ref != null) {
453458
schema = defsParser.$refs.get(schema.$ref);

modules/openapi-generator/src/main/resources/htmlDocs2/paramB.mustache

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
<script>
55
$(document).ready(function() {
66
var schemaWrapper = {{{jsonSchema}}};
7-
var schema = findNode('schema', schemaWrapper).schema;
7+
8+
var schema = findNode('schema',schemaWrapper).schema;
89
if (!schema) {
9-
schema = schemaWrapper.schema;
10+
schema = schemaWrapper.schema;
1011
}
1112
if (schema.$ref != null) {
1213
schema = defsParser.$refs.get(schema.$ref);
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
index.html
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.0.0-SNAPSHOT
1+
5.0.0-SNAPSHOT

samples/documentation/html.md/index.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,8 @@ <h1>An <em>API</em> with more <strong>Markdown</strong> in summary, description,
189189
<li>in schema (model) member descriptions</li>
190190
</ol>
191191
</div>
192-
<div class="app-desc">More information: <a href="https://helloreverb.com">https://helloreverb.com</a></div>
193-
<div class="app-desc">Contact Info: <a href="[email protected]">[email protected]</a></div>
192+
<div class="app-desc">More information: <a href="https://openapi-generator.tech">https://openapi-generator.tech</a></div>
193+
<div class="app-desc">Contact Info: <a href="[email protected]">[email protected]</a></div>
194194
<div class="app-desc">Version: 0.1.0</div>
195195
<div class="app-desc">BasePath:/v1</div>
196196
<div class="license-info">All rights reserved</div>
@@ -226,7 +226,7 @@ <h3 class="field-label">Query parameters</h3>
226226
<div class="field-items">
227227
<div class="param">seed (required)</div>
228228

229-
<div class="param-desc"><span class="param-type">Query Parameter</span> &mdash; A random number <em>seed</em>. </div>
229+
<div class="param-desc"><span class="param-type">Query Parameter</span> &mdash; A random number <em>seed</em>. default: null </div>
230230
</div> <!-- field-items -->
231231

232232

@@ -242,8 +242,8 @@ <h3 class="field-label">Example data</h3>
242242
<div class="example-data-content-type">Content-Type: */*</div>
243243
<pre class="example"><code>{
244244
"sequence" : 1,
245-
"seed" : 6.02745618307040320615897144307382404804229736328125,
246-
"value" : 0.80082819046101150206595775671303272247314453125
245+
"seed" : 6.027456183070403,
246+
"value" : 0.8008281904610115
247247
}</code></pre>
248248

249249
<h3 class="field-label">Produces</h3>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
index.html

samples/documentation/html/index.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,6 @@ <h1>OpenAPI Petstore</h1>
190190
<h2>Access</h2>
191191
<ol>
192192
<li>APIKey KeyParamName:api_key KeyInQuery:false KeyInHeader:true</li>
193-
<li>APIKey KeyParamName:AUTH_KEY KeyInQuery:false KeyInHeader:false</li>
194193
<li>OAuth AuthorizationUrl:http://petstore.swagger.io/api/oauth/dialogTokenUrl:</li>
195194
</ol>
196195

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
index.html

0 commit comments

Comments
 (0)