From ba6e2bd3ffa3317d50576974e9019aed0ad30f5f Mon Sep 17 00:00:00 2001 From: hitchhiker Date: Thu, 17 Apr 2025 15:45:20 +0200 Subject: [PATCH] Add api-generator package to README --- README.md | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 1b30494..0f0afcc 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,7 @@ This monorepo contains common TypeScript packages used across Generation One pro g1-ts-common-packages/ ├── packages/ # All packages are stored here │ ├── sse-client/ # Server-Sent Events client package +│ ├── api-generator/ # OpenAPI TypeScript client generator │ └── [future-packages]/ # Additional packages will be added here ├── scripts/ # Utility scripts for the repository ├── docs/ # Documentation @@ -24,9 +25,18 @@ A custom Server-Sent Events (SSE) client that supports headers and bypasses cert - Handles reconnection with exponential backoff - Works in both browser and Node.js environments - Provides connection management utilities - [View SSE Client Documentation](packages/sse-client/README.md) +### API Generator (`@g1/api-generator`) + +A command-line tool for generating TypeScript API clients from OpenAPI schemas. + +- 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 +[View API Generator Documentation](packages/api-generator/README.md) + ## Getting Started ### Prerequisites @@ -89,6 +99,8 @@ pnpm add /path/to/g1-sse-client-0.2.0.tgz ### Example Usage +#### SSE Client + ```typescript import { SSEClient } from '@g1/sse-client'; @@ -111,6 +123,27 @@ client.on('message', (event) => { client.close(); ``` +#### API Generator + +```bash +# Generate API client from OpenAPI schema +g1-api-generator https://api.example.com/openapi.json ./src/api +``` + +```typescript +// Use the generated API client +import { ApiClient } from './src/api'; + +const api = new ApiClient({ + BASE: 'https://api.example.com', + TOKEN: 'your-token' +}); + +// Call API methods +const users = await api.users.getUsers(); +console.log(users); +``` + ## Development ### Adding a New Package