resolvers icon indicating copy to clipboard operation
resolvers copied to clipboard

perf(ajv): reuse compiled schema

Open matthiasschwarz opened this issue 1 year ago • 0 comments

Moved initialization of Ajv, ajvErrors and the creation of the adjusted schema outside of the Resolver to allow the instance of Ajv to reuse the compiled schema on multiple invocations of the Resolver. Also adjusted the example usage in the README to show that the ajvResolver should only be called once for the schema.

This aligns with the recommended approach of compiling a schema only once as described in the docs under Managing schemas.

Overall this should also significantly reduce the memory footprint since the instance of Ajv and the modified schema is reused.

matthiasschwarz avatar Sep 09 '24 19:09 matthiasschwarz