mnahkies / openapi-code-generator

A code generation tool for openapi 3 / 3.1 specifications written in typescript, primarily aimed at generating typescript clients and server stubs. Other target languages may be added in future.
https://openapi-code-generator.nahkies.co.nz/
MIT License
17 stars 2 forks source link

feat: use pre-compiled ajv validators at runtime #141

Closed mnahkies closed 5 months ago

mnahkies commented 5 months ago

this builds on the speed up from memorizing the validator in https://github.com/mnahkies/openapi-code-generator/pull/140, further improving the speed of the zod spec file from ~1s -> ~200ms (a lot better than the original ~6s!) (though note, it's a bit of a wash for time in CI given it re-compiles there)

there's no longer any need to memorize the validator, since the require cache effectively does this for us now.

the compiled validation function is pretty large, but committing it will keep me honest and prove reproducibility thanks to the CI check for uncommitted changes after running the build / tests.