@codestacks/ng-query-codegen-openapi
v0.0.30
Published
<p align="center"> <img src="https://raw.githubusercontent.com/rtk-incubator/rtk-query/main/logo.png" width="400" /> </p> <h2 align="center"> Code Generator </h2>
Readme
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
remoteFileandschemaFile - 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 toschemaFilepathoutputFile: The output file path for generated codeapiFile: 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 codestacks-ng-query-codegen-openapi ./rtk-query-codegen.config.ts
yarn build && npx codestacks-ng-query-codegen-openapi ./rtk-query-codegen-slice.config.ts
rm -rf test_output3/* && node lib/bin/cli.mjs rtk-query-codegen-slice.config.tsnew
yarn cli ./rtk-query-codegen-slice.config.tsStep
- [endpoint-generator] EndpointGenerator.generateEndpoints....
- [endpoint-generator] EndpointGenerator.generateForGroup....... 2.1. [generate-new] generateApi........
- [endpoint-generator] EndpointGenerator.generateForGroup....... 2.1. [generate-new] generateApi........
