Skip to content

Commit 765781c

Browse files
docs(event_handlers): new data validation and OpenAPI feature (#3386)
Co-authored-by: heitorlessa <[email protected]>
1 parent 89a92b7 commit 765781c

26 files changed

+1162
-4
lines changed

aws_lambda_powertools/event_handler/openapi/params.py

+174
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,64 @@ def __init__(
117117
json_schema_extra: Union[Dict[str, Any], None] = None,
118118
**extra: Any,
119119
):
120+
"""
121+
Constructs a new Param.
122+
123+
Parameters
124+
----------
125+
default: Any
126+
The default value of the parameter
127+
default_factory: Callable[[], Any], optional
128+
Callable that will be called when a default value is needed for this field
129+
annotation: Any, optional
130+
The type annotation of the parameter
131+
alias: str, optional
132+
The public name of the field
133+
alias_priority: int, optional
134+
Priority of the alias. This affects whether an alias generator is used
135+
validation_alias: str | AliasPath | AliasChoices | None, optional
136+
Alias to be used for validation only
137+
serialization_alias: str | AliasPath | AliasChoices | None, optional
138+
Alias to be used for serialization only
139+
title: str, optional
140+
The title of the parameter
141+
description: str, optional
142+
The description of the parameter
143+
gt: float, optional
144+
Only applies to numbers, required the field to be "greater than"
145+
ge: float, optional
146+
Only applies to numbers, required the field to be "greater than or equal"
147+
lt: float, optional
148+
Only applies to numbers, required the field to be "less than"
149+
le: float, optional
150+
Only applies to numbers, required the field to be "less than or equal"
151+
min_length: int, optional
152+
Only applies to strings, required the field to have a minimum length
153+
max_length: int, optional
154+
Only applies to strings, required the field to have a maximum length
155+
pattern: str, optional
156+
Only applies to strings, requires the field match against a regular expression pattern string
157+
discriminator: str, optional
158+
Parameter field name for discriminating the type in a tagged union
159+
strict: bool, optional
160+
Enables Pydantic's strict mode for the field
161+
multiple_of: float, optional
162+
Only applies to numbers, requires the field to be a multiple of the given value
163+
allow_inf_nan: bool, optional
164+
Only applies to numbers, requires the field to allow infinity and NaN values
165+
max_digits: int, optional
166+
Only applies to Decimals, requires the field to have a maxmium number of digits within the decimal.
167+
decimal_places: int, optional
168+
Only applies to Decimals, requires the field to have at most a number of decimal places
169+
examples: List[Any], optional
170+
A list of examples for the parameter
171+
deprecated: bool, optional
172+
If `True`, the parameter will be marked as deprecated
173+
include_in_schema: bool, optional
174+
If `False`, the parameter will be excluded from the generated OpenAPI schema
175+
json_schema_extra: Dict[str, Any], optional
176+
Extra values to include in the generated OpenAPI schema
177+
"""
120178
self.deprecated = deprecated
121179
self.include_in_schema = include_in_schema
122180

@@ -207,6 +265,64 @@ def __init__(
207265
json_schema_extra: Union[Dict[str, Any], None] = None,
208266
**extra: Any,
209267
):
268+
"""
269+
Constructs a new Path param.
270+
271+
Parameters
272+
----------
273+
default: Any
274+
The default value of the parameter
275+
default_factory: Callable[[], Any], optional
276+
Callable that will be called when a default value is needed for this field
277+
annotation: Any, optional
278+
The type annotation of the parameter
279+
alias: str, optional
280+
The public name of the field
281+
alias_priority: int, optional
282+
Priority of the alias. This affects whether an alias generator is used
283+
validation_alias: str | AliasPath | AliasChoices | None, optional
284+
Alias to be used for validation only
285+
serialization_alias: str | AliasPath | AliasChoices | None, optional
286+
Alias to be used for serialization only
287+
title: str, optional
288+
The title of the parameter
289+
description: str, optional
290+
The description of the parameter
291+
gt: float, optional
292+
Only applies to numbers, required the field to be "greater than"
293+
ge: float, optional
294+
Only applies to numbers, required the field to be "greater than or equal"
295+
lt: float, optional
296+
Only applies to numbers, required the field to be "less than"
297+
le: float, optional
298+
Only applies to numbers, required the field to be "less than or equal"
299+
min_length: int, optional
300+
Only applies to strings, required the field to have a minimum length
301+
max_length: int, optional
302+
Only applies to strings, required the field to have a maximum length
303+
pattern: str, optional
304+
Only applies to strings, requires the field match against a regular expression pattern string
305+
discriminator: str, optional
306+
Parameter field name for discriminating the type in a tagged union
307+
strict: bool, optional
308+
Enables Pydantic's strict mode for the field
309+
multiple_of: float, optional
310+
Only applies to numbers, requires the field to be a multiple of the given value
311+
allow_inf_nan: bool, optional
312+
Only applies to numbers, requires the field to allow infinity and NaN values
313+
max_digits: int, optional
314+
Only applies to Decimals, requires the field to have a maxmium number of digits within the decimal.
315+
decimal_places: int, optional
316+
Only applies to Decimals, requires the field to have at most a number of decimal places
317+
examples: List[Any], optional
318+
A list of examples for the parameter
319+
deprecated: bool, optional
320+
If `True`, the parameter will be marked as deprecated
321+
include_in_schema: bool, optional
322+
If `False`, the parameter will be excluded from the generated OpenAPI schema
323+
json_schema_extra: Dict[str, Any], optional
324+
Extra values to include in the generated OpenAPI schema
325+
"""
210326
if default is not ...:
211327
raise AssertionError("Path parameters cannot have a default value")
212328

@@ -279,6 +395,64 @@ def __init__(
279395
json_schema_extra: Union[Dict[str, Any], None] = None,
280396
**extra: Any,
281397
):
398+
"""
399+
Constructs a new Query param.
400+
401+
Parameters
402+
----------
403+
default: Any
404+
The default value of the parameter
405+
default_factory: Callable[[], Any], optional
406+
Callable that will be called when a default value is needed for this field
407+
annotation: Any, optional
408+
The type annotation of the parameter
409+
alias: str, optional
410+
The public name of the field
411+
alias_priority: int, optional
412+
Priority of the alias. This affects whether an alias generator is used
413+
validation_alias: str | AliasPath | AliasChoices | None, optional
414+
Alias to be used for validation only
415+
serialization_alias: str | AliasPath | AliasChoices | None, optional
416+
Alias to be used for serialization only
417+
title: str, optional
418+
The title of the parameter
419+
description: str, optional
420+
The description of the parameter
421+
gt: float, optional
422+
Only applies to numbers, required the field to be "greater than"
423+
ge: float, optional
424+
Only applies to numbers, required the field to be "greater than or equal"
425+
lt: float, optional
426+
Only applies to numbers, required the field to be "less than"
427+
le: float, optional
428+
Only applies to numbers, required the field to be "less than or equal"
429+
min_length: int, optional
430+
Only applies to strings, required the field to have a minimum length
431+
max_length: int, optional
432+
Only applies to strings, required the field to have a maximum length
433+
pattern: str, optional
434+
Only applies to strings, requires the field match against a regular expression pattern string
435+
discriminator: str, optional
436+
Parameter field name for discriminating the type in a tagged union
437+
strict: bool, optional
438+
Enables Pydantic's strict mode for the field
439+
multiple_of: float, optional
440+
Only applies to numbers, requires the field to be a multiple of the given value
441+
allow_inf_nan: bool, optional
442+
Only applies to numbers, requires the field to allow infinity and NaN values
443+
max_digits: int, optional
444+
Only applies to Decimals, requires the field to have a maxmium number of digits within the decimal.
445+
decimal_places: int, optional
446+
Only applies to Decimals, requires the field to have at most a number of decimal places
447+
examples: List[Any], optional
448+
A list of examples for the parameter
449+
deprecated: bool, optional
450+
If `True`, the parameter will be marked as deprecated
451+
include_in_schema: bool, optional
452+
If `False`, the parameter will be excluded from the generated OpenAPI schema
453+
json_schema_extra: Dict[str, Any], optional
454+
Extra values to include in the generated OpenAPI schema
455+
"""
282456
super().__init__(
283457
default=default,
284458
default_factory=default_factory,

0 commit comments

Comments
 (0)