Skip to content

v0.5.0

Choose a tag to compare

@greeeg greeeg released this 13 Jan 20:59
· 35 commits to master since this release
v0.5.0
dd68173

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

  • onError event handler now accepts a single error: unknown argument

Bug fixes

  • Fix generated code formatting for API clients & react-query hooks