@@ -19,42 +19,43 @@ def parser(
1919 schema : BaseModel ,
2020 envelope : Optional [BaseEnvelope ] = None ,
2121) -> Any :
22+ # noinspection SpellCheckingInspection,SpellCheckingInspection
2223 """Decorator to conduct advanced parsing & validation for lambda handlers events
2324
24- As Lambda follows (event, context) signature we can remove some of the boilerplate
25- and also capture any exception any Lambda function throws as metadata.
26- event will be the parsed and passed as a BaseModel pydantic class of the input type "schema"
27- to the lambda handler.
28- event will be extracted from the envelope in case envelope is not None.
29- In case envelope is None, the complete event is parsed to match the schema parameter BaseModel definition.
30- In case envelope is not None, first the event is parsed as the envelope's schema definition, and the user
31- message is extracted and parsed again as the schema parameter's definition.
25+ As Lambda follows (event, context) signature we can remove some of the boilerplate
26+ and also capture any exception any Lambda function throws as metadata.
27+ event will be the parsed and passed as a BaseModel pydantic class of the input type "schema"
28+ to the lambda handler.
29+ event will be extracted from the envelope in case envelope is not None.
30+ In case envelope is None, the complete event is parsed to match the schema parameter BaseModel definition.
31+ In case envelope is not None, first the event is parsed as the envelope's schema definition, and the user
32+ message is extracted and parsed again as the schema parameter's definition.
3233
33- Example
34- -------
35- **Lambda function using validation decorator**
34+ Example
35+ -------
36+ **Lambda function using validation decorator**
3637
37- @parser(schema=MyBusiness, envelope=envelopes.EVENTBRIDGE)
38- def handler(event: MyBusiness , context: LambdaContext):
39- ...
38+ @parser(schema=MyBusiness, envelope=envelopes.EVENTBRIDGE)
39+ def handler(event: MyBusiness , context: LambdaContext):
40+ ...
4041
41- Parameters
42- ----------
43- handler: input for lambda_handler_decorator, wraps the handler lambda
44- event: AWS event dictionary
45- context: AWS lambda context
46- schema: pydantic BaseModel class. This is the user data schema that will replace the event.
47- event parameter will be parsed and a new schema object will be created from it.
48- envelope: what envelope to extract the schema from, can be any AWS service that is currently
49- supported in the envelopes module. Can be None.
42+ Parameters
43+ ----------
44+ handler: input for lambda_handler_decorator, wraps the handler lambda
45+ event: AWS event dictionary
46+ context: AWS lambda context
47+ schema: pydantic BaseModel class. This is the user data schema that will replace the event.
48+ event parameter will be parsed and a new schema object will be created from it.
49+ envelope: what envelope to extract the schema from, can be any AWS service that is currently
50+ supported in the envelopes module. Can be None.
5051
51- Raises
52- ------
53- SchemaValidationError
54- When input event doesn't conform with schema provided
55- InvalidSchemaTypeError
56- When schema given does not implement BaseModel
57- """
52+ Raises
53+ ------
54+ SchemaValidationError
55+ When input event doesn't conform with schema provided
56+ InvalidSchemaTypeError
57+ When schema given does not implement BaseModel
58+ """
5859 if envelope is None :
5960 try :
6061 logger .debug ("Parsing and validating event schema; no envelope used" )
0 commit comments