Skip to content

Releases: greeeg/openapi-kit

v0.8.0

09 May 06:32
59c09ba

Choose a tag to compare

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

06 May 06:31
1e8c97c

Choose a tag to compare

This release contains dependency updates & support for react-query skip tokens.

v0.6.1

01 Apr 16:51
a86d4ef

Choose a tag to compare

This release contains bug fixes for multipart/form-data API client methods.

v0.6.0

30 Mar 10:54
349a0f2

Choose a tag to compare

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: binary

Features

  • Support multipart/form-data in generated API clients & react-query mutations

v0.5.1

16 Jan 12:45
v0.5.1
7520e41

Choose a tag to compare

This release contains updated dependencies & documentation.

v0.5.0

13 Jan 20:59
v0.5.0
dd68173

Choose a tag to compare

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

v0.4.1

01 Jan 14:32
v0.4.1
6f40993

Choose a tag to compare

Bug fixes

  • Fix API client functions & react-query hooks generation for OpenAPI operations without path params, query params or request body

v0.4.0

01 Jan 13:39
v0.4.0
dd4152c

Choose a tag to compare

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, --mockData or --reactQuery CLI flags to choose what needs to be generated
  • Use onError event handler on generated API clients to catch API request errors (eg. authorization issues which require a reload)

v0.3.0

26 Dec 17:01
v0.3.0
eff8ee4

Choose a tag to compare

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 outputFilePath instead of outputPath

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-query hooks when schemas contain something else than application/json

v0.2.0

24 Dec 09:42
v0.2.0
fc1974f

Choose a tag to compare

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-query query & mutation hooks for OpenAPI operations