-
Notifications
You must be signed in to change notification settings - Fork 34
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
[BUG] Cannot Include Json Schema in serverless.yml #87
Comments
Note: Not the same as dherault/serverless-offline#894, as I am expecting serverless to find the schema, and at least use it when deployed. |
I've ran into this, I don't have the code in front of me, but the workaround is to do something like this in your serverless.yml
The syntax might be different, I'd have to look at my config at $WORK, but that's the gist, you need to define the path twice, once for offline and once for APIGW, because of path resolution differrences. You might also need to make sure that the packaging step is including your schema in the generated zip file. |
I decided against this approach as I couldn't get it to work, and we want validation working locally with serverless-offline, so we decided to do request body validation in our lambda functions. Thank you for the pointers though in case anyone else runs across this. Gonna keep this issue open, as it is an issue, just no longer an issue for me as I am not using this functionality. |
Checked my config, this is actually the way to make offline and apigw work simultaneously with a schema in serverless.yml:
using 2 I've actually taken to doing both validations you mention though, doing a basic validation at the APIGW level and then doing more complex schema validations deeper in my code, just before my business logic at the API layer. Partly due to the fact that the implementation of schemas on APIGW leave something to be desired in comparison with e.g. AJV. things like |
can we close this? |
Yeah, I think so. there is a workaround in place and honestly I decided to just use the latest version of AJS within my code so I could handle the response body to send back to the calling client. |
Describe the bug
Serverless fails to add a Json Schema to my Http Post Request due to "File not Found".
Added Json Schema to
serverless.yml
the same way as described here: Serverless Request Schema ValidatorsTo Reproduce
serverless.yml
Expected behavior
I should not have a warning about the schema not being found, and it should be used to validate my request
Screenshots
Serverless yml file
Cmd Output
Schema File Location:
![image](https://user-images.githubusercontent.com/84519320/124978246-866ee080-dfff-11eb-9355-27d31290c632.png)
Check which provider is affected:
[x] AWS
[ ] Azure
[ ] Google Cloud Platform
Check which framework is affected:
[ ] Angular
[ ] Nodejs
[x] Serverless
[ ] Lambda
[ ] Infrastructure as a code
Additional context
serverless.yml
and updating file path) (Does not work)"resolveJsonModule": true
totsconfig.json
(Helps with import/require within ts, didn't help with this issue)dist
folder (Did not work)The text was updated successfully, but these errors were encountered: