@acrool/rtk-query-codegen-openapi
TypeScript icon, indicating that this package has built-in type declarations

0.0.9 • Public • Published

Code Generator

Discord server

Introduction

This is a utility library meant to be used with RTK Query that will generate a typed API client from an OpenAPI schema.

Features

  • Local Schema File Support: Direct processing of local schema files via schemaFile
  • Remote Schema Download: Download remote schemas to local files via remoteFile and schemaFile
  • Type Generation: Generates TypeScript types from OpenAPI schemas
  • RTK Query Integration: Seamless integration with RTK Query

Configuration Options

  • schemaFile: The local OpenAPI schema file path (required)
  • remoteFile: (Optional) Remote schema URL to download to schemaFile path
  • outputFile: The output file path for generated code
  • apiFile: The base API file path

Example Configuration

// 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'
}

Documentation

View the RTK Query Code Generation docs

Test

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

Readme

Keywords

none

Package Sidebar

Install

npm i @acrool/rtk-query-codegen-openapi

Weekly Downloads

8

Version

0.0.9

License

MIT

Unpacked Size

373 kB

Total Files

27

Last publish

Collaborators

  • imagine10255