v0.5.0
This release brings error handling improvements in generated API clients. Indeed, errors that could have been thrown while making HTTP requests are now catch & properly returned. A new HTTPRequestError has been introduced so that all errors (network-related or not) can be treated in a similar fashion.
const apiClient = getAPIClient({
baseUrl: 'https://petstore.swagger.io/v2',
headers: {
Accept: 'application/json',
},
onError: (error: unknown) => {
if (error instanceof HTTPRequestError && error.statusCode === 401) {
// Do something
}
},
})
const response = await apiClient.showPetById({
pathParams: {
petId: 1,
},
})Features
- Improved error handling in generated API clients
Breaking changes
onErrorevent handler now accepts a singleerror: unknownargument
Bug fixes
- Fix generated code formatting for API clients &
react-queryhooks