Comments (6)
Checked my config, this is actually the way to make offline and apigw work simultaneously with a schema in serverless.yml:
events:
- http:
path: my/endpoint
method: post
request:
schema:
application/json: ${
file(src/my-endpoint/post.request.schema.json),
file(apps/my-app/src/my-endpoint/post.request.schema.json)}
using 2 file()
declarations inside the ${}
substitution separated by a comma provides failover should one file fail to be found.
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 oneOf
rules don't work as expected and lots of little gotchas in complex schemas that I don't recall off the top of my head.
from nx-plugins.
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.
from nx-plugins.
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
functions:
location:
handler: src/controllers/location.saveLocation
events:
- http:
path: location
method: post
request:
schemas:
application/json:
- ${file(src/schemas/location.json)}
- ${file(apps/my-app/src/schemas/location.json)}
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.
from nx-plugins.
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.
from nx-plugins.
can we close this?
from nx-plugins.
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.
from nx-plugins.
Related Issues (20)
- [BUG] Cannot create new api HOT 1
- [BUG] Cannot find module '@nrwl/workspace/src/utilities/run-webpack' HOT 1
- [BUG] Schematic "init" cannot resolve the factory. HOT 3
- [BUG] nx-serverless: Property 'port' does not match the schema. '7777' should be a 'number'. HOT 1
- [BUG] When using npm as packager, pacakgelist is not properly computed resulting in "*" for all package versions HOT 2
- [FEAT] Webpack stats.json support HOT 4
- [BUG] NX 13 and Webpack5 Support HOT 10
- Configuration error at 'useDotenv': should be equal to constant HOT 2
- [BUG] After creating monorepo blank workspace not able to create api HOT 3
- [FEAT] Nx-Serverless | option to exclude ALL dependencies from build HOT 1
- Cannot destructure property 'name' of 'node' as it is undefined. - @flowaccount/scully-plugin-angular-delay
- Support newer Serverless framework
- [BUG] Not able to run or build the freshly scaffolded project HOT 3
- [FEAT] Build functions individually HOT 9
- [BUG] Zip file resolution error when deploying a single artifact HOT 18
- Allow for a serverless.ts file HOT 8
- [BUG] External dependencies are unavailable after deploying HOT 5
- [BUG] Runtime.ImportModuleError in every Lambda function after deploying new project HOT 2
- [BUG] Missing compat.ts for sls executor HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nx-plugins.