-
Notifications
You must be signed in to change notification settings - Fork 429
feat(validation): support JSON Schema referencing in validation utils #4508
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
sthulb
merged 13 commits into
aws-powertools:develop
from
danieljnchen:feat/validation-json-schema-refs
Jun 19, 2024
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
d4270f1
feat: add support for fastjsonschema's handlers param in validation u…
danieljnchen 8c3a84b
docs: document new handlers param in validation utilities
danieljnchen fd933ea
Merge branch 'aws-powertools:develop' into feat/validation-json-schem…
danieljnchen 650cf9b
Add provider_options validation arg, fix test JSON schema
danieljnchen e17370e
Update provider_options default arg value
danieljnchen 9e481eb
Remove unused import
danieljnchen 4e41ebf
Merge branch 'develop' into feat/validation-json-schema-refs
danieljnchen 5f3de5c
Lint files
danieljnchen d760ca6
Small changes + example refactor
leandrodamascena 868e94a
Small changes + example refactor
leandrodamascena 189714e
Addressing Heitor's feedback
leandrodamascena caa806e
Merge branch 'develop' into feat/validation-json-schema-refs
leandrodamascena 2191346
Addressing Heitor's feedback
leandrodamascena File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from custom_handlers_schema import CHILD_SCHEMA, PARENT_SCHEMA | ||
|
||
from aws_lambda_powertools.utilities.typing import LambdaContext | ||
from aws_lambda_powertools.utilities.validation import validator | ||
|
||
|
||
# Function to return the child schema | ||
def get_child_schema(uri: str): | ||
return CHILD_SCHEMA | ||
|
||
|
||
@validator(inbound_schema=PARENT_SCHEMA, inbound_handlers={"https": get_child_schema}) | ||
def lambda_handler(event, context: LambdaContext) -> dict: | ||
return event |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"ParentSchema": | ||
{ | ||
"project": "powertools" | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
PARENT_SCHEMA = { | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"$id": "https://example.com/schemas/parent.json", | ||
"type": "object", | ||
"properties": { | ||
"ParentSchema": { | ||
"$ref": "https://SCHEMA", | ||
}, | ||
}, | ||
} | ||
|
||
CHILD_SCHEMA = { | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"$id": "https://example.com/schemas/child.json", | ||
"type": "object", | ||
"properties": { | ||
"project": { | ||
"type": "string", | ||
}, | ||
}, | ||
"required": ["project"], | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.