@@ -306,64 +306,6 @@ def get_flat_params(dependant: Dependant) -> list[ModelField]:
306
306
)
307
307
308
308
309
- def expand_pydantic_model_for_openapi (param_field : ModelField ) -> list [ModelField ]:
310
- """
311
- Expands a Pydantic model parameter into individual fields for OpenAPI schema generation.
312
-
313
- Parameters
314
- ----------
315
- param_field: ModelField
316
- The field containing a Pydantic model
317
-
318
- Returns
319
- -------
320
- list[ModelField]
321
- List of individual ModelField objects for each field in the Pydantic model
322
- """
323
- from pydantic import BaseModel
324
-
325
- from aws_lambda_powertools .event_handler .openapi .compat import lenient_issubclass
326
-
327
- # Check if this is a Pydantic model in Query, Header, or Form
328
- if not (
329
- isinstance (param_field .field_info , (Query , Header , Form ))
330
- and lenient_issubclass (param_field .field_info .annotation , BaseModel )
331
- ):
332
- return [param_field ]
333
-
334
- # Get the Pydantic model class
335
- model_class = param_field .field_info .annotation
336
- field_info_template = param_field .field_info
337
-
338
- expanded_fields = []
339
-
340
- # Create individual fields for each field in the Pydantic model
341
- for field_name , field_def in model_class .model_fields .items ():
342
- # Create a new field_info for each model field
343
- individual_field_info = type (field_info_template )(
344
- default = field_def .default if field_def .default is not ... else None ,
345
- annotation = field_def .annotation ,
346
- alias = field_def .alias or field_name ,
347
- title = field_def .title ,
348
- description = field_def .description ,
349
- )
350
-
351
- # Create the ModelField using the internal function
352
- from aws_lambda_powertools .event_handler .openapi .params import _create_model_field
353
-
354
- individual_field = _create_model_field (
355
- field_info = individual_field_info ,
356
- type_annotation = field_def .annotation ,
357
- param_name = field_name ,
358
- is_path_param = False ,
359
- )
360
-
361
- if individual_field :
362
- expanded_fields .append (individual_field )
363
-
364
- return expanded_fields
365
-
366
-
367
309
def get_body_field (* , dependant : Dependant , name : str ) -> ModelField | None :
368
310
"""
369
311
Get the Body field for a given Dependant object.
0 commit comments