Skip to content

Commit

Permalink
Blank optional parameters omitted from sample request
Browse files Browse the repository at this point in the history
  • Loading branch information
tommybananas committed May 18, 2017
1 parent 940db62 commit 53dbbeb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion template/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ <h4><input type="radio" data-sample-request-param-group-id="sample-request-param
{{#each this}}
<label class="col-md-3 control-label" for="sample-request-param-field-{{field}}">{{field}}</label>
<div class="input-group">
<input id="sample-request-param-field-{{field}}" type="text" placeholder="{{field}}" class="form-control sample-request-param" data-sample-request-param-name="{{field}}" data-sample-request-param-group="sample-request-param-{{@../index}}">
<input id="sample-request-param-field-{{field}}" type="text" placeholder="{{field}}" class="form-control sample-request-param" data-sample-request-param-name="{{field}}" data-sample-request-param-group="sample-request-param-{{@../index}}" {{#if optional}}data-sample-request-param-optional="true"{{/if}}>
<div class="input-group-addon">{{{type}}}</div>
</div>
{{/each}}
Expand Down
4 changes: 3 additions & 1 deletion template/utils/send_sample_request.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ define([
var paramType = {};
$root.find(".sample-request-param:checked").each(function(i, element) {
var group = $(element).data("sample-request-param-group-id");
$root.find("[data-sample-request-param-group=\"" + group + "\"]").each(function(i, element) {
$root.find("[data-sample-request-param-group=\"" + group + "\"]").not(function(){
return $(this).val() == "" && $(this).is("[data-sample-request-param-optional='true']");
}).each(function(i, element) {
var key = $(element).data("sample-request-param-name");
var value = element.value;
if ( ! element.optional && element.defaultValue !== '') {
Expand Down

0 comments on commit 53dbbeb

Please sign in to comment.