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
Above will throw TS error like this: Type 'Document<unknown, any, ObjectData> & ObjectData & Required<{ _id: string; }>' is missing the following properties from type '{ [x: string]: unknown; error?: string | undefined; statusCode: number; message: string; }': statusCode, message
It seems to be correctly parsed by schema-to-ts, but the fastify wouldn't allow it by throwing this error: "Failed building the serialization schema for POST: /xxx, due to error response schemas should be nested under a valid status code, e.g { 2xx: { type: \"object\" } }"
Prerequisites
Fastify version
^4.9.2
Plugin version
^2.1.1
Node.js version
18
Operating system
Windows
Operating system version (i.e. 20.04, 11.3, 10)
10
Description
It doesn't convert to the intended typing when comes to defining multiple response code in the schema like this:
Above will throw TS error like this:
Type 'Document<unknown, any, ObjectData> & ObjectData & Required<{ _id: string; }>' is missing the following properties from type '{ [x: string]: unknown; error?: string | undefined; statusCode: number; message: string; }': statusCode, message
When using 'oneOf' in the response like this:
It seems to be correctly parsed by schema-to-ts, but the fastify wouldn't allow it by throwing this error:
"Failed building the serialization schema for POST: /xxx, due to error response schemas should be nested under a valid status code, e.g { 2xx: { type: \"object\" } }"
Steps to Reproduce
Expected Behavior
I don't know how to sort this out. Maybe treat
response
types differently by usingoneOf
logic?The text was updated successfully, but these errors were encountered: