Skip to content

Commit

Permalink
[html2] Fix blank responses in html document (#18356)
Browse files Browse the repository at this point in the history
* [html2]remove unnecessary mustache section

* [html2]add null check
  • Loading branch information
Aniokrait authored Apr 12, 2024
1 parent 0b3e6ed commit 8618658
Showing 1 changed file with 41 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -445,48 +445,49 @@


<div class="tab-content" id="responses-{{baseName}}-{{nickname}}-{{code}}-wrapper" style='margin-bottom: 10px;'>
{{#schema}}
<div class="tab-pane active" id="responses-{{baseName}}-{{nickname}}-{{code}}-schema">
<div id="responses-{{baseName}}-{{nickname}}-schema-{{code}}" class="exampleStyle">
<script>
$(document).ready(function() {
var schemaWrapper = {{{jsonSchema}}};
var schema = findNode('schema',schemaWrapper).schema;
if (!schema) {
schema = schemaWrapper.schema;
}
if (schema.$ref != null) {
schema = defsParser.$refs.get(schema.$ref);
Object.keys(schema.properties).forEach( (item) => {
if (schema.properties[item].$ref != null) {
schema.properties[item] = defsParser.$refs.get(schema.properties[item].$ref);
}
});
} else if (schema.items != null && schema.items.$ref != null) {
schema.items = defsParser.$refs.get(schema.items.$ref);
} else {
schemaWrapper.definitions = Object.assign({}, defs);
$RefParser.dereference(schemaWrapper).catch(function(err) {
console.log(err);
});
}
<div class="tab-pane active" id="responses-{{baseName}}-{{nickname}}-{{code}}-schema">
<div id="responses-{{baseName}}-{{nickname}}-schema-{{code}}" class="exampleStyle">
<script>
$(document).ready(function() {
var schemaWrapper = {{{jsonSchema}}};
var schema = findNode('schema',schemaWrapper).schema;
if (!schema) {
schema = schemaWrapper.schema;
}
if (schema == null) {
return;
}
if (schema.$ref != null) {
schema = defsParser.$refs.get(schema.$ref);
Object.keys(schema.properties).forEach( (item) => {
if (schema.properties[item].$ref != null) {
schema.properties[item] = defsParser.$refs.get(schema.properties[item].$ref);
}
});
} else if (schema.items != null && schema.items.$ref != null) {
schema.items = defsParser.$refs.get(schema.items.$ref);
} else {
schemaWrapper.definitions = Object.assign({}, defs);
$RefParser.dereference(schemaWrapper).catch(function(err) {
console.log(err);
});
}
var view = new JSONSchemaView(schema, 3);
$('#responses-{{baseName}}-{{nickname}}-{{code}}-schema-data').val(JSON.stringify(schema));
var result = $('#responses-{{baseName}}-{{nickname}}-schema-{{code}}');
result.empty();
result.append(view.render());
});
</script>
</div>
<input id='responses-{{baseName}}-{{nickname}}-{{code}}-schema-data' type='hidden' value=''></input>
var view = new JSONSchemaView(schema, 3);
$('#responses-{{baseName}}-{{nickname}}-{{code}}-schema-data').val(JSON.stringify(schema));
var result = $('#responses-{{baseName}}-{{nickname}}-schema-{{code}}');
result.empty();
result.append(view.render());
});
</script>
</div>
{{#examples}}
<div class="tab-pane" id="examples-{{baseName}}-{{nickname}}-{{code}}-example">
<pre class="prettyprint"><code class="json">{{example}}</code></pre>
</div>
{{/examples}}
{{/schema}}
<input id='responses-{{baseName}}-{{nickname}}-{{code}}-schema-data' type='hidden' value=''></input>
</div>
{{#examples}}
<div class="tab-pane" id="examples-{{baseName}}-{{nickname}}-{{code}}-example">
<pre class="prettyprint"><code class="json">{{example}}</code></pre>
</div>
{{/examples}}
{{#hasHeaders}}
<div class="tab-pane" id="responses-{{nickname}}-{{code}}-headers">
<table>
Expand Down

0 comments on commit 8618658

Please sign in to comment.