resolvers
resolvers copied to clipboard
perf(ajv): reuse compiled schema
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.