-
Notifications
You must be signed in to change notification settings - Fork 6
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
How to retrieve models/schemas in Lambda/Javascript? #7
Comments
For the current version of the models plugin and Serverless this approach should work for your special use case although it is not universal as you can define your models as s-models.json or s-models.yaml. In future this could even be part of the plugin itself, so that it could generate a validator function/class or provide a way to retrieve the model definitions at runtime. But as I need to do excessive changes for the upcoming Serverless V1, this will not happen in this version. |
In my case I use only json, so it is quite easy to load the models. In regards providing validate function as part of the plugin. That depends of what scope this plugin will have in future. So far it is isolated for deploying models to API Gateway, which it does greatly. Doing validations as well would extend its current scope. Off topic: when is serverless v1 release planned? |
Exactly. |
New obstacle, Is it possible to retrieve models in other way, within the function handler? |
Currently not. As a hack you might symlink the s-models.json into your function root. |
Could you please be more specific? |
Like this
|
Aah. Thanks. But really an hack, specially when commiting to GIT. |
Yes it is :-) But at least GIT handles symlinks correctly. |
Since API Gateway does not use Models to perform any schema validation of request/response messages (currently at least), Im considering using one of the Javascript JSON-Schema validator implementations for NodeJS to do this myself inside Lambda handler.
In order to do that, validators are requiring schemas and then I need to be able to retrieve the models/schemas from
s-models.json
file. Is it as easy as just usingrequire()
function, or do you suggest another way?The text was updated successfully, but these errors were encountered: