Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/main/javascript/view/ParameterView.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,13 @@ SwaggerUi.Views.ParameterView = Backbone.View.extend({
this.model.paramType = this.model.in || this.model.paramType;
this.model.isBody = this.model.paramType === 'body' || this.model.in === 'body';
this.model.isFile = type && type.toLowerCase() === 'file';
this.model.default = (this.model.default || this.model.defaultValue);

// Allow for default === false
if(typeof this.model.default === 'undefined') {
this.model.default = this.model.defaultValue;
}

this.model.hasDefault = (typeof this.model.default !== 'undefined');
this.model.valueId = 'm' + this.model.name + Math.random();

if (this.model.allowableValues) {
Expand Down Expand Up @@ -99,4 +105,4 @@ SwaggerUi.Views.ParameterView = Backbone.View.extend({
}
}
}
});
});
26 changes: 10 additions & 16 deletions src/main/template/param_list.handlebars
Original file line number Diff line number Diff line change
@@ -1,23 +1,17 @@
<td class='code{{#if required}} required{{/if}}'><label for='{{valueId}}'>{{name}}</labe></td>
<td>
<select {{#isArray this}} multiple='multiple'{{/isArray}} class={{#if required}}'parameter required'{{else}}'parameter'{{/if}} name='{{name}}' id='{{valueId}}'>
{{#if required}}
{{else}}
{{#if default}}
{{else}}
{{#isArray this}}
{{else}}
<option selected="" value=''></option>
{{/isArray}}
{{/if}}
{{/if}}
<select {{#isArray this}} multiple="multiple"{{/isArray}} class="parameter {{#if required}} required {{/if}}" name="{{name}}" id="{{valueId}}">

{{#unless required}}
<option {{#unless hasDefault}} selected="" {{/unless}} value=''></option>
{{/unless}}

{{#each allowableValues.descriptiveValues}}
{{#if isDefault}}
<option selected="" value='{{value}}'>{{value}} (default)</option>
{{else}}
<option value='{{value}}'>{{value}}</option>
{{/if}}

<option {{#if isDefault}} selected="" {{/if}} value='{{value}}'> {{value}} {{#if isDefault}} (default) {{/if}} </option>

{{/each}}

</select>
</td>
<td class="markdown">{{#if required}}<strong>{{/if}}{{{description}}}{{#if required}}</strong>{{/if}}</td>
Expand Down