cdimascio / express-openapi-validator

🦋 Auto-validates api requests, responses, and securities using ExpressJS and an OpenAPI 3.x specification
MIT License
920 stars 211 forks source link

Use Precompiled Validator? #910

Open krcourville opened 8 months ago

krcourville commented 8 months ago

Is your feature request related to a problem? Please describe. I have been testing this middleware via AWS Lambda. And it provides much better validation responses than AWS API Gateway, which is great. What is less great is that it adds a couple of seconds to lambda cold start times.

Describe the solution you'd like My understanding is that AJV supports pre-compiled validators. Would it shave off start-up time if a precompiled AJV validator could be passed into configuration? Precompilation should also mean that the AJV modules can be excluded from the deployed JS bundle, further reducing cold start times.

Describe alternatives you've considered I have yet to find a better implementation of OpenAPI data validation that supports recent features of the OAS.

Possibly, given some direction, I'd be willing to create a branch off this repo and experiment and contribute back via PR if the experiment works.