This is a utility library meant to be used with RTK Query that will generate a typed API client from an OpenAPI schema.
-
Local Schema File Support: Direct processing of local schema files via
schemaFile
-
Remote Schema Download: Download remote schemas to local files via
remoteFile
andschemaFile
- Type Generation: Generates TypeScript types from OpenAPI schemas
- RTK Query Integration: Seamless integration with RTK Query
-
schemaFile
: The local OpenAPI schema file path (required) -
remoteFile
: (Optional) Remote schema URL to download toschemaFile
path -
outputFile
: The output file path for generated code -
apiFile
: The base API file path
// For remote schemas with download
{
schemaFile: './schemas/api-schema.json',
remoteFile: 'https://api.example.com/openapi.json',
apiFile: './baseApi',
outputFile: './generated-api.ts'
}
// For local schema files
{
schemaFile: './schemas/api-schema.json',
apiFile: './baseApi',
outputFile: './generated-api.ts'
}
View the RTK Query Code Generation docs
yarn build && npx acrool-rtk-query-codegen-openapi ./rtk-query-codegen.config.ts
yarn build && npx acrool-rtk-query-codegen-openapi ./rtk-query-codegen-slice.config.ts