You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[@feathersjs/schema] Feathers schema associations using $ref may not be working #2675
When using $ref associations with @feathersjs/schema and compiling the app locally, it fails and gives an error about the association.
The error:
Error: can't resolve reference AlbumResult from id ArtistResult
at Object.code (/app/node_modules/ajv/lib/vocabularies/core/ref.ts:19:39)
at keywordCode (/app/node_modules/ajv/lib/compile/validate/index.ts:523:9)
at /app/node_modules/ajv/lib/compile/validate/index.ts:228:21
at CodeGen.code (/app/node_modules/ajv/lib/compile/codegen/index.ts:525:33)
at CodeGen.block (/app/node_modules/ajv/lib/compile/codegen/index.ts:680:20)
at schemaKeywords (/app/node_modules/ajv/lib/compile/validate/index.ts:228:9)
at typeAndKeywords (/app/node_modules/ajv/lib/compile/validate/index.ts:161:3)
at subSchemaObjCode (/app/node_modules/ajv/lib/compile/validate/index.ts:147:3)
at subschemaCode (/app/node_modules/ajv/lib/compile/validate/index.ts:124:7)
at KeywordCxt.subschema (/app/node_modules/ajv/lib/compile/validate/index.ts:491:5)
Here is a gist of my app's schema and hooks code, which is currently reproducing the error.
System configuration
Running Feathers in docker
Module versions (especially the part that's not working):
I may be in a unique position since I am running Feathers v4 for all but the@feathersjs/schema package, which is v5
changed the title [-]Feathers schema associations using $ref may not be working[/-][+][@feathersjs/schema] Feathers schema associations using $ref may not be working[/+]on Jun 30, 2022
This has been addressed now in #2772 with making the schema wrapper optional and using FromSchema or TypeBox directly which both do support references. With plain JSON schema this would look like this:
Is there a more complete example for this solution? I'm having trouble understanding how you go from this example to actually using getValidator and getDataValidator and their respective hooks.
Activity
ejmudrak commentedon Jun 21, 2022
My temporary workaround is importing the referenced schema directly like so:
[-]Feathers schema associations using $ref may not be working[/-][+][@feathersjs/schema] Feathers schema associations using $ref may not be working[/+]AshotN commentedon Sep 29, 2022
Were you able to resolve this issue? I am running into something similar and I'm unsure if it's user error.
daffl commentedon Oct 5, 2022
This has been addressed now in #2772 with making the schema wrapper optional and using
FromSchemaor TypeBox directly which both do support references. With plain JSON schema this would look like this:RickEyre commentedon Nov 1, 2023
Is there a more complete example for this solution? I'm having trouble understanding how you go from this example to actually using
getValidatorandgetDataValidatorand their respective hooks.opatajoshua commentedon Feb 20, 2024
Error is thrown by
getValidatoraddSchemabeforegetValidatoris called