Skip to content

Commit 883b852

Browse files
committed
dont resolve circular refs in advance
1 parent f200abb commit 883b852

16 files changed

+136
-124
lines changed

dist/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
-->
1919

2020
<rapi-doc
21-
spec-url="https://petstore.swagger.io/v2/swagger.json"
21+
spec-url="https://api.apis.guru/v2/specs/bitbucket.org/2.0/swagger.json"
2222
layout="row"
2323
theme="dark"
2424
>

dist/index.html.gz

0 Bytes
Binary file not shown.

dist/rapidoc-min.js

Lines changed: 33 additions & 47 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/rapidoc-min.js.gz

139 Bytes
Binary file not shown.

dist/rapidoc-min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/rapidoc-min.js.map.gz

-528 Bytes
Binary file not shown.

dist/report.html

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

docs/rapidoc-min.js

Lines changed: 33 additions & 47 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
-->
1919

2020
<rapi-doc
21-
spec-url="https://petstore.swagger.io/v2/swagger.json"
21+
spec-url="https://api.apis.guru/v2/specs/bitbucket.org/2.0/swagger.json"
2222
layout="row"
2323
theme="dark"
2424
>

src/components/api-request.js

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { LitElement, html } from 'lit-element';
2+
import JsonSchemaRefParser from 'json-schema-ref-parser';
23
import JsonTree from '@/components/json-tree';
34
import SchemaTree from '@/components/schema-tree';
45
import TagInput from '@/components/tag-input';
@@ -11,7 +12,6 @@ import CommonStyles from '@/styles/common-styles';
1112
import { schemaToModel, getTypeInfo, generateExample, removeCircularReferences} from '@/utils/common-utils';
1213
import marked from 'marked';
1314
import {unsafeHTML} from 'lit-html/directives/unsafe-html.js';
14-
import {repeat} from "lit-html/lib/repeat"
1515

1616
export default class ApiRequest extends LitElement {
1717

@@ -140,6 +140,7 @@ export default class ApiRequest extends LitElement {
140140
path : { type: String },
141141
parameters : { type: Array },
142142
request_body : { type: Object },
143+
parser : { type: Object },
143144
responseMessage: { type: String, attribute:false },
144145
responseText : { type: String, attribute:false },
145146
responseHeaders: { type: String, attribute:false },
@@ -165,6 +166,12 @@ export default class ApiRequest extends LitElement {
165166

166167
const tableRows = [];
167168
for (const param of filteredParams) {
169+
if (!param.schema){
170+
continue;
171+
}
172+
if (param.schema.$ref){
173+
param.schema = this.parser.$refs.get(param.schema.$ref);
174+
}
168175
let paramSchema = getTypeInfo(param.schema);
169176
let inputVal='';
170177
if (param.example=='0'){
@@ -234,6 +241,10 @@ export default class ApiRequest extends LitElement {
234241
if(!this.request_body){
235242
return '';
236243
}
244+
if (this.request_body.$ref){
245+
this.request_body = this.parser.$refs.get(this.request_body.$ref);
246+
}
247+
237248
if (Object.keys(this.request_body).length == 0){
238249
return '';
239250
}
@@ -248,6 +259,7 @@ export default class ApiRequest extends LitElement {
248259
let reqSchemaTree="";
249260

250261
let content = this.request_body.content;
262+
251263
for(let mimeReq in content ) {
252264
// do not change shortMimeTypes values, they are referenced in other places
253265
if (mimeReq.includes('json')){shortMimeTypes[mimeReq]='json';}
@@ -260,8 +272,12 @@ export default class ApiRequest extends LitElement {
260272
let reqExample="";
261273
if (mimeReq.includes('json') || mimeReq.includes('xml') || mimeReq.includes('text/plain')){
262274
//Remove Circular references from RequestBody json-schema
275+
263276
try {
264-
mimeReqObj.schema = JSON.parse(JSON.stringify(mimeReqObj.schema, removeCircularReferences()));
277+
if (mimeReqObj.schema.$ref){
278+
mimeReqObj.schema = this.parser.$refs.get(mimeReqObj.schema.$ref);
279+
}
280+
//mimeReqObj.schema = JSON.parse(JSON.stringify(mimeReqObj.schema, removeCircularReferences()));
265281
}
266282
catch{
267283
console.error("Unable to resolve circular refs in schema", mimeReqObj.schema);

0 commit comments

Comments
 (0)