Using both Type.Union()
and Type.Ref()
in a schema at the same time,
ERROR: can't resolve reference (...) from id (...)
is thrown at runtime, on request, with no schema error on startup.
Using just one of Type.Union()
or Type.Ref()
without the other in a schema results in no error.
npm install
With any fastify
version from @4.2.0
to @4.9.2
(latest as of now):
- run
npm start
- open http://localhost:3370/documentation
- on
/fails1
operation, clickTry it out
, thenExecute
, which should result in
{
"statusCode": 500,
"error": "Internal Server Error",
"message": "can't resolve reference RefSchema from id FailingSchema1"
}
/works1
and/works2
operations both resolve properly/works1
shows thatType.Union()
does work next to a non-Type.Ref()
property/works2
shows that theType.Ref()
can actually be resolved, even next to some other typebox-provided utility,Type.Array()
in this case
/fails2
is the same as/works2
except it usesType.Union()
insideType.Array()
, causing the same kind of error as in/fails1
Happens from [email protected]
onwards.
Last version before that is 4.1.0
:
- Install that exact version (via
-E
) with
npm install [email protected] -E
- run
npm start
- open http://localhost:3370/documentation
- on
/fails1
operation, clickTry it out
, thenExecute
, and it resolves properly with
{
"id": 1,
"reference": "hi"
}
- as expected
/fails2
resolves properly as well