@sdk-it/cli 0.12.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,110 @@
1
+ # @sdk-it/cli
2
+
3
+ <p align="center">Command-line interface for SDK-IT that simplifies generating type-safe client SDKs from OpenAPI specifications</p>
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ # Install globally
9
+ npm install -g sdk-it
10
+
11
+ # Or use with npx without installing
12
+ npx sdk-it
13
+ ```
14
+
15
+ ## Usage
16
+
17
+ The CLI provides a simple way to generate SDKs from OpenAPI specifications
18
+
19
+ ### Basic Command Structure
20
+
21
+ ```bash
22
+ npx sdk-it --spec <path-to-spec> --output <output-directory> [options]
23
+ ```
24
+
25
+ ### Options
26
+
27
+ | Option | Alias | Description | Default |
28
+ | ------------- | ----- | -------------------------------------------------------- | ---------- |
29
+ | `--spec` | `-s` | Path to OpenAPI specification file (local or remote URL) | _Required_ |
30
+ | `--output` | `-o` | Output directory for the generated SDK | _Required_ |
31
+ | `--name` | `-n` | Name of the generated client | `Client` |
32
+ | `--mode` | `-m` | Generation mode: `full` or `minimal` | `minimal` |
33
+ | `--formatter` | | Formatter command to run on generated code | |
34
+
35
+ #### Mode Options
36
+
37
+ - `minimal`: Generates only the client SDK files (default)
38
+ - `full`: Generates a complete project including package.json and tsconfig.json (useful for monorepo/workspaces)
39
+
40
+ #### Formatter
41
+
42
+ You can specify a command to format the generated code. The special variable `$SDK_IT_OUTPUT` will be replaced with the output directory path.
43
+
44
+ Examples:
45
+
46
+ - `--formatter "prettier $SDK_IT_OUTPUT --write"`
47
+ - `--formatter "biome check $SDK_IT_OUTPUT --write"`
48
+
49
+ ### Supported Specification Formats
50
+
51
+ - JSON (`.json`)
52
+ - YAML (`.yaml`, `.yml`)
53
+
54
+ ## Examples
55
+
56
+ ### Generate SDK from a Remote OpenAPI Specification
57
+
58
+ ```bash
59
+ npx sdk-it -s https://petstore.swagger.io/v2/swagger.json -o ./client
60
+ ```
61
+
62
+ ### Generate SDK with Custom Client Name
63
+
64
+ ```bash
65
+ npx sdk-it -s ./openapi.json -o ./client -n PetStore
66
+ ```
67
+
68
+ ### Generate Full Project with Formatting
69
+
70
+ ```bash
71
+ npx sdk-it -s ./openapi.yaml -o ./client -m full --formatter "prettier $SDK_IT_OUTPUT --write"
72
+ ```
73
+
74
+ ## Complete Example
75
+
76
+ Let's generate a client SDK for the Hetzner Cloud API with automatic formatting:
77
+
78
+ ```bash
79
+ # Generate SDK from Hetzner Cloud API spec with Prettier formatting
80
+ npx sdk-it -s https://docs.hetzner.cloud/spec.json -o ./client --formatter "prettier $SDK_IT_OUTPUT --write"
81
+ ```
82
+
83
+ After running this command:
84
+
85
+ 1. The OpenAPI specification is downloaded from the Hetzner Cloud documentation
86
+ 2. A type-safe TypeScript SDK is generated in the `./client` directory
87
+ 3. Prettier is run on the generated code to ensure consistent formatting
88
+
89
+ You can then use the generated SDK in your application:
90
+
91
+ ```typescript
92
+ import { Client } from './client';
93
+
94
+ // Create a client instance with your API token
95
+ const client = new Client({
96
+ baseUrl: 'https://api.hetzner.cloud/v1',
97
+ headers: {
98
+ Authorization: 'Bearer your_api_token',
99
+ },
100
+ });
101
+
102
+ // Call API methods with type safety
103
+ const [servers, error] = await client.request('GET /servers', {});
104
+
105
+ if (error) {
106
+ console.error('Error fetching servers:', error);
107
+ } else {
108
+ console.log('Servers:', servers);
109
+ }
110
+ ```
@@ -0,0 +1,2 @@
1
+ export * from './lib/cli.ts';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC"}