Skip to content

Commit c47ab63

Browse files
refactor(event_handler): refactoring params to reduce code (#8124)
chore: refactoring params
1 parent 7af52e4 commit c47ab63

File tree

1 file changed

+0
-242
lines changed
  • aws_lambda_powertools/event_handler/openapi

1 file changed

+0
-242
lines changed

aws_lambda_powertools/event_handler/openapi/params.py

Lines changed: 0 additions & 242 deletions
Original file line numberDiff line numberDiff line change
@@ -286,64 +286,6 @@ def __init__(
286286
json_schema_extra: dict[str, Any] | None = None,
287287
**extra: Any,
288288
):
289-
"""
290-
Constructs a new Path param.
291-
292-
Parameters
293-
----------
294-
default: Any
295-
The default value of the parameter
296-
default_factory: Callable[[], Any], optional
297-
Callable that will be called when a default value is needed for this field
298-
annotation: Any, optional
299-
The type annotation of the parameter
300-
alias: str, optional
301-
The public name of the field
302-
alias_priority: int, optional
303-
Priority of the alias. This affects whether an alias generator is used
304-
validation_alias: str | AliasPath | AliasChoices | None, optional
305-
Alias to be used for validation only
306-
serialization_alias: str | AliasPath | AliasChoices | None, optional
307-
Alias to be used for serialization only
308-
title: str, optional
309-
The title of the parameter
310-
description: str, optional
311-
The description of the parameter
312-
gt: float, optional
313-
Only applies to numbers, required the field to be "greater than"
314-
ge: float, optional
315-
Only applies to numbers, required the field to be "greater than or equal"
316-
lt: float, optional
317-
Only applies to numbers, required the field to be "less than"
318-
le: float, optional
319-
Only applies to numbers, required the field to be "less than or equal"
320-
min_length: int, optional
321-
Only applies to strings, required the field to have a minimum length
322-
max_length: int, optional
323-
Only applies to strings, required the field to have a maximum length
324-
pattern: str, optional
325-
Only applies to strings, requires the field match against a regular expression pattern string
326-
discriminator: str, optional
327-
Parameter field name for discriminating the type in a tagged union
328-
strict: bool, optional
329-
Enables Pydantic's strict mode for the field
330-
multiple_of: float, optional
331-
Only applies to numbers, requires the field to be a multiple of the given value
332-
allow_inf_nan: bool, optional
333-
Only applies to numbers, requires the field to allow infinity and NaN values
334-
max_digits: int, optional
335-
Only applies to Decimals, requires the field to have a maxmium number of digits within the decimal.
336-
decimal_places: int, optional
337-
Only applies to Decimals, requires the field to have at most a number of decimal places
338-
examples: list[Any], optional
339-
A list of examples for the parameter
340-
deprecated: bool, optional
341-
If `True`, the parameter will be marked as deprecated
342-
include_in_schema: bool, optional
343-
If `False`, the parameter will be excluded from the generated OpenAPI schema
344-
json_schema_extra: dict[str, Any], optional
345-
Extra values to include in the generated OpenAPI schema
346-
"""
347289
if default is not ...:
348290
raise AssertionError("Path parameters cannot have a default value")
349291

@@ -418,64 +360,6 @@ def __init__(
418360
json_schema_extra: dict[str, Any] | None = None,
419361
**extra: Any,
420362
):
421-
"""
422-
Constructs a new Query param.
423-
424-
Parameters
425-
----------
426-
default: Any
427-
The default value of the parameter
428-
default_factory: Callable[[], Any], optional
429-
Callable that will be called when a default value is needed for this field
430-
annotation: Any, optional
431-
The type annotation of the parameter
432-
alias: str, optional
433-
The public name of the field
434-
alias_priority: int, optional
435-
Priority of the alias. This affects whether an alias generator is used
436-
validation_alias: str | AliasPath | AliasChoices | None, optional
437-
Alias to be used for validation only
438-
serialization_alias: str | AliasPath | AliasChoices | None, optional
439-
Alias to be used for serialization only
440-
title: str, optional
441-
The title of the parameter
442-
description: str, optional
443-
The description of the parameter
444-
gt: float, optional
445-
Only applies to numbers, required the field to be "greater than"
446-
ge: float, optional
447-
Only applies to numbers, required the field to be "greater than or equal"
448-
lt: float, optional
449-
Only applies to numbers, required the field to be "less than"
450-
le: float, optional
451-
Only applies to numbers, required the field to be "less than or equal"
452-
min_length: int, optional
453-
Only applies to strings, required the field to have a minimum length
454-
max_length: int, optional
455-
Only applies to strings, required the field to have a maximum length
456-
pattern: str, optional
457-
Only applies to strings, requires the field match against a regular expression pattern string
458-
discriminator: str, optional
459-
Parameter field name for discriminating the type in a tagged union
460-
strict: bool, optional
461-
Enables Pydantic's strict mode for the field
462-
multiple_of: float, optional
463-
Only applies to numbers, requires the field to be a multiple of the given value
464-
allow_inf_nan: bool, optional
465-
Only applies to numbers, requires the field to allow infinity and NaN values
466-
max_digits: int, optional
467-
Only applies to Decimals, requires the field to have a maxmium number of digits within the decimal.
468-
decimal_places: int, optional
469-
Only applies to Decimals, requires the field to have at most a number of decimal places
470-
examples: list[Any], optional
471-
A list of examples for the parameter
472-
deprecated: bool, optional
473-
If `True`, the parameter will be marked as deprecated
474-
include_in_schema: bool, optional
475-
If `False`, the parameter will be excluded from the generated OpenAPI schema
476-
json_schema_extra: dict[str, Any], optional
477-
Extra values to include in the generated OpenAPI schema
478-
"""
479363
super().__init__(
480364
default=default,
481365
default_factory=default_factory,
@@ -550,67 +434,6 @@ def __init__(
550434
json_schema_extra: dict[str, Any] | None = None,
551435
**extra: Any,
552436
):
553-
"""
554-
Constructs a new Query param.
555-
556-
Parameters
557-
----------
558-
default: Any
559-
The default value of the parameter
560-
default_factory: Callable[[], Any], optional
561-
Callable that will be called when a default value is needed for this field
562-
annotation: Any, optional
563-
The type annotation of the parameter
564-
alias: str, optional
565-
The public name of the field
566-
alias_priority: int, optional
567-
Priority of the alias. This affects whether an alias generator is used
568-
validation_alias: str | AliasPath | AliasChoices | None, optional
569-
Alias to be used for validation only
570-
serialization_alias: str | AliasPath | AliasChoices | None, optional
571-
Alias to be used for serialization only
572-
convert_underscores: bool
573-
If true convert "_" to "-"
574-
See RFC: https://www.rfc-editor.org/rfc/rfc9110.html#name-field-name-registry
575-
title: str, optional
576-
The title of the parameter
577-
description: str, optional
578-
The description of the parameter
579-
gt: float, optional
580-
Only applies to numbers, required the field to be "greater than"
581-
ge: float, optional
582-
Only applies to numbers, required the field to be "greater than or equal"
583-
lt: float, optional
584-
Only applies to numbers, required the field to be "less than"
585-
le: float, optional
586-
Only applies to numbers, required the field to be "less than or equal"
587-
min_length: int, optional
588-
Only applies to strings, required the field to have a minimum length
589-
max_length: int, optional
590-
Only applies to strings, required the field to have a maximum length
591-
pattern: str, optional
592-
Only applies to strings, requires the field match against a regular expression pattern string
593-
discriminator: str, optional
594-
Parameter field name for discriminating the type in a tagged union
595-
strict: bool, optional
596-
Enables Pydantic's strict mode for the field
597-
multiple_of: float, optional
598-
Only applies to numbers, requires the field to be a multiple of the given value
599-
allow_inf_nan: bool, optional
600-
Only applies to numbers, requires the field to allow infinity and NaN values
601-
max_digits: int, optional
602-
Only applies to Decimals, requires the field to have a maxmium number of digits within the decimal.
603-
decimal_places: int, optional
604-
Only applies to Decimals, requires the field to have at most a number of decimal places
605-
examples: list[Any], optional
606-
A list of examples for the parameter
607-
deprecated: bool, optional
608-
If `True`, the parameter will be marked as deprecated
609-
include_in_schema: bool, optional
610-
If `False`, the parameter will be excluded from the generated OpenAPI schema
611-
json_schema_extra: dict[str, Any], optional
612-
Extra values to include in the generated OpenAPI schema
613-
"""
614437
self.convert_underscores = convert_underscores
615438
self._alias = alias
616439

@@ -665,71 +488,6 @@ class Cookie(Param): # type: ignore[misc]
665488

666489
in_ = ParamTypes.cookie
667490

668-
def __init__(
669-
self,
670-
default: Any = Undefined,
671-
*,
672-
default_factory: Callable[[], Any] | None = _Unset,
673-
annotation: Any | None = None,
674-
alias: str | None = None,
675-
alias_priority: int | None = _Unset,
676-
# MAINTENANCE: update when deprecating Pydantic v1, import these types
677-
# str | AliasPath | AliasChoices | None
678-
validation_alias: str | None = _Unset,
679-
serialization_alias: str | None = None,
680-
title: str | None = None,
681-
description: str | None = None,
682-
gt: float | None = None,
683-
ge: float | None = None,
684-
lt: float | None = None,
685-
le: float | None = None,
686-
min_length: int | None = None,
687-
max_length: int | None = None,
688-
pattern: str | None = None,
689-
discriminator: str | None = None,
690-
strict: bool | None = _Unset,
691-
multiple_of: float | None = _Unset,
692-
allow_inf_nan: bool | None = _Unset,
693-
max_digits: int | None = _Unset,
694-
decimal_places: int | None = _Unset,
695-
examples: list[Any] | None = None,
696-
openapi_examples: dict[str, Example] | None = None,
697-
deprecated: bool | None = None,
698-
include_in_schema: bool = True,
699-
json_schema_extra: dict[str, Any] | None = None,
700-
**extra: Any,
701-
):
702-
super().__init__(
703-
default=default,
704-
default_factory=default_factory,
705-
annotation=annotation,
706-
alias=alias,
707-
alias_priority=alias_priority,
708-
validation_alias=validation_alias,
709-
serialization_alias=serialization_alias,
710-
title=title,
711-
description=description,
712-
gt=gt,
713-
ge=ge,
714-
lt=lt,
715-
le=le,
716-
min_length=min_length,
717-
max_length=max_length,
718-
pattern=pattern,
719-
discriminator=discriminator,
720-
strict=strict,
721-
multiple_of=multiple_of,
722-
allow_inf_nan=allow_inf_nan,
723-
max_digits=max_digits,
724-
decimal_places=decimal_places,
725-
deprecated=deprecated,
726-
examples=examples,
727-
openapi_examples=openapi_examples,
728-
include_in_schema=include_in_schema,
729-
json_schema_extra=json_schema_extra,
730-
**extra,
731-
)
732-
733491

734492
class Body(FieldInfo): # type: ignore[misc]
735493
"""

0 commit comments

Comments
 (0)