diff --git a/lib/components/JsonSchema/json-schema-common.scss b/lib/components/JsonSchema/json-schema-common.scss index 434b63f3..78a260bf 100644 --- a/lib/components/JsonSchema/json-schema-common.scss +++ b/lib/components/JsonSchema/json-schema-common.scss @@ -72,11 +72,11 @@ $sub-schema-offset: ($bullet-size/2) + $bullet-margin; color: #999; } -.param-type.string { +.param-type.string, .enum-value.string { color: rgba(0, 80, 0, 0.7); } -.param-type.integer, .param-type.number { +.param-type.integer, .param-type.number, .enum-value.number { color: rgba(74, 139, 179, 0.8); } @@ -84,7 +84,7 @@ $sub-schema-offset: ($bullet-size/2) + $bullet-margin; color: rgba(0, 50, 159, 0.7); } -.param-type.boolean { +.param-type.boolean, .enum-value.boolean { color: firebrick; } @@ -158,3 +158,25 @@ $sub-schema-offset: ($bullet-size/2) + $bullet-margin; .param-schema .param-wrap:first-of-type .param-name:before { display: none !important; } + +.param-enum { + color: #666; + + &:before { + content: "Values: {" + } + + &:after { + content: "}" + } + + > .enum-value { + &:after { + content: ", "; + } + + &:last-of-type:after { + content: none; + } + } +} diff --git a/lib/components/JsonSchema/json-schema.html b/lib/components/JsonSchema/json-schema.html index 51a9b0a7..9828a49a 100644 --- a/lib/components/JsonSchema/json-schema.html +++ b/lib/components/JsonSchema/json-schema.html @@ -13,6 +13,9 @@ {{prop._displayType}} {{prop._displayFormat}} Required +
+ {{enumItem.val | json}} +
This field value determines the exact schema:
diff --git a/lib/components/JsonSchema/json-schema.js b/lib/components/JsonSchema/json-schema.js index 0ed590aa..a55aff42 100644 --- a/lib/components/JsonSchema/json-schema.js +++ b/lib/components/JsonSchema/json-schema.js @@ -99,14 +99,18 @@ export default class JsonSchema extends BaseComponent { } static injectPropData(propData, propName, propPointer, requiredMap, schema) { + let propEnum; + propData = Object.assign({}, propData); propData._name = propName; propData.required = propData.required || (requiredMap && requiredMap[propName]); propData._displayType = propData.type; propData.isDiscriminator = (schema && schema.discriminator === propName); + propEnum = propData.enum; if (propData.type === 'array') { let itemType = propData.items.type; let itemFormat = propData.items.format; + propEnum = propData.items.enum; if (itemType === 'object' || !itemType) { itemType = propData.items.title || 'object'; propData._pointer = propData.items._pointer @@ -128,6 +132,11 @@ export default class JsonSchema extends BaseComponent { } if (propData.format) propData._displayFormat = `<${propData.format}>`; + if (propEnum) { + propData.enum = propEnum.map((value) => { + return {val: value, type: typeof value}; + }); + } return propData; } diff --git a/lib/components/ParamsList/params-list.html b/lib/components/ParamsList/params-list.html index 8bfe6853..86e66c5c 100644 --- a/lib/components/ParamsList/params-list.html +++ b/lib/components/ParamsList/params-list.html @@ -9,6 +9,9 @@ {{param._displayType}} {{param._displayFormat}} Required +
+ {{enumItem.val | json}} +