Skip to content

Commit fdad456

Browse files
committed
[API] Generator: Fixes order of arguments.clone
When updating the code generator for 8.x, the order of `arguments.clone` in the generated code was changed. This would make it so that we would modify the arguments before cloning them, which is undesired. Addresses #1727
1 parent 2bc1f2b commit fdad456

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

elasticsearch-api/utils/thor/templates/_method_setup.erb

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
# specific language governing permissions and limitations
1717
# under the License.
1818
%>
19-
<%= ' '*(@namespace_depth+4) %>arguments = arguments.clone
2019
<%- if @method_name == 'search' -%>
2120
arguments[:index] = UNDERSCORE_ALL if ! arguments[:index] && arguments[:type]
2221
<%- end -%>

elasticsearch-api/utils/thor/templates/method.erb

+2
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,14 @@ module Elasticsearch
3333
<%= ' '*(@namespace_depth+2) %>end
3434
<%- else -%>
3535
<%- if @method_name == 'get_field_mapping' %>
36+
arguments = arguments.clone
3637
_fields = arguments.delete(:field) || arguments.delete(:fields)
3738
raise ArgumentError, "Required argument 'field' missing" unless _fields
3839
<%- else -%>
3940
<%- @required_parts.each do |required| %><%# Arguments -%>
4041
<%= ' '*(@namespace_depth+3) + "raise ArgumentError, \"Required argument '#{required}' missing\" unless arguments[:#{required}]" + "\n" -%>
4142
<%- end -%>
43+
arguments = arguments.clone
4244
<%- end -%>
4345
headers = arguments.delete(:headers) || {}
4446
<%- #Body %>

0 commit comments

Comments
 (0)