Skip to content

Generating types and SDKs

For the types to be generated, you need to have the OpenAPI schema available. Which means your API needs to be running without errors.

You can generate the types by running the following command (at root level):

Terminal window
pnpm generate

This will generate the types in the packages/openapi-generator/client folder. Those types are automatically imported by the frontend apps.

To use the generated API client in a frontend app:

import { client } from '@boilerstone/openapi-generator'
client.setConfig({
baseURL: 'http://localhost:3000',
// other options...
})
// Usage example
import { postControllerCreatePost } from '@boilerstone/openapi-generator'
const posts = await postControllerCreatePost()
  • Don’t forget to commit your generated types to the repository, as they will be used for production builds.
  • If your type do not refresh, check out for API errors in your console. If the API is not running, the types generation can’t be done.