mirror of
https://github.com/Redocly/redoc.git
synced 2024-11-26 02:23:43 +03:00
Display enums info
This commit is contained in:
parent
fae59c7917
commit
e861ae9add
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,6 +13,9 @@
|
|||
<span class="param-type {{prop.type}}" [ngClass]="{'with-hint': prop._displayTypeHint}"
|
||||
title="{{prop._displayTypeHint}}"> {{prop._displayType}} {{prop._displayFormat}}</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>
|
||||
</div>
|
||||
</div>
|
||||
<div class="param-description" innerHtml="{{prop.description | marked}}"></div>
|
||||
<div class="discriminator-info" *ngIf="prop.isDiscriminator"> This field value determines the exact schema: </div>
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -9,6 +9,9 @@
|
|||
<span class="param-type {{param.type}}" [ngClass]="{'with-hint': param._displayTypeHint}"
|
||||
title="{{param._displayTypeHint}}"> {{param._displayType}} {{param._displayFormat}}</span>
|
||||
<span *ngIf="param.required" class="param-required">Required</span>
|
||||
<div *ngIf="param.enum" class="param-enum">
|
||||
<span *ngFor="#enumItem of param.enum" class="enum-value {{enumItem.type}}"> {{enumItem.val | json}} </span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="param-description" innerHtml="{{param.description | marked}}"></div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue
Block a user