Skip to content

Commit

Permalink
[Html2] Fix circular references (#5313)
Browse files Browse the repository at this point in the history
* [html2] Fix circular references

Signed-off-by: weiyang <[email protected]>

* [samples][html2] Fix circular references

Signed-off-by: weiyang <[email protected]>

* Optimize code format

Signed-off-by: weiyang <[email protected]>
  • Loading branch information
wy-z authored and wing328 committed Apr 6, 2017
1 parent 5de04fa commit abffdca
Show file tree
Hide file tree
Showing 6 changed files with 1,342 additions and 2,523 deletions.
40 changes: 25 additions & 15 deletions modules/swagger-codegen/src/main/resources/htmlDocs2/index.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -363,20 +363,21 @@
$(document).ready(function() {
var schemaWrapper = {{{jsonSchema}}};
var schema = schemaWrapper.schema;
schemaWrapper.definitions = defs;
//console.log(JSON.stringify(schema))
JsonRefs.resolveRefs(schemaWrapper, {
"depth": 3,
"resolveRemoteRefs": false,
"resolveFileRefs": false
}, function(err, resolved, metadata) {
//console.log(JSON.stringify(resolved));
var view = new JSONSchemaView(resolved.schema, 3);
$('#responses-{{nickname}}-{{code}}-schema-data').val(JSON.stringify(resolved.schema));
var result = $('#responses-{{nickname}}-{{code}}-schema-{{code}}');
result.empty();
result.append(view.render());
});
if (schema.$ref != null) {
schema = defsParser.$refs.get(schema.$ref);
} else {
schemaWrapper.definitions = Object.assign({}, defs);
$RefParser.dereference(schemaWrapper).catch(function(err) {
console.log(err);
});
}
//console.log(JSON.stringify(schema));
var view = new JSONSchemaView(schema, 3);
$('#responses-{{nickname}}-{{code}}-schema-data').val(stringify(schema));
var result = $('#responses-{{nickname}}-{{code}}-schema-{{code}}');
result.empty();
result.append(view.render());
});
</script>
</div>
Expand Down Expand Up @@ -448,8 +449,17 @@
</div>
{{>js_jsonformatter}}
{{>js_jsonschemaview}}
{{>js_jsonref}}
{{>js_json_schema_ref_parser}}
{{>js_json_stringify_safe}}
{{>js_webfontloader}}
<script>
var schemaWrapper = {};
schemaWrapper.definitions = Object.assign({}, defs);
defsParser = new $RefParser();
defsParser.dereference(schemaWrapper).catch(function(err) {
console.log(err);
});
</script>
<script>
$(document).ready(function () {
$('.nav-tabs-examples').find('a:first').tab('show');
Expand Down
Loading

0 comments on commit abffdca

Please sign in to comment.