fix: move title propagation to the correct place

This commit is contained in:
Roman Hotsiy 2018-01-10 13:02:32 +02:00
parent 9d0f2a9273
commit 0b0bc99f73
No known key found for this signature in database
GPG Key ID: 5CB7B3ACABA57CB0

View File

@ -191,10 +191,6 @@ export class OpenAPIParser {
};
});
if (receiver.title === undefined && isNamedDefinition($ref)) {
receiver.title = JsonPointer.baseName($ref);
}
for (let { $ref: subSchemaRef, schema: subSchema } of allOfSchemas) {
if (
receiver.type !== subSchema.type &&
@ -220,17 +216,22 @@ export class OpenAPIParser {
receiver.required = (receiver.required || []).concat(subSchema.required);
}
// merge rest of constraints
// TODO: do more intelegent merge
receiver = { ...subSchema, ...receiver };
if (subSchemaRef) {
receiver.parentRefs!.push(subSchemaRef);
if (receiver.title === undefined && isNamedDefinition(subSchemaRef)) {
receiver.title = JsonPointer.baseName(subSchemaRef);
}
}
// merge rest of constraints
// TODO: do more intelegent merge
receiver = { ...subSchema, ...receiver };
}
if (receiver.title === undefined && isNamedDefinition($ref)) {
receiver.title = JsonPointer.baseName($ref);
}
return receiver;
}