schema types coloring

This commit is contained in:
Roman Hotsiy 2016-01-23 16:29:34 +02:00
parent 6ebca9d46c
commit 31e6a1b543
2 changed files with 23 additions and 2 deletions

View File

@ -71,7 +71,7 @@ export default class JsonSchema extends BaseComponent {
let discriminatorFieldIdx = -1;
let props = Object.keys(schema.properties).map((prop, idx) => {
let propData = schema.properties[prop];
this.injectPropData(prop, propData, schema);
propData = this.injectPropData(prop, propData, schema);
if (propData.isDiscriminator) discriminatorFieldIdx = idx;
return propData;
});
@ -98,6 +98,7 @@ export default class JsonSchema extends BaseComponent {
}
injectPropData(prop, propData, schema) {
propData = Object.assign({}, propData);
propData._name = prop;
propData.isRequired = this.requiredMap[prop];
propData._displayType = propData.type;
@ -109,9 +110,10 @@ export default class JsonSchema extends BaseComponent {
itemType = propData.items.title || 'object';
propData._pointer = propData.items._pointer || JsonPointer.join(this.pointer, ['properties', prop, 'items']);
}
propData._displayType = `array of ${itemType}`;
propData._displayType = `${itemType}`;
propData.format = itemFormat;
propData._isArray = true;
propData.type = 'array ' + propData.items.type;
}
if (propData.type === 'object') {
@ -124,6 +126,8 @@ export default class JsonSchema extends BaseComponent {
}
if (propData.format) propData._displayFormat = `<${propData.format}>`;
return propData;
}
init() {

View File

@ -67,6 +67,23 @@ $sub-schema-offset: ($bullet-size/2) + $bullet-margin;
font-weight: bold;
}
.param-type.array:before {
content: "Array of ";
color: #999;
}
.param-type.string {
color: rgba(0, 80, 0, 0.7);
}
.param-type.integer {
color: rgba(30, 0, 80, 0.7);
}
.param-type.object {
color: rgba(139, 0, 0, 0.67);
}
.param-type.with-hint {
&:before, &:after {
content: "\\00a0";