fix: enum with single value not shown in non-body params

closes #284
This commit is contained in:
Roman Hotsiy 2017-07-02 18:54:51 +03:00
parent 10cdfe59ee
commit 87d9abd62b
No known key found for this signature in database
GPG Key ID: 5CB7B3ACABA57CB0
2 changed files with 11 additions and 5 deletions

View File

@ -11,7 +11,8 @@
</div>
<div class="param-info">
<div>
<span *ngIf='param.type === "array"' class="param-array-format param-collection-format-{{param.collectionFormat}}">
<span *ngIf='param.type === "array"'
class="param-array-format param-collection-format-{{param.collectionFormat}}">
{{param | collectionFormat}}
</span>
<span class="param-type {{param.type}}" [ngClass]="{'with-hint': param._displayTypeHint}"
@ -21,8 +22,13 @@
<div class="param-default" *ngIf="param.default != null">
<span class="param-default-value">{{param.default | json}}</span>
</div>
<div *ngIf="param.enum" class="param-enum">
<span *ngFor="let enumItem of param.enum" class="param-enum-value {{enumItem.type}}"> {{enumItem.val | json}} </span>
<div *ngIf="param.enum || param._enumItem" class="param-enum">
<span *ngFor="let enumItem of param.enum" class="param-enum-value {{enumItem.type}}">
{{enumItem.val | json}}
</span>
<span *ngIf="param._enumItem" class="param-enum-value {{param._enumItem.type}}">
{{param._enumItem.val | json}}
</span>
</div>
<span *ngIf="param.pattern" class="param-pattern">{{param.pattern}}</span>
</div>

View File

@ -35,8 +35,8 @@ const injectors = {
injectTo.enum = propertySchema.enum.map((value) => {
return {val: value, type: typeof value};
});
if (propertySchema.enum && propertySchema.enum.length === 1) {
injectTo._enumItem = propertySchema.enum[0];
if (injectTo.enum && injectTo.enum.length === 1) {
injectTo._enumItem = injectTo.enum[0];
injectTo.enum = null;
}
}