diff --git a/lib/components/JsonSchema/json-schema.js b/lib/components/JsonSchema/json-schema.js index 6358db37..75f723e3 100644 --- a/lib/components/JsonSchema/json-schema.js +++ b/lib/components/JsonSchema/json-schema.js @@ -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() { diff --git a/lib/components/JsonSchema/json-schema.scss b/lib/components/JsonSchema/json-schema.scss index 9ba8e11c..e76a6715 100644 --- a/lib/components/JsonSchema/json-schema.scss +++ b/lib/components/JsonSchema/json-schema.scss @@ -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";