fix: different output of cli bundle and redoc

fixes #547
This commit is contained in:
Roman Hotsiy 2018-07-18 11:42:02 +03:00
parent dcca44a92d
commit 89aa754063
No known key found for this signature in database
GPG Key ID: 5CB7B3ACABA57CB0
2 changed files with 8 additions and 4 deletions

View File

@ -80,16 +80,12 @@ exports[`Components SchemaView discriminator should correctly render discriminat
"options": "<<<filtered>>>", "options": "<<<filtered>>>",
"pattern": undefined, "pattern": undefined,
"rawSchema": Object { "rawSchema": Object {
"allOf": undefined,
"default": undefined, "default": undefined,
"parentRefs": Array [],
"type": "string", "type": "string",
}, },
"readOnly": false, "readOnly": false,
"schema": Object { "schema": Object {
"allOf": undefined,
"default": undefined, "default": undefined,
"parentRefs": Array [],
"type": "string", "type": "string",
}, },
"title": "", "title": "",

View File

@ -192,6 +192,14 @@ export class OpenAPIParser {
parentRefs: [], parentRefs: [],
}; };
// avoid mutating inner objects
if (receiver.properties !== undefined && typeof receiver.properties === 'object') {
receiver.properties = { ...receiver.properties };
}
if (receiver.items !== undefined && typeof receiver.items === 'object') {
receiver.items = { ...receiver.items };
}
const allOfSchemas = schema.allOf.map(subSchema => { const allOfSchemas = schema.allOf.map(subSchema => {
const resolved = this.deref(subSchema, forceCircular); const resolved = this.deref(subSchema, forceCircular);
const subRef = subSchema.$ref || undefined; const subRef = subSchema.$ref || undefined;