mirror of
https://github.com/Redocly/redoc.git
synced 2024-11-11 03:16:48 +03:00
Add minimum and maximum information for numeric fields (fixes #33)
This commit is contained in:
parent
ac7116ad04
commit
13286558d0
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -11,7 +11,9 @@
|
|||
<td class="param-info">
|
||||
<div>
|
||||
<span class="param-type {{prop.type}}" [ngClass]="{'with-hint': prop._displayTypeHint}"
|
||||
title="{{prop._displayTypeHint}}"> {{prop._displayType}} {{prop._displayFormat}}</span>
|
||||
title="{{prop._displayTypeHint}}"> {{prop._displayType}} {{prop._displayFormat}}
|
||||
<span class="param-range" *ngIf="prop._range"> {{prop._range}} </span>
|
||||
</span>
|
||||
<span *ngIf="prop.required" class="param-required">Required</span>
|
||||
<div *ngIf="prop.enum" class="param-enum">
|
||||
<span *ngFor="#enumItem of prop.enum" class="enum-value {{enumItem.type}}"> {{enumItem.val | json}} </span>
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue
Block a user