@@ -99,7 +99,7 @@ class Argument(CachedPropertyModel):
9999 def __str__ (self ) -> str :
100100 return self .argument
101101
102- @cached_property
102+ @property
103103 def argument (self ) -> str :
104104 if self .field is None :
105105 type_hint = self .type_hint
@@ -113,9 +113,9 @@ def argument(self) -> str:
113113 )
114114 if self .default is None and self .required :
115115 return f'{ self .name } : { type_hint } '
116- return f'{ self .name } : { self . type_hint } = { self .default } '
116+ return f'{ self .name } : { type_hint } = { self .default } '
117117
118- @cached_property
118+ @property
119119 def snakecase (self ) -> str :
120120 if self .field is None :
121121 type_hint = self .type_hint
@@ -141,7 +141,6 @@ class Operation(CachedPropertyModel):
141141 parameters : List [Dict [str , Any ]] = []
142142 responses : Dict [UsefulStr , Any ] = {}
143143 deprecated : bool = False
144- imports : List [Import ] = []
145144 security : Optional [List [Dict [str , List [str ]]]] = None
146145 tags : Optional [List [str ]] = []
147146 request : Optional [Argument ] = None
@@ -152,9 +151,7 @@ class Operation(CachedPropertyModel):
152151 arguments_list : List [Argument ] = []
153152
154153 @classmethod
155- def merge_arguments_with_union (
156- cls , arguments : List [Argument ], imports : List [Import ]
157- ) -> List [Argument ]:
154+ def merge_arguments_with_union (cls , arguments : List [Argument ]) -> List [Argument ]:
158155 grouped_arguments : DefaultDict [str , List [Argument ]] = DefaultDict (list )
159156 for argument in arguments :
160157 grouped_arguments [argument .name ].append (argument )
@@ -187,18 +184,25 @@ def type(self) -> UsefulStr:
187184
188185 @property
189186 def arguments (self ) -> str :
190- sorted_arguments = Operation .merge_arguments_with_union (
191- self .arguments_list , self .imports
192- )
187+ sorted_arguments = Operation .merge_arguments_with_union (self .arguments_list )
193188 return ", " .join (argument .argument for argument in sorted_arguments )
194189
195190 @property
196191 def snake_case_arguments (self ) -> str :
197- sorted_arguments = Operation .merge_arguments_with_union (
198- self .arguments_list , self .imports
199- )
192+ sorted_arguments = Operation .merge_arguments_with_union (self .arguments_list )
200193 return ", " .join (argument .snakecase for argument in sorted_arguments )
201194
195+ @property
196+ def imports (self ) -> Imports :
197+ imports = Imports ()
198+ for argument in self .arguments_list :
199+ if isinstance (argument .field , list ):
200+ for field in argument .field :
201+ imports .append (field .data_type .import_ )
202+ elif argument .field :
203+ imports .append (argument .field .data_type .import_ )
204+ return imports
205+
202206 @cached_property
203207 def root_path (self ) -> UsefulStr :
204208 paths = self .path .split ("/" )
0 commit comments