-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
feat - Creating ability to add validators to api gw method without needing a model #2450
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #2450 +/- ##
===========================================
+ Coverage 93.58% 94.51% +0.92%
===========================================
Files 90 97 +7
Lines 6124 7305 +1181
Branches 1260 1524 +264
===========================================
+ Hits 5731 6904 +1173
- Misses 183 193 +10
+ Partials 210 208 -2
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for the PR!
tests/translator/output/error_api_request_model_with_strings_validator.json
Show resolved
Hide resolved
@aahung fixed, thanks for the review!! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm!
# if we have validator configured to a request parameter | ||
# we want to add it to the editor but remove it from original dict before it iterates | ||
# If validators is present or not, this method will handle the check | ||
self._add_validators( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure if this should be the correct behaviour. I found it confusing, if the customer defined set the validation to True
in the RequestModel
but to False
in the RequestValidators
, why should we disable the validations. I think it is not a good customer experience.
Thanks @Rondineli for your contribution. I just have a concern about the customer experience of the new property My understanding of the purpose of this PR is to allow the customers to set validations for a service Path even if there is no model. Let me share my thoughts, and I will also validate it with the team. Is it possible to allow the customer to do that by making the |
@moelasmar thanks for replying. That makes sense and it is a valid concern. My thoughts were get a way of not change the actual behaviour as it can break existent config. Let me know the best way to proceed then I can change my PR to meet the requirements. The idea of changing the model to no be required also sounds confusing as it still having to have a "RequestModel" on the template. We could maybe validate If the template has a model with a validator and if both are present, raise an exception saying that it must have either a validator on its model block to the method or a validator on its request parameters to the method. In any case I would be happy to change the PR to meet the desired behaviour. |
Issue #, if available: #1403 - Feature improvement
Description of changes: Add ability to add validators if no Model is present. In some cases, when request Parameters is present but no model we still want to add validators to the path. This PR aim add a second way of add a validator to the swagger specs, even if a model is not defined.
In case both are defined (model and RequestValidators) it will add the unique validator to the path, keeping model and requestParameters as part of the swagger spec definitions.
Description of how you validated changes: Create a path with RequestParameters and add a RequestValidators to it. It will update the validators to the final spec, validating the requests as intended.
Checklist:
make pr
passesExamples?
Please reach out in the comments, if you want to add an example. Examples will be
added to
sam init
through https://github.com/awslabs/aws-sam-cli-app-templates/By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.