JsonSchema treat array of objects

This commit is contained in:
Roman Hotsiy 2015-11-18 23:51:19 +02:00
parent 54b3ef1223
commit af4f21726a
2 changed files with 5442 additions and 4 deletions

5435
demo/rebilly.json Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,5 @@
'use strict'; 'use strict';
import {JsonPointer} from '../../utils/JsonPointer';
import {RedocComponent, BaseComponent} from '../base'; import {RedocComponent, BaseComponent} from '../base';
import {ElementRef} from 'angular2/angular2'; import {ElementRef} from 'angular2/angular2';
@ -29,11 +28,12 @@ export default class JsonSchema extends BaseComponent {
// TODO // TODO
return; return;
} }
if (!schema.properties) return;
let props = Object.keys(schema.properties).map(prop => { let props = Object.keys(schema.properties).map(prop => {
let propData = schema.properties[prop]; let propData = schema.properties[prop];
this.injectPropData(prop, propData); this.injectPropData(prop, propData);
return propData; return propData;
}) });
this.data.properties = props; this.data.properties = props;
@ -55,12 +55,15 @@ export default class JsonSchema extends BaseComponent {
if (propData.type === 'array') { if (propData.type === 'array') {
let itemType = propData.items.type; let itemType = propData.items.type;
if (itemType === 'object') itemType = propData.items.title || 'object'; if (itemType === 'object') {
itemType = propData.items.title || 'object';
propData._pointer = propData.items._pointer;
}
propData.type = `array of ${itemType}`; propData.type = `array of ${itemType}`;
} }
if (propData.type === 'object') { if (propData.type === 'object') {
propData.type = propData.title || 'object' propData.type = propData.title || 'object';
} }
} }