fix: merge inner properties of allOf

This commit is contained in:
Roman Hotsiy 2018-03-05 13:47:04 +02:00
parent 2462639f76
commit 8926dd457c
No known key found for this signature in database
GPG Key ID: 5CB7B3ACABA57CB0
2 changed files with 16 additions and 5 deletions

View File

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

View File

@ -212,11 +212,18 @@ export class OpenAPIParser {
}
if (subSchema.properties !== undefined) {
// TODO: merge properties contents
receiver.properties = {
...(receiver.properties || {}),
...subSchema.properties,
};
receiver.properties = receiver.properties || {};
for (let prop in subSchema.properties) {
if (!receiver.properties[prop]) {
receiver.properties[prop] = subSchema.properties[prop];
} else {
// merge inner properties
receiver.properties[prop] = this.mergeAllOf(
{ allOf: [receiver.properties[prop], subSchema.properties[prop]] },
$ref + '/properties/' + prop,
);
}
}
}
if (subSchema.required !== undefined) {