Add api-generator package to README
This commit is contained in:
parent
40da469730
commit
ba6e2bd3ff
35
README.md
35
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user