Skip to content

Commit

Permalink
fix: enum with single value not shown in non-body params
Browse files Browse the repository at this point in the history
closes #284
  • Loading branch information
RomanHotsiy committed Jul 2, 2017
1 parent 10cdfe5 commit 87d9abd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
12 changes: 9 additions & 3 deletions lib/components/ParamsList/params-list.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ <h5 class="param-list-header" *ngIf="params.length"> Parameters </h5>
</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}"
Expand All @@ -21,8 +22,13 @@ <h5 class="param-list-header" *ngIf="params.length"> Parameters </h5>
<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>
Expand Down
4 changes: 2 additions & 2 deletions lib/services/schema-helper.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down

0 comments on commit 87d9abd

Please sign in to comment.