@skmtc/core 0.0.829 โ 0.0.831
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 +90 -63
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,89 +1,116 @@
|
|
|
1
|
-
[](https://opensource.org/licenses/Apache-2.0)
|
|
2
|
-
[](https://deno.land/)
|
|
3
|
-
[](https://discord.com/invite/Mg88C8Xu5Y)
|
|
4
|
-
|
|
5
1
|
<p align="center">
|
|
6
|
-
<img src="
|
|
2
|
+
<img src="./skmtc.svg" />
|
|
7
3
|
</p>
|
|
8
4
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
**Stop writing the same code over and over.** Generate TypeScript types, API clients, validation schemas, and more directly from your OpenAPI specifications.
|
|
5
|
+
**Skmtc is a declarative code generation framework**. It lets you generate TypeScript code from OpenAPI schemas using string templates.
|
|
12
6
|
|
|
13
|
-
|
|
14
|
-
**Pain:** Hours spent manually writing TypeScript interfaces from OpenAPI docs, fighting typos and sync issues.
|
|
15
|
-
**Solution:** Generate accurate types with perfect synchronization.
|
|
7
|
+
## โจ Features
|
|
16
8
|
|
|
17
|
-
|
|
18
|
-
**
|
|
19
|
-
**
|
|
9
|
+
- ๐๏ธ **Fast** - Generates 550k+ tokens per second
|
|
10
|
+
- ๐งต **Easy to edit code generators** - Outputs specified using string templates, not ASTs
|
|
11
|
+
- ๐ฅ **Stackable generators** - Compose complex functionality by combining generators
|
|
12
|
+
- ๐๏ธ **Use your own code conventions** - Full control over naming and file structure
|
|
20
13
|
|
|
21
|
-
|
|
22
|
-
**Pain:** No compile-time guarantees that API calls match backend schemas.
|
|
23
|
-
**Solution:** End-to-end type safety from schema through clients to UI components.
|
|
14
|
+
## ๐ Quick Start
|
|
24
15
|
|
|
25
|
-
|
|
16
|
+
```bash
|
|
17
|
+
# Run directly with npx
|
|
18
|
+
npx skmtc
|
|
26
19
|
|
|
27
|
-
|
|
20
|
+
```
|
|
28
21
|
|
|
29
|
-
###
|
|
22
|
+
### Running code generators
|
|
30
23
|
|
|
31
24
|
```bash
|
|
32
|
-
|
|
33
|
-
|
|
25
|
+
npx skmtc generate @skmtc/supabase-backend https://petstore3.swagger.io/api/v3/openapi.json
|
|
26
|
+
# Generated 9 files (507 lines, 3,383 tokens) in 9ms
|
|
27
|
+
|
|
28
|
+
npx skmtc generate @skmtc/supabase-react-client https://raw.githubusercontent.com/cloudflare/api-schemas/refs/heads/main/openapi.json
|
|
29
|
+
# Generated 6,797 files (104,752 lines, 1,635,227 tokens) in 2,969ms
|
|
34
30
|
```
|
|
35
31
|
|
|
36
|
-
###
|
|
32
|
+
### Example generator code
|
|
37
33
|
|
|
38
34
|
```typescript
|
|
39
|
-
import {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
35
|
+
import { ZodInsertable } from '@skmtc/gen-zod'
|
|
36
|
+
|
|
37
|
+
class ZodFetch extends BaseTransformer {
|
|
38
|
+
zodName: string;
|
|
39
|
+
|
|
40
|
+
constructor({context, operation, settings}){
|
|
41
|
+
super({context, operation, settings})
|
|
42
|
+
|
|
43
|
+
// Generate Zod schema for API response and insert it into current file
|
|
44
|
+
const response = operation.toSuccessResponse()?.resolve().toSchema()
|
|
45
|
+
const zodResponse = this.insert(ZodInsertable, response)
|
|
46
|
+
|
|
47
|
+
// Grab Zod schema name to use in output code
|
|
48
|
+
this.zodName = zodResponse.identifier.name
|
|
56
49
|
}
|
|
57
|
-
}
|
|
58
50
|
|
|
59
|
-
//
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
51
|
+
// Define code output
|
|
52
|
+
toString(){
|
|
53
|
+
return `() => {
|
|
54
|
+
const res = await fetch('${this.operation.path}')
|
|
55
|
+
const data = await res.json()
|
|
64
56
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
57
|
+
return ${zodName}.parse(data)
|
|
58
|
+
}`
|
|
59
|
+
}
|
|
68
60
|
}
|
|
69
61
|
```
|
|
70
62
|
|
|
71
|
-
|
|
63
|
+
## ๐ฆ Available Generators
|
|
72
64
|
|
|
73
|
-
|
|
74
|
-
// @/types/user.generated.ts
|
|
75
|
-
export interface User {
|
|
76
|
-
id?: string
|
|
77
|
-
name?: string
|
|
78
|
-
}
|
|
79
|
-
```
|
|
65
|
+
Choose from our growing collection of generators, combone them or create your own:
|
|
80
66
|
|
|
81
|
-
|
|
67
|
+
- **Tanstack Query** - React Query hooks with Zod validation
|
|
68
|
+
- **MSW** - Mock Service Worker handlers from OpenAPI examples
|
|
69
|
+
- **Zod Schemas** - Runtime validation schemas
|
|
70
|
+
- **TypeScript Types** - Pure type definitions
|
|
71
|
+
- **Supabase/Hono Functions** - Edge function handlers
|
|
72
|
+
- See full list at https://github.com/skmtc/skmtc-generators
|
|
82
73
|
|
|
83
|
-
|
|
84
|
-
- **[How-To Guides โ](docs/how-to/)** - Task-oriented tutorials
|
|
85
|
-
- **[API Reference โ](docs/api/)** - Complete technical documentation
|
|
74
|
+
## โ FAQ
|
|
86
75
|
|
|
87
|
-
|
|
76
|
+
### **What OpenAPI versions are supported?**
|
|
77
|
+
Skmtc supports OpenAPI v3.0. Swagger 2.0 and OpenAPI v3.1 are automatically converted to OpenAPI v3.0.
|
|
88
78
|
|
|
89
|
-
|
|
79
|
+
### **Can I customize the generated code?**
|
|
80
|
+
Yes! Each Transformer specifies its output using plain string templates, which means you can
|
|
81
|
+
edit them as would you edit any other code.
|
|
82
|
+
|
|
83
|
+
### **Can I use this with my existing React app?**
|
|
84
|
+
Yes! Skmtc generates standalone code that integrates with any React application. The generated components work with your existing setup.
|
|
85
|
+
|
|
86
|
+
### **How does this compare to OpenAPI Generator?**
|
|
87
|
+
Skmtc is the only code generation framework that provides full control over the generated code. You are not limited by library-specific settings and you do not need to write complex AST code.
|
|
88
|
+
|
|
89
|
+
### **Does it work with Next.js/Remix/Vite?**
|
|
90
|
+
Yes! The generated code is framework-agnostic TypeScript that works with any build tool or library.
|
|
91
|
+
|
|
92
|
+
## ๐ค Contributing
|
|
93
|
+
|
|
94
|
+
We welcome contributions! Check out our [Contributing Guide](CONTRIBUTING.md) to get started.
|
|
95
|
+
|
|
96
|
+
<!-- ## ๐ Documentation
|
|
97
|
+
|
|
98
|
+
- [Full Documentation](https://docs.skmtc.dev)
|
|
99
|
+
- [API Reference](https://docs.skmtc.dev/api)
|
|
100
|
+
- [Custom Generators Guide](https://docs.skmtc.dev/generators)
|
|
101
|
+
- [Examples](https://github.com/skmtc/skmtc/tree/main/examples) -->
|
|
102
|
+
|
|
103
|
+
## ๐ Support
|
|
104
|
+
|
|
105
|
+
- [GitHub Issues](https://github.com/skmtc/skmtc/issues) - Bug reports and feature requests
|
|
106
|
+
- [Discord Community](https://discord.com/invite/Mg88C8Xu5Y) - Get help and share your experience
|
|
107
|
+
|
|
108
|
+
## ๐ License
|
|
109
|
+
|
|
110
|
+
Apache 2.0 ยฉ [Skmtc Contributors](LICENSE.md)
|
|
111
|
+
|
|
112
|
+
---
|
|
113
|
+
|
|
114
|
+
[](https://opensource.org/licenses/Apache-2.0)
|
|
115
|
+
[](https://deno.land/)
|
|
116
|
+
[](https://discord.com/invite/Mg88C8Xu5Y)
|