Merge pull request #1227 from ponelat/fix/default-boolean
allow default to be false, tweak "required" in param_list
This commit is contained in:
@@ -30,7 +30,13 @@ SwaggerUi.Views.ParameterView = Backbone.View.extend({
|
|||||||
this.model.paramType = this.model.in || this.model.paramType;
|
this.model.paramType = this.model.in || this.model.paramType;
|
||||||
this.model.isBody = this.model.paramType === 'body' || this.model.in === 'body';
|
this.model.isBody = this.model.paramType === 'body' || this.model.in === 'body';
|
||||||
this.model.isFile = type && type.toLowerCase() === 'file';
|
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();
|
this.model.valueId = 'm' + this.model.name + Math.random();
|
||||||
|
|
||||||
if (this.model.allowableValues) {
|
if (this.model.allowableValues) {
|
||||||
@@ -99,4 +105,4 @@ SwaggerUi.Views.ParameterView = Backbone.View.extend({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,23 +1,17 @@
|
|||||||
<td class='code{{#if required}} required{{/if}}'><label for='{{valueId}}'>{{name}}</labe></td>
|
<td class='code{{#if required}} required{{/if}}'><label for='{{valueId}}'>{{name}}</labe></td>
|
||||||
<td>
|
<td>
|
||||||
<select {{#isArray this}} multiple='multiple'{{/isArray}} class={{#if required}}'parameter required'{{else}}'parameter'{{/if}} name='{{name}}' id='{{valueId}}'>
|
<select {{#isArray this}} multiple="multiple"{{/isArray}} class="parameter {{#if required}} required {{/if}}" name="{{name}}" id="{{valueId}}">
|
||||||
{{#if required}}
|
|
||||||
{{else}}
|
{{#unless required}}
|
||||||
{{#if default}}
|
<option {{#unless hasDefault}} selected="" {{/unless}} value=''></option>
|
||||||
{{else}}
|
{{/unless}}
|
||||||
{{#isArray this}}
|
|
||||||
{{else}}
|
|
||||||
<option selected="" value=''></option>
|
|
||||||
{{/isArray}}
|
|
||||||
{{/if}}
|
|
||||||
{{/if}}
|
|
||||||
{{#each allowableValues.descriptiveValues}}
|
{{#each allowableValues.descriptiveValues}}
|
||||||
{{#if isDefault}}
|
|
||||||
<option selected="" value='{{value}}'>{{value}} (default)</option>
|
<option {{#if isDefault}} selected="" {{/if}} value='{{value}}'> {{value}} {{#if isDefault}} (default) {{/if}} </option>
|
||||||
{{else}}
|
|
||||||
<option value='{{value}}'>{{value}}</option>
|
|
||||||
{{/if}}
|
|
||||||
{{/each}}
|
{{/each}}
|
||||||
|
|
||||||
</select>
|
</select>
|
||||||
</td>
|
</td>
|
||||||
<td class="markdown">{{#if required}}<strong>{{/if}}{{{description}}}{{#if required}}</strong>{{/if}}</td>
|
<td class="markdown">{{#if required}}<strong>{{/if}}{{{description}}}{{#if required}}</strong>{{/if}}</td>
|
||||||
|
|||||||
Reference in New Issue
Block a user