diff --git a/lib/components/JsonSchema/json-schema-common.scss b/lib/components/JsonSchema/json-schema-common.scss index a939c365..d4ae7d5a 100644 --- a/lib/components/JsonSchema/json-schema-common.scss +++ b/lib/components/JsonSchema/json-schema-common.scss @@ -47,6 +47,10 @@ $sub-schema-offset: ($bullet-size/2) + $bullet-margin; width: 75%; } +.param-range { + color: rgba($primary-color, .7); +} + .param-description { font-size: 13px; } diff --git a/lib/components/JsonSchema/json-schema.html b/lib/components/JsonSchema/json-schema.html index c43fe903..c22bc7e8 100644 --- a/lib/components/JsonSchema/json-schema.html +++ b/lib/components/JsonSchema/json-schema.html @@ -11,7 +11,9 @@
{{prop._displayType}} {{prop._displayFormat}} + title="{{prop._displayTypeHint}}"> {{prop._displayType}} {{prop._displayFormat}} + {{prop._range}} + Required
{{enumItem.val | json}} diff --git a/lib/components/JsonSchema/json-schema.js b/lib/components/JsonSchema/json-schema.js index 18309505..c5ef5430 100644 --- a/lib/components/JsonSchema/json-schema.js +++ b/lib/components/JsonSchema/json-schema.js @@ -163,5 +163,28 @@ const injectors = { `${propertySchema.title} (${propertySchema.type})` : propertySchema.type; } } + }, + integer: { + check: (propertySchema) => (propertySchema.type === 'integer' || propertySchema.type === 'number'), + inject: (injectTo, propertySchema = injectTo) => { + var range = ''; + if (propertySchema.minimum && propertySchema.maximum) { + range += propertySchema.exclusiveMinimum ? '( ' : '[ '; + range += propertySchema.minimum; + range += ' .. '; + range += propertySchema.maximum; + range += propertySchema.exclusiveMaximum ? ' )' : ' ]'; + } else if (propertySchema.maximum) { + range += propertySchema.exclusiveMaximum? '< ' : '<= '; + range += propertySchema.maximum; + } else if (propertySchema.minimum) { + range += propertySchema.exclusiveMinimum ? '> ' : '>= '; + range += propertySchema.minimum; + } + + if (range) { + injectTo._range = range; + } + } } };