Releases: greeeg/openapi-kit
v0.8.0
This release removes support for lazy queries as react-query skipTokens can now be used. It also updates the config object structure to use an onRequest event handler instead of a static object.
import { getAPIClient } from 'generated/apiClient'
// Before
const apiClient = getAPIClient({
baseUrl: 'https://petstore.swagger.io/v2',
headers: {
Authorization: 'Bearer 1234',
},
onError: (error: unknown) => {
if (error instanceof HTTPRequestError && error.statusCode === 401) {
// Do something
}
},
})
// After
const apiClient = getAPIClient({
baseUrl: 'https://petstore.swagger.io/v2',
onRequest: async () => ({
headers: {
Authorization: 'Bearer 1234',
}
}),
onError: (error: unknown) => {
if (error instanceof HTTPRequestError && error.statusCode === 401) {
// Do something
}
},
})v0.7.0
This release contains dependency updates & support for react-query skip tokens.
v0.6.1
v0.6.0
This release adds support for multipart/form-data in OpenAPI requestBody. Generated API clients & react-query mutations accept a FormData object.
paths:
/pictures:
post:
summary: Upload a picture
operationId: uploadPicture
requestBody:
content:
multipart/form-data:
schema:
type: object
properties:
id:
type: string
format: binaryFeatures
- Support
multipart/form-datain generated API clients &react-querymutations
v0.5.1
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
v0.4.1
v0.4.0
This release contains new CLI options to specify what needs to be generated & a new onError event handler for generated API clients.
Features
- Use
--types,--apiClient,--mockDataor--reactQueryCLI flags to choose what needs to be generated - Use
onErrorevent handler on generated API clients to catch API request errors (eg. authorization issues which require a reload)
v0.3.0
This release contains some bug fixes & improvements related to real-life experimentation using Stripe & Twilio OpenAPI specs.
Features
- Faster generation thanks to optional Prettier formatting (defaults to
false)
Breaking changes
- Generation functions use
outputFilePathinstead ofoutputPath
Bug fixes
- Fix a bug related to circular refs when generating mock data
- Fix nullable enums mock data generation
- Fix nullable empty schemas mock data generation
- Fix typed responses in API client &
react-queryhooks when schemas contain something else thanapplication/json
v0.2.0
Features
- Parse OpenAPI 3 & OpenAPI 3.1 YML/JSON documents
- Generate Typescript types for OpenAPI components & paths
- Generate a typed API client with named methods for OpenAPI operations
- Generate mock data for OpenAPI operations
- Generate
react-queryquery & mutation hooks for OpenAPI operations