Closed miguelrk closed 1 year ago
For reference, adding dataValidator.addSchema(<service>Schema)
right after declaring <service>Schema
gets it working. For example:
// user.schema.ts
const userSchema = Type.Object({
// ...
}, { $id: 'User', additionalProperties: false }
)
dataValidator.addSchema(userSchema) // ADD THIS LINE HERE
// message.schema.ts
import { userSchema } from "../users/user.schema"
const messageSchema = Type.Object({
userId: Type.String(),
user: Type.Ref(userSchema)
}, { $id: 'Message', additionalProperties: false }
)
TLDR: CLI should be udpated to register main schemas using
dataValidator.addSchema(<service>Schema)
to be able to useType.Ref(<service>Schema)
Relevant thread
Steps to reproduce
I'm getting the same Error
MissingRefError: can't resolve reference User from id Message
when using user: Type.Ref(userSchema) for the following:Expected behavior
Main schemas (and all others: data, patch and query) should be registered using ajv's
addSchema()
Actual behavior
I have tried the following for user instead of Type.Ref(userSchema) to no success:
System configuration