Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fix crash when endpoint has no methods or method has no parameters. a…

…lso fix parameter names not loading
  • Loading branch information...
commit 214eb4a3d5c33a482759c9b0de0e591161085b6b 1 parent 6c3b4df
@brandonmwest authored
Showing with 136 additions and 134 deletions.
  1. +55 −54 views/_methods.haml
  2. +81 −80 views/_parameters.haml
View
109 views/_methods.haml
@@ -1,66 +1,67 @@
%ul.methods
-method_count = 0
- -endpoint["methods"].each do |m|
- -method_count=method_count+1
+ -if endpoint["methods"].length > 0
+ -endpoint["methods"].each do |m|
+ -method_count=method_count+1
- %li.method{:endpointIndex => endpointIndex, :methodIndex => method_count}
- %legend
- .section.clickable{"target" => "#endpoint#{endpointIndex}method#{method_count}"}
- %a{:name => "endpoint#{endpointIndex}method#{method_count}"}
- Method:
- %span.methodNameSpan #{m.MethodName}
+ %li.method{:endpointIndex => endpointIndex, :methodIndex => method_count}
+ %legend
+ .section.clickable{"target" => "#endpoint#{endpointIndex}method#{method_count}"}
+ %a{:name => "endpoint#{endpointIndex}method#{method_count}"}
+ Method:
+ %span.methodNameSpan #{m.MethodName}
- .methodContainer.hide{:id => "endpoint#{endpointIndex}method#{method_count}"}
- %span.method-controls
- %a.btn.btn-danger.removeMethod
- %i.icon-trash.icon-white
- Delete Method
+ .methodContainer.hide{:id => "endpoint#{endpointIndex}method#{method_count}"}
+ %span.method-controls
+ %a.btn.btn-danger.removeMethod
+ %i.icon-trash.icon-white
+ Delete Method
- .control-group
- %label.control-label{:for => "endpoints[#{endpointIndex}].methods[#{method_count}].MethodName"}
- Method Name
- .controls
- %input.methodName{:name => "endpoints[#{endpointIndex}].methods[#{method_count}].MethodName", :id => "endpoints.endpoint[#{endpointIndex}].methods[#{method_count}].MethodName", :value => "#{m.MethodName}"}
+ .control-group
+ %label.control-label{:for => "endpoints[#{endpointIndex}].methods[#{method_count}].MethodName"}
+ Method Name
+ .controls
+ %input.methodName{:name => "endpoints[#{endpointIndex}].methods[#{method_count}].MethodName", :id => "endpoints.endpoint[#{endpointIndex}].methods[#{method_count}].MethodName", :value => "#{m.MethodName}"}
- .control-group
- %label.control-label{:for => "endpoints[#{endpointIndex}].methods[#{method_count}].Synopsis"}
- Synopsis
- .controls
- %textarea{:name => "endpoints[#{endpointIndex}].methods[#{method_count}].Synopsis", :id => "endpoints[#{endpointIndex}].methods[#{method_count}].Synopsis"}#{m.Synopsis}
+ .control-group
+ %label.control-label{:for => "endpoints[#{endpointIndex}].methods[#{method_count}].Synopsis"}
+ Synopsis
+ .controls
+ %textarea{:name => "endpoints[#{endpointIndex}].methods[#{method_count}].Synopsis", :id => "endpoints[#{endpointIndex}].methods[#{method_count}].Synopsis"}#{m.Synopsis}
- .control-group
- %label.control-label{:for => "endpoints[#{endpointIndex}].methods[#{method_count}].HTTPMethod"}
- HTTP Method (GET, POST, PUT, etc)
- .controls
- %input{:name => "endpoints[#{endpointIndex}].methods[#{method_count}].HTTPMethod", :id => "endpoints[#{endpointIndex}].methods[#{method_count}].HTTPMethod", :value => "#{m.HTTPMethod}"}
+ .control-group
+ %label.control-label{:for => "endpoints[#{endpointIndex}].methods[#{method_count}].HTTPMethod"}
+ HTTP Method (GET, POST, PUT, etc)
+ .controls
+ %input{:name => "endpoints[#{endpointIndex}].methods[#{method_count}].HTTPMethod", :id => "endpoints[#{endpointIndex}].methods[#{method_count}].HTTPMethod", :value => "#{m.HTTPMethod}"}
- .control-group
- %label.control-label{:for => "endpoints[#{endpointIndex}].methods[#{method_count}].URI"}
- URI
- .controls
- %input{:name => "endpoints[#{endpointIndex}].methods[#{method_count}].URI", :id => "endpoints[#{endpointIndex}].methods[#{method_count}].URI", :value => "#{m.URI}"}
+ .control-group
+ %label.control-label{:for => "endpoints[#{endpointIndex}].methods[#{method_count}].URI"}
+ URI
+ .controls
+ %input{:name => "endpoints[#{endpointIndex}].methods[#{method_count}].URI", :id => "endpoints[#{endpointIndex}].methods[#{method_count}].URI", :value => "#{m.URI}"}
- .control-group
- %label.control-label{:for => "endpoints[#{endpointIndex}].methods[#{method_count}].RequiresOAuth"}
- Requires OAuth?
- .controls
- %label.radio
- %input{:type => "radio", :name => "endpoints[#{endpointIndex}].methods[#{method_count}].RequiresOAuth", |
- :id => "endpoints[#{endpointIndex}].methods[#{method_count}].RequiresOAuth.Yes", |
- :value => "Y", |
- :checked => m.RequiresOAuth == "Y"}
- %span Yes
- %label.radio
- %input{:type => "radio", :name => "endpoints[#{endpointIndex}].methods[#{method_count}].RequiresOAuth", |
- :id => "endpoints[#{endpointIndex}].methods[#{method_count}].RequiresOAuth.No", |
- :value => "N", |
- :checked => m.RequiresOAuth == "N"}
- %span No
+ .control-group
+ %label.control-label{:for => "endpoints[#{endpointIndex}].methods[#{method_count}].RequiresOAuth"}
+ Requires OAuth?
+ .controls
+ %label.radio
+ %input{:type => "radio", :name => "endpoints[#{endpointIndex}].methods[#{method_count}].RequiresOAuth", |
+ :id => "endpoints[#{endpointIndex}].methods[#{method_count}].RequiresOAuth.Yes", |
+ :value => "Y", |
+ :checked => m.RequiresOAuth == "Y"}
+ %span Yes
+ %label.radio
+ %input{:type => "radio", :name => "endpoints[#{endpointIndex}].methods[#{method_count}].RequiresOAuth", |
+ :id => "endpoints[#{endpointIndex}].methods[#{method_count}].RequiresOAuth.No", |
+ :value => "N", |
+ :checked => m.RequiresOAuth == "N"}
+ %span No
- %span.method-controls
- %a.btn.btn-info.addButton.addParameter
- %i.icon-plus.icon-white
- Add Parameter
- = partial :parameters, :locals => {:m => m, :methodIndex => method_count, :endpointIndex => endpointIndex}
+ %span.method-controls
+ %a.btn.btn-info.addButton.addParameter
+ %i.icon-plus.icon-white
+ Add Parameter
+ = partial :parameters, :locals => {:m => m, :methodIndex => method_count, :endpointIndex => endpointIndex}
%input{:type=>"hidden", :value => method_count, :id=>"endpoint#{endpointIndex}MethodCounter"}
View
161 views/_parameters.haml
@@ -1,94 +1,95 @@
%ul.parameters
-param_count = 0
- -m.parameters.each do |p|
- -param_count=param_count+1
+ -if m.parameters
+ -m.parameters.each do |p|
+ -param_count=param_count+1
- %li.parameter{:endpointIndex => endpointIndex, :methodIndex => methodIndex, :parameterIndex => param_count}
- %legend
- .section.clickable{"parent" => "#endpoint#{endpointIndex}method#{methodIndex}", "target" => "#endpoint#{endpointIndex}method#{methodIndex}parameter#{param_count}"}
- Parameter:
- %span.parameterNameSpan #{p.Name}
+ %li.parameter{:endpointIndex => endpointIndex, :methodIndex => methodIndex, :parameterIndex => param_count}
+ %legend
+ .section.clickable{"parent" => "#endpoint#{endpointIndex}method#{methodIndex}", "target" => "#endpoint#{endpointIndex}method#{methodIndex}parameter#{param_count}"}
+ Parameter:
+ %span.parameterNameSpan #{p.ParameterName}
- .parameterContainer.hide{:id => "endpoint#{endpointIndex}method#{methodIndex}parameter#{param_count}"}
- %span.method-controls
+ .parameterContainer.hide{:id => "endpoint#{endpointIndex}method#{methodIndex}parameter#{param_count}"}
%span.method-controls
- %a.btn.btn-danger.removeParameter
- %i.icon-trash.icon-white
- Delete Parameter
+ %span.method-controls
+ %a.btn.btn-danger.removeParameter
+ %i.icon-trash.icon-white
+ Delete Parameter
- .control-group
- %label.control-label{:for => "endpoints[#{endpointIndex}].methods[#{methodIndex}].parameters[#{param_count}].ParameterName"} Parameter Name
- .controls
- %input.parameterName{:name => "endpoints[#{endpointIndex}].methods[#{methodIndex}].parameters[#{param_count}].ParameterName", |
- :id => "endpoints[#{endpointIndex}].methods[#{methodIndex}].parameters[#{param_count}].ParameterName", |
- :value => "#{p.Name}"} |
- .control-group
- %label.control-label{:for => "endpoints[#{endpointIndex}].methods[#{methodIndex}].parameters[#{param_count}].Description"} Description
- .controls
- %textarea{:name => "endpoints[#{endpointIndex}].methods[#{methodIndex}].parameters[#{param_count}].Description", |
- :id => "endpoints[#{endpointIndex}].methods[#{methodIndex}].parameters[#{param_count}].Description"} |
- #{p.Description} |
- .control-group
- %label.control-label Required?
- .controls
- %label.radio
- %input{:type => "radio", :name => "endpoints[#{endpointIndex}].methods[#{methodIndex}].parameters[#{param_count}].Required", |
- :id => "endpoints[#{endpointIndex}].methods[#{methodIndex}].parameters[#{param_count}].Required.Yes", |
- :value => "Y", |
- :checked => p.Required == "Y"}
- Yes
+ .control-group
+ %label.control-label{:for => "endpoints[#{endpointIndex}].methods[#{methodIndex}].parameters[#{param_count}].ParameterName"} Parameter Name
+ .controls
+ %input.parameterName{:name => "endpoints[#{endpointIndex}].methods[#{methodIndex}].parameters[#{param_count}].ParameterName", |
+ :id => "endpoints[#{endpointIndex}].methods[#{methodIndex}].parameters[#{param_count}].ParameterName", |
+ :value => "#{p.ParameterName}"} |
+ .control-group
+ %label.control-label{:for => "endpoints[#{endpointIndex}].methods[#{methodIndex}].parameters[#{param_count}].Description"} Description
+ .controls
+ %textarea{:name => "endpoints[#{endpointIndex}].methods[#{methodIndex}].parameters[#{param_count}].Description", |
+ :id => "endpoints[#{endpointIndex}].methods[#{methodIndex}].parameters[#{param_count}].Description"} |
+ #{p.Description} |
+ .control-group
+ %label.control-label Required?
+ .controls
+ %label.radio
+ %input{:type => "radio", :name => "endpoints[#{endpointIndex}].methods[#{methodIndex}].parameters[#{param_count}].Required", |
+ :id => "endpoints[#{endpointIndex}].methods[#{methodIndex}].parameters[#{param_count}].Required.Yes", |
+ :value => "Y", |
+ :checked => p.Required == "Y"}
+ Yes
- %label.radio
- %input{:type => "radio", :name => "endpoints[#{endpointIndex}].methods[#{methodIndex}].parameters[#{param_count}].Required", |
- :id => "endpoints[#{endpointIndex}].methods[#{methodIndex}].parameters[#{param_count}].Required.No", |
- :value => "N", |
- :checked => p.Required == "N"}
- No
- .control-group
- %label.control-label{:for => "endpoints[#{endpointIndex}].methods[#{methodIndex}].parameters[#{param_count}].Default"} Default value
- .controls
- %input{:name => "endpoints[#{endpointIndex}].methods[#{methodIndex}].parameters[#{param_count}].Default", |
- :id => "endpoints[#{endpointIndex}].methods[#{methodIndex}].parameters[#{param_count}].Default", |
- :value => "#{p.Default}"} |
+ %label.radio
+ %input{:type => "radio", :name => "endpoints[#{endpointIndex}].methods[#{methodIndex}].parameters[#{param_count}].Required", |
+ :id => "endpoints[#{endpointIndex}].methods[#{methodIndex}].parameters[#{param_count}].Required.No", |
+ :value => "N", |
+ :checked => p.Required == "N"}
+ No
+ .control-group
+ %label.control-label{:for => "endpoints[#{endpointIndex}].methods[#{methodIndex}].parameters[#{param_count}].Default"} Default value
+ .controls
+ %input{:name => "endpoints[#{endpointIndex}].methods[#{methodIndex}].parameters[#{param_count}].Default", |
+ :id => "endpoints[#{endpointIndex}].methods[#{methodIndex}].parameters[#{param_count}].Default", |
+ :value => "#{p.Default}"} |
- .control-group
- %label.control-label{:for => "endpoints[#{endpointIndex}].methods[#{methodIndex}].parameters[#{param_count}].Type"} Data type
- -#should be a dropdown
- .controls
- %label.radio
- %input.dataType{:type => "radio", |
- :name => "endpoints[#{endpointIndex}].methods[#{methodIndex}].parameters[#{param_count}].Type", |
- :id => "endpoints[#{endpointIndex}].methods[#{methodIndex}].parameters[#{param_count}].Type.Boolean", |
- :value => "boolean", |
- :checked => p.Type == "boolean"}
- Boolean
+ .control-group
+ %label.control-label{:for => "endpoints[#{endpointIndex}].methods[#{methodIndex}].parameters[#{param_count}].Type"} Data type
+ -#should be a dropdown
+ .controls
+ %label.radio
+ %input.dataType{:type => "radio", |
+ :name => "endpoints[#{endpointIndex}].methods[#{methodIndex}].parameters[#{param_count}].Type", |
+ :id => "endpoints[#{endpointIndex}].methods[#{methodIndex}].parameters[#{param_count}].Type.Boolean", |
+ :value => "boolean", |
+ :checked => p.Type == "boolean"}
+ Boolean
- %label.radio
- %input.dataType{:type => "radio", |
- :name => "endpoints[#{endpointIndex}].methods[#{methodIndex}].parameters[#{param_count}].Type", |
- :id => "endpoints[#{endpointIndex}].methods[#{methodIndex}].parameters[#{param_count}].Type.Enumerated", |
- :value => "enumerated", |
- :checked => p.Type == "enumerated"}
- Enumerated ( JSON list of options, e.g. ["option1","option2"] )
+ %label.radio
+ %input.dataType{:type => "radio", |
+ :name => "endpoints[#{endpointIndex}].methods[#{methodIndex}].parameters[#{param_count}].Type", |
+ :id => "endpoints[#{endpointIndex}].methods[#{methodIndex}].parameters[#{param_count}].Type.Enumerated", |
+ :value => "enumerated", |
+ :checked => p.Type == "enumerated"}
+ Enumerated ( JSON list of options, e.g. ["option1","option2"] )
- .enumeratedList
- %input.enumeratedInput{:name => "endpoints[#{endpointIndex}].methods[#{methodIndex}].parameters[#{param_count}].EnumeratedList", |
- :id => "endpoints[#{endpointIndex}].methods[#{methodIndex}].parameters[#{param_count}].EnumeratedList", |
- :value => "#{p.EnumeratedList}", |
- :style => p.Type != "enumerated" ? 'display:none' : ''}
+ .enumeratedList
+ %input.enumeratedInput{:name => "endpoints[#{endpointIndex}].methods[#{methodIndex}].parameters[#{param_count}].EnumeratedList", |
+ :id => "endpoints[#{endpointIndex}].methods[#{methodIndex}].parameters[#{param_count}].EnumeratedList", |
+ :value => "#{p.EnumeratedList}", |
+ :style => p.Type != "enumerated" ? 'display:none' : ''}
- %label.radio
- %input.dataType{:type => "radio", |
- :name => "endpoints[#{endpointIndex}].methods[#{methodIndex}].parameters[#{param_count}].Type", |
- :id => "endpoints[#{endpointIndex}].methods[#{methodIndex}].parameters[#{param_count}].Type.Custom", |
- :value => "custom", |
- :checked => p.Type != "boolean" && p.Type != "enumerated"}
- Custom
+ %label.radio
+ %input.dataType{:type => "radio", |
+ :name => "endpoints[#{endpointIndex}].methods[#{methodIndex}].parameters[#{param_count}].Type", |
+ :id => "endpoints[#{endpointIndex}].methods[#{methodIndex}].parameters[#{param_count}].Type.Custom", |
+ :value => "custom", |
+ :checked => p.Type != "boolean" && p.Type != "enumerated"}
+ Custom
- .custom
- %input.customInput{:name => "endpoints[#{endpointIndex}].methods[#{methodIndex}].parameters[#{param_count}].Type", |
- :id => "endpoints[#{endpointIndex}].methods[#{methodIndex}].parameters[#{param_count}].Type", |
- :value => "#{p.Type}" , |
- :style => p.Type == "boolean" || p.Type == "enumerated" ? 'display:none' : ''}
+ .custom
+ %input.customInput{:name => "endpoints[#{endpointIndex}].methods[#{methodIndex}].parameters[#{param_count}].Type", |
+ :id => "endpoints[#{endpointIndex}].methods[#{methodIndex}].parameters[#{param_count}].Type", |
+ :value => "#{p.Type}" , |
+ :style => p.Type == "boolean" || p.Type == "enumerated" ? 'display:none' : ''}
%input{:type=>"hidden", :value => param_count, :id=>"endpoint#{endpointIndex}Method#{methodIndex}ParameterCounter"}
Please sign in to comment.
Something went wrong with that request. Please try again.