ajv icon indicating copy to clipboard operation
ajv copied to clipboard

fix #2427 compileAsync a schema with discriminator and $ref

Open yonran opened this issue 9 months ago • 2 comments

Make the discriminator code generation throw MissingRefError when the $ref does not synchronously resolve so that compileAsync can loadSchema and retry.

What issue does this pull request resolve? #2427

What changes did you make? Make the discriminator code generation throw MissingRefError when the $ref does not synchronously resolve so that compileAsync can loadSchema and retry.

Is there anything that requires more attention while reviewing? The existing tests create separate test Ajv instances by calling withStandalone(getAjvInstances(AjvClass, …)) (https://github.com/ajv-validator/ajv/blob/v8.13.0/spec/discriminator.spec.ts#L22). I could not directly reuse those Ajv instances because I need to add the loadSchema option and I can’t call compileAsync on an Ajv after withStandalone. For now I only called new _Ajv. To what extent should I try creating separate ajv, ajv2019, standalone instances in the test?

yonran avatar May 10 '24 00:05 yonran

I've made some small changes just to get it passing linting and see how the tests run.

jasoniangreen avatar May 11 '24 12:05 jasoniangreen

Not sure why coveralls is erroring. Will try a clean branch and see if I get the same issue.

jasoniangreen avatar May 12 '24 20:05 jasoniangreen

This has been moved to #2433 due to coveralls issues.

jasoniangreen avatar May 16 '24 21:05 jasoniangreen