@g1/api-generator (0.2.1)
Published 2025-04-17 16:02:51 +02:00 by semaphore
Installation
@g1:registry=
npm install @g1/api-generator@0.2.1
"@g1/api-generator": "0.2.1"
About this package
G1 API Generator
A command-line tool for generating TypeScript API clients from OpenAPI schemas.
Features
- Downloads OpenAPI schema from a specified URL
- Generates TypeScript interfaces and API client code
- Post-processes generated code to fix common issues
- Supports HTTPS with option to skip TLS verification
- Detects and warns about duplicate DTOs in the schema
Installation
# Install from G1 package registry
npm install @g1/api-generator --save-dev
# Or with pnpm
pnpm add @g1/api-generator -D
Usage
Command Line
# Basic usage
g1-api-generator https://your-api-server/openapi/schema.json ./src/lib/api
# Skip TLS verification (useful for local development with self-signed certificates)
g1-api-generator https://localhost:7205/openapi/schema.json ./src/lib/api --skip-tls-verify
In package.json scripts
{
"scripts": {
"api:generate": "g1-api-generator https://localhost:7205/openapi/schema.json src/lib/api"
}
}
Programmatic Usage
import { generateApiClient } from '@g1/api-generator';
async function generateApi() {
await generateApiClient({
schemaUrl: 'https://your-api-server/openapi/schema.json',
outputDir: './src/lib/api',
skipTlsVerify: true, // Optional, default: false
runPostProcessing: true // Optional, default: true
});
}
generateApi().catch(console.error);
Generated Code Structure
The generated code is organized as follows:
models/
- TypeScript interfaces for API modelsservices/
- API client services for making requestscore/
- Core functionality for the API clientopen-api.json
- The downloaded and processed OpenAPI schema
Post-Processing
The tool automatically applies the following post-processing to the generated code:
- Removes import statements for
void
type - Replaces usages of
void
as a type withany
- Detects and replaces self-referencing DTOs with
any
- Adds auto-generated comments to files
License
UNLICENSED - Private package for Generation One use only.
Dependencies
Dependencies
ID | Version |
---|---|
axios | ^1.8.4 |
openapi-typescript-codegen | ^0.29.0 |
Development Dependencies
ID | Version |
---|---|
@types/node | ^20 |
typescript | ^5 |
Keywords
openapi
api
generator
typescript
Details
2025-04-17 16:02:51 +02:00
Assets (1)
Versions (2)
View all
npm
84
Generation One
UNLICENSED
latest
3.7 KiB
api-generator-0.2.1.tgz
3.7 KiB