-
Notifications
You must be signed in to change notification settings - Fork 2.4k
feat: Add ValidateBody/ValidateParameters attribute to setup API model validators #2026
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
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
1baaba6
Added validators to the swagger definitions when a model is required
56330e2
Remove approach of trying an extra field for validators
218833b
WIP - tests deps not working
af4b806
Finished and fixed all tests to make pr command was complaining. Fixe…
4f85273
py2.7 complaint
1c6afda
Fix py2.7 order of validators on output folder
561a9ee
WIP - adding validator fields
909c252
Set another strategy to set the validators without affect existent cl…
5322874
Set another strategy to set the validators without affect existent cl…
aae5717
Remove mistaken file pushed
fc23711
Remove mistaken file pushed
8f71bcb
Partial coments fixes
37ff9d4
Implemented case where we can set a only limited combinations on the …
bc3dd9e
Fix case test when multiple path are using same validator
91886ff
Added openapi3 specific tests
e50aa42
Added openapi3 specific tests
b3ce527
Fix requested changes from review: Renamed from ValidateRequest -> Va…
be312b9
new approach to not cause KeyErrors
c00c7bf
Setting validator to the only given method not all methods on the path
2ef0d41
removed extra space on comment - lint
895fcd5
Normalized method name path that comes from the template
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
157 changes: 157 additions & 0 deletions
157
tests/translator/input/api_request_model_with_validator.yaml
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,157 @@ | ||
Resources: | ||
HtmlFunction: | ||
Type: AWS::Serverless::Function | ||
Properties: | ||
CodeUri: s3://sam-demo-bucket/member_portal.zip | ||
Handler: index.gethtml | ||
Runtime: nodejs12.x | ||
Events: | ||
GetHtml: | ||
Type: Api | ||
Properties: | ||
RestApiId: HtmlApi | ||
Path: / | ||
Method: get | ||
RequestModel: | ||
Model: User | ||
Required: true | ||
ValidateBody: true | ||
ValidateParameters: true | ||
|
||
HtmlFunctionNoValidation: | ||
Type: AWS::Serverless::Function | ||
Properties: | ||
CodeUri: s3://sam-demo-bucket/member_portal.zip | ||
Handler: index.gethtml | ||
Runtime: nodejs12.x | ||
Events: | ||
GetHtml: | ||
Type: Api | ||
Properties: | ||
RestApiId: HtmlApi | ||
Path: /no-validation | ||
Method: get | ||
RequestModel: | ||
Model: User | ||
Required: true | ||
ValidateBody: false | ||
ValidateParameters: false | ||
|
||
HtmlFunctionMixinValidation: | ||
Type: AWS::Serverless::Function | ||
Properties: | ||
CodeUri: s3://sam-demo-bucket/member_portal.zip | ||
Handler: index.gethtml | ||
Runtime: nodejs12.x | ||
Events: | ||
GetHtml: | ||
Type: Api | ||
Properties: | ||
RestApiId: HtmlApi | ||
Path: /mixin | ||
Method: get | ||
RequestModel: | ||
Model: User | ||
Required: true | ||
ValidateBody: true | ||
ValidateParameters: false | ||
|
||
HtmlFunctionOnlyBodyDefinition: | ||
Type: AWS::Serverless::Function | ||
Properties: | ||
CodeUri: s3://sam-demo-bucket/member_portal.zip | ||
Handler: index.gethtml | ||
Runtime: nodejs12.x | ||
Events: | ||
GetHtml: | ||
Type: Api | ||
Properties: | ||
RestApiId: HtmlApi | ||
Path: /only-body-true | ||
Method: get | ||
RequestModel: | ||
Model: User | ||
Required: true | ||
ValidateBody: true | ||
|
||
HtmlFunctionOnlyRequestDefinition: | ||
Type: AWS::Serverless::Function | ||
Properties: | ||
CodeUri: s3://sam-demo-bucket/member_portal.zip | ||
Handler: index.gethtml | ||
Runtime: nodejs12.x | ||
Events: | ||
GetHtml: | ||
Type: Api | ||
Properties: | ||
RestApiId: HtmlApi | ||
Path: /only-request-true | ||
Method: get | ||
RequestModel: | ||
Model: User | ||
Required: true | ||
ValidateParameters: true | ||
|
||
HtmlFunctionOnlyRequestDefinitionFalse: | ||
Type: AWS::Serverless::Function | ||
Properties: | ||
CodeUri: s3://sam-demo-bucket/member_portal.zip | ||
Handler: index.gethtml | ||
Runtime: nodejs12.x | ||
Events: | ||
GetHtml: | ||
Type: Api | ||
Properties: | ||
RestApiId: HtmlApi | ||
Path: /only-request-false | ||
Method: get | ||
RequestModel: | ||
Model: User | ||
Required: true | ||
ValidateParameters: false | ||
|
||
HtmlFunctionOnlyBodyDefinitionFalse: | ||
Type: AWS::Serverless::Function | ||
Properties: | ||
CodeUri: s3://sam-demo-bucket/member_portal.zip | ||
Handler: index.gethtml | ||
Runtime: nodejs12.x | ||
Events: | ||
GetHtml: | ||
Type: Api | ||
Properties: | ||
RestApiId: HtmlApi | ||
Path: /only-body-false | ||
Method: get | ||
RequestModel: | ||
Model: User | ||
Required: true | ||
ValidateBody: false | ||
|
||
HtmlFunctionNotDefinedValidation: | ||
Rondineli marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Type: AWS::Serverless::Function | ||
Properties: | ||
CodeUri: s3://sam-demo-bucket/member_portal.zip | ||
Handler: index.gethtml | ||
Runtime: nodejs12.x | ||
Events: | ||
GetHtml: | ||
Type: Api | ||
Properties: | ||
RestApiId: HtmlApi | ||
Path: /not-defined | ||
Method: get | ||
RequestModel: | ||
Model: User | ||
Required: true | ||
|
||
HtmlApi: | ||
Type: AWS::Serverless::Api | ||
Properties: | ||
StageName: Prod | ||
Models: | ||
User: | ||
type: object | ||
properties: | ||
username: | ||
type: string |
Oops, something went wrong.
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.