@@ -133,22 +133,24 @@ def action(self, *args, **kwargs):
133133 Example:
134134 api.action(['cluster', 'create'], name='testcluster')
135135 """
136- overrides = None
137-
138- if args [0 ][- 1 ] == 'list' :
139- # Removing query parameters if they exist in path parameters
140- path = args [0 ]
141- link = self .schema [path [0 ]]
142- for item in path [1 :]:
143- link = link [item ]
144-
145- fields = []
146- path_fields = [field .name for field in link .fields if field .location == 'path' ]
147- for field in link .fields :
148- if not (field .location == 'query' and field .name in path_fields ):
149- fields .append (field )
150- fields = tuple (fields )
151- overrides = {'fields' : fields }
136+
137+ # After parsing the schema, fields for a query, a form, or a path may appear that have
138+ # the same names, which may cause the field value to go to the wrong place.
139+ # Path fields take precedence over query and form fields, so if there are path fields
140+ # and query or form fields with the same name, we delete the query and form fields
141+ # with the given name.
142+ path = args [0 ]
143+ link = self .schema [path [0 ]]
144+ for item in path [1 :]:
145+ link = link [item ]
146+
147+ fields = []
148+ path_fields = [field .name for field in link .fields if field .location == 'path' ]
149+ for field in link .fields :
150+ if not (field .location in ('query' , 'form' ) and field .name in path_fields ):
151+ fields .append (field )
152+ fields = tuple (fields )
153+ overrides = {'fields' : fields }
152154
153155 data = self .client .action (self .schema , * args , overrides = overrides , ** kwargs )
154156 self ._check_for_error (data )
0 commit comments