Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[html2] Fix blank responses in html document #18356

Merged
merged 2 commits into from
Apr 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading