|
Hello everybody, Is there some way to extend the errors with "| unknown" for these cases? What are my options? |
Replies: 1 comment
|
I think the cleanest solution is to model this in the OpenAPI responses if you can. Orval's React Query + axios error type is derived from the non-2xx responses in the spec. In the current code path, the generated query error type becomes So for an expected-but-not-operation-specific failure shape, add a shared responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/MySuccess'
default:
description: Unexpected error
content:
application/json:
schema:
$ref: '#/components/schemas/ApiError'That makes the generated If the upstream spec is not under your control, the practical alternatives are:
I don't think there is a built-in option whose only job is to append |
I think the cleanest solution is to model this in the OpenAPI responses if you can.
Orval's React Query + axios error type is derived from the non-2xx responses in the spec. In the current code path, the generated query error type becomes
AxiosError<...>where...is the deduped union of documented error responses. If there are no documented error responses, it falls back tounknown.So for an expected-but-not-operation-specific failure shape, add a shared
defaultresponse, or explicit500/5XXresponses, for example: