joinAllOf fix: ref and inline schema case

This commit is contained in:
Roman Hotsiy 2016-04-20 19:56:20 +03:00
parent 21788c282d
commit b92ebe388b
2 changed files with 10 additions and 2 deletions

View File

@ -75,7 +75,8 @@ export default class JsonSchema extends BaseComponent {
let discriminatorFieldIdx = -1;
let props = Object.keys(schema.properties).map((prop, idx) => {
let propertySchema = schema.properties[prop];
let propPointer = JsonPointer.join(schema._pointer || this.pointer, ['properties', prop]);
let propPointer = propertySchema._pointer ||
JsonPointer.join(schema._pointer || this.pointer, ['properties', prop]);
propertySchema = JsonSchema.injectPropertyData(propertySchema, prop, propPointer);
// stop endless discriminator recursion
if (propertySchema._pointer === this.childFor) {

View File

@ -192,12 +192,19 @@ export class BaseComponent {
if (into.type === 'object' && subSchema.properties) {
into.properties || (into.properties = {});
Object.assign(into.properties, subSchema.properties);
Object.keys(subSchema.properties).forEach(propName => {
if (!subSchema.properties[propName]._pointer) {
subSchema.properties[propName]._pointer = subSchema._pointer ?
JsonPointer.join(subSchema._pointer, ['properties', propName]) : null;
}
});
}
if (into.type === 'object' && subSchema.required) {
into.required || (into.required = []);
into.required.push(...subSchema.required);
}
// don't merge _pointer
subSchema._pointer = null;
defaults(into, subSchema);
}
into.allOf = null;