-
Hello. For example, right now the I thought if I use, for example, I would also like to thank the creator for making such a great library with many great features. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Hello @John4266 , Thank you for your feedback and ideas. About the errors and their codes. The z.object({
status: z.literal("error"),
error: z.object({
message: z.string(),
}),
}); The HTTP Error code meanwhile goes to the status code of the response. If you want your negative response to have particular fields only in case of specific errors, you can define the schema with optional fields. Like this: z.object({
status: z.literal("error"),
error: z.object({
code: z.number().optional(),
message: z.string(),
tracing: z.array(z.string()).optional(),
file: z.string().optional(),
line: z.number().optional(),
}),
additionalInformation: z.record(z.string()).optional()
}); Then you can fulfill these optional fields in the implementation of your So, no matter is it P.S. For the OpenAPI you can also supply those optional fields with descriptions, that would clarify in which cases they are present. z.object({
// ...
additionalInformation: z.record(z.string()).optional().description("in case of 503")
}); I hope this would be helpful. Let me know. |
Beta Was this translation helpful? Give feedback.
Hello @John4266 ,
Thank you for your feedback and ideas.
Unfortunately, OpenAPI generator can not figure out anything from the code of the implementation.
Instead it works in the explicit way based on the static declaration of the
Endpoint
's andResultHandler
's schemas.About the errors and their codes.
Regardless the particular HTTP error code you throw inside the
Endpoint
's handler, the case will be handled over to theResultHandler
, the entity responsible for the consistency of responses.In the
ResultHandler
you can define two schemas: for a positive response and for a negative one (in case of an error).That means that in case of any error the actual response must comply the predefin…