mirror of
https://github.com/Redocly/redoc.git
synced 2025-02-07 21:40:32 +03:00
Fix array inside objects if referenced directly (fixes #84)
This commit is contained in:
parent
4f746a19e3
commit
2bc729ea23
|
@ -66,8 +66,8 @@ export class JsonSchema extends BaseComponent implements OnInit {
|
|||
this.applyStyling();
|
||||
|
||||
this.schema = this.normalizer.normalize(this.schema, this.normPointer);
|
||||
this.initDescendants();
|
||||
this.schema = SchemaHelper.unwrapArray(this.schema, this.normPointer);
|
||||
this.initDescendants();
|
||||
this.preprocessSchema();
|
||||
}
|
||||
|
||||
|
|
|
@ -67,11 +67,15 @@ const injectors = {
|
|||
return propertySchema.type === 'array' && !Array.isArray(propertySchema.items);
|
||||
},
|
||||
inject: (injectTo, propertySchema = injectTo, propPointer) => {
|
||||
if (!(SchemaHelper.detectType(propertySchema.items) === 'object')) {
|
||||
injectTo._isArray = true;
|
||||
injectTo._pointer = propertySchema.items._pointer
|
||||
|| JsonPointer.join(propertySchema._pointer || propPointer, ['items']);
|
||||
|
||||
SchemaHelper.runInjectors(injectTo, propertySchema.items, propPointer);
|
||||
} else {
|
||||
injectors.object.inject(injectTo, propertySchema.items);
|
||||
}
|
||||
injectTo._widgetType = 'array';
|
||||
}
|
||||
},
|
||||
|
@ -270,6 +274,7 @@ export class SchemaHelper {
|
|||
}
|
||||
|
||||
static detectType(schema) {
|
||||
if (schema.type) return schema.type;
|
||||
let keywords = Object.keys(keywordTypes);
|
||||
for (var i=0; i < keywords.length; i++) {
|
||||
let keyword = keywords[i];
|
||||
|
|
Loading…
Reference in New Issue
Block a user