@type-crafter/mcp 1.2.0 → 1.2.1

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.
@@ -1,46 +1,37 @@
1
1
  # References Rules
2
2
 
3
- ## Reference Syntax
3
+ **Only the `$ref` keyword is used for references. No other referencing mechanism exists (`$include`, `$import`, `extends`, `inherits`, etc. are all invalid).**
4
4
 
5
- References use `$ref` to point to other types:
5
+ ---
6
6
 
7
- ```yaml
8
- $ref: '#/types/TypeName' # Same file, top-level type
9
- $ref: '#/groupedTypes/Group/Type' # Same file, grouped type
10
- $ref: './path/file.yaml#/TypeName' # External file
11
- ```
7
+ ## Valid Reference Formats (Complete List)
12
8
 
13
- ---
9
+ There are exactly **three** valid `$ref` formats:
14
10
 
15
- ## Top File vs Non-Top File (CRITICAL)
11
+ | Format | When to use | Example |
12
+ | --- | --- | --- |
13
+ | `#/types/TypeName` | Top file, same-file, types section | `$ref: '#/types/User'` |
14
+ | `#/groupedTypes/Group/TypeName` | Top file, same-file, grouped section | `$ref: '#/groupedTypes/Auth/Token'` |
15
+ | `'./path/file.yaml#/TypePath'` | External file, OR any ref in non-top files | `$ref: './shared/types.yaml#/User'` |
16
16
 
17
- ### Identifying File Type
17
+ **No other reference formats exist.**
18
+
19
+ ---
18
20
 
19
- **Top File** = Has `info` section at root:
21
+ ## Top File vs Non-Top File
20
22
 
21
- ```yaml
22
- info:
23
- version: '1.0.0'
24
- title: 'My Types'
25
- types:
26
- User: { ... }
27
- ```
23
+ ### Identifying File Type
28
24
 
29
- **Non-Top File** = No `info` section:
25
+ **Top File** = Has `info` section with valid `version` and `title`.
30
26
 
31
- ```yaml
32
- # No info section here
33
- UserTypes:
34
- User: { ... }
35
- Profile: { ... }
36
- ```
27
+ **Non-Top File** = No `info` section.
37
28
 
38
29
  ### Reference Rules by File Type
39
30
 
40
- | File Type | Same-File Reference | External Reference |
41
- | ------------ | ---------------------------------- | -------------------------- |
42
- | Top File | `#/types/Name` | `'./path/file.yaml#/Name'` |
43
- | Non-Top File | `'./path/to/this-file.yaml#/Name'` | `'./path/file.yaml#/Name'` |
31
+ | File Type | Same-File Reference | External Reference |
32
+ | --- | --- | --- |
33
+ | Top File | `#/types/Name` or `#/groupedTypes/Group/Name` | `'./path/file.yaml#/Name'` |
34
+ | Non-Top File | `'./path/to/this-file.yaml#/Name'` (full path required) | `'./path/file.yaml#/Name'` |
44
35
 
45
36
  ---
46
37
 
@@ -49,7 +40,6 @@ UserTypes:
49
40
  In a file WITH `info` section:
50
41
 
51
42
  ```yaml
52
- # types.yaml (TOP FILE)
53
43
  info:
54
44
  version: '1.0.0'
55
45
  title: 'API Types'
@@ -59,12 +49,13 @@ types:
59
49
  type: object
60
50
  properties:
61
51
  profile:
62
- $ref: '#/types/Profile' # Same-file reference
52
+ $ref: '#/types/Profile'
63
53
 
64
54
  Profile:
65
55
  type: object
66
56
  properties:
67
- bio: { type: string }
57
+ bio:
58
+ type: string
68
59
 
69
60
  groupedTypes:
70
61
  Auth:
@@ -72,14 +63,15 @@ groupedTypes:
72
63
  type: object
73
64
  properties:
74
65
  user:
75
- $ref: '#/types/User' # Reference to types section
66
+ $ref: '#/types/User'
76
67
  session:
77
- $ref: '#/groupedTypes/Auth/Session' # Same group
68
+ $ref: '#/groupedTypes/Auth/Session'
78
69
 
79
70
  Session:
80
71
  type: object
81
72
  properties:
82
- token: { type: string }
73
+ token:
74
+ type: string
83
75
  ```
84
76
 
85
77
  ---
@@ -89,7 +81,6 @@ groupedTypes:
89
81
  In a file WITHOUT `info` section, you MUST use full paths for EVERYTHING:
90
82
 
91
83
  ```yaml
92
- # shared/cart.yaml (NON-TOP FILE - no info section)
93
84
  Cart:
94
85
  CartItem:
95
86
  type: object
@@ -97,7 +88,6 @@ Cart:
97
88
  - product
98
89
  properties:
99
90
  product:
100
- # MUST use full path even for same-file reference
101
91
  $ref: './shared/cart.yaml#/Cart/Product'
102
92
  quantity:
103
93
  type: number
@@ -105,27 +95,14 @@ Cart:
105
95
  Product:
106
96
  type: object
107
97
  properties:
108
- name: { type: string }
109
- price: { type: number }
98
+ name:
99
+ type: string
100
+ price:
101
+ type: number
110
102
  ```
111
103
 
112
104
  **Why?** Non-top files have no root context. The parser needs the full path to resolve references.
113
105
 
114
- ### Common Mistake in Non-Top Files
115
-
116
- ```yaml
117
- # shared/cart.yaml (NON-TOP FILE)
118
- Cart:
119
- CartItem:
120
- type: object
121
- properties:
122
- product:
123
- $ref: '#/Cart/Product' # WRONG! Missing file path
124
-
125
- product:
126
- $ref: './shared/cart.yaml#/Cart/Product' # CORRECT
127
- ```
128
-
129
106
  ---
130
107
 
131
108
  ## External File References
@@ -152,7 +129,6 @@ my-project/ # <- Run CLI from here
152
129
  ### References in api.yaml (top file)
153
130
 
154
131
  ```yaml
155
- # specs/api.yaml
156
132
  info:
157
133
  version: '1.0.0'
158
134
  title: 'API'
@@ -171,39 +147,20 @@ groupedTypes:
171
147
  ### References in cart.yaml (non-top file)
172
148
 
173
149
  ```yaml
174
- # specs/shop/cart.yaml (NON-TOP FILE)
175
150
  Cart:
176
151
  CartItem:
177
152
  type: object
178
153
  properties:
179
154
  product:
180
- # Reference to another non-top file
181
155
  $ref: './specs/shop/product.yaml#/Product/ProductInfo'
182
-
183
- # Same-file reference - still needs full path!
184
156
  discount:
185
157
  $ref: './specs/shop/cart.yaml#/Cart/Discount'
186
158
 
187
159
  Discount:
188
160
  type: object
189
161
  properties:
190
- amount: { type: number }
191
- ```
192
-
193
- ### WRONG: Using Relative Paths
194
-
195
- ```yaml
196
- # specs/shop/cart.yaml
197
- Cart:
198
- CartItem:
199
- type: object
200
- properties:
201
- product:
202
- # WRONG - Don't use ../
203
- $ref: '../product.yaml#/Product'
204
-
205
- # CORRECT - From project root
206
- $ref: './specs/shop/product.yaml#/Product'
162
+ amount:
163
+ type: number
207
164
  ```
208
165
 
209
166
  ---
@@ -213,29 +170,28 @@ Cart:
213
170
  You can reference an entire group, not just individual types:
214
171
 
215
172
  ```yaml
216
- # api.yaml (top file)
217
173
  info:
218
174
  version: '1.0.0'
219
175
  title: 'API'
220
176
 
221
177
  groupedTypes:
222
- # Import entire Auth group from external file
223
178
  Auth:
224
179
  $ref: './specs/auth/types.yaml#/AuthTypes'
225
180
  ```
226
181
 
227
182
  ```yaml
228
- # specs/auth/types.yaml (can be top or non-top)
229
183
  AuthTypes:
230
184
  LoginRequest:
231
185
  type: object
232
186
  properties:
233
- email: { type: string }
187
+ email:
188
+ type: string
234
189
 
235
190
  LoginResponse:
236
191
  type: object
237
192
  properties:
238
- token: { type: string }
193
+ token:
194
+ type: string
239
195
  ```
240
196
 
241
197
  ---
@@ -255,7 +211,7 @@ TreeNode:
255
211
  children:
256
212
  type: array
257
213
  items:
258
- $ref: '#/types/TreeNode' # Self-reference
214
+ $ref: '#/types/TreeNode'
259
215
 
260
216
  LinkedList:
261
217
  type: object
@@ -263,40 +219,16 @@ LinkedList:
263
219
  value:
264
220
  type: number
265
221
  next:
266
- $ref: '#/types/LinkedList' # Self-reference
222
+ $ref: '#/types/LinkedList'
267
223
  ```
268
224
 
269
- **TypeScript:**
270
-
271
- ```typescript
272
- export type TreeNode = {
273
- value: string;
274
- children: TreeNode[] | null;
275
- };
276
-
277
- export type LinkedList = {
278
- value: number | null;
279
- next: LinkedList | null;
280
- };
281
- ```
282
-
283
- ---
284
-
285
- ## Reference Path Formats
286
-
287
- | Context | Format | Example |
288
- | ---------------------------- | --------------------------- | -------------------------------------- |
289
- | Top file, same file, types | `#/types/Name` | `$ref: '#/types/User'` |
290
- | Top file, same file, grouped | `#/groupedTypes/Group/Name` | `$ref: '#/groupedTypes/Auth/Token'` |
291
- | Top file, external | `'./path/file.yaml#/...'` | `$ref: './shared/types.yaml#/User'` |
292
- | Non-top file, ANY reference | `'./path/file.yaml#/...'` | `$ref: './this/file.yaml#/Group/Type'` |
293
-
294
225
  ---
295
226
 
296
- ## Checklist
227
+ ## Valid Reference Formats Summary
297
228
 
298
- - [ ] Is this a top file or non-top file?
299
- - [ ] If non-top: Am I using full paths for ALL references?
300
- - [ ] Are paths from project root (not relative to current file)?
301
- - [ ] Do paths start with `./`?
302
- - [ ] No `../` in any path?
229
+ | Context | Format | Example |
230
+ | --- | --- | --- |
231
+ | Top file, same file, types | `#/types/Name` | `$ref: '#/types/User'` |
232
+ | Top file, same file, grouped | `#/groupedTypes/Group/Name` | `$ref: '#/groupedTypes/Auth/Token'` |
233
+ | Top file, external | `'./path/file.yaml#/...'` | `$ref: './shared/types.yaml#/User'` |
234
+ | Non-top file, ANY reference | `'./path/file.yaml#/...'` | `$ref: './this/file.yaml#/Group/Type'` |
@@ -1,35 +1,43 @@
1
1
  # Structure Rules
2
2
 
3
- ## Root Structure
3
+ **Only the structure documented here is valid. Any keys or sections not listed will be rejected.**
4
4
 
5
- Every Type Crafter spec file has this structure:
5
+ ---
6
6
 
7
- ```yaml
8
- info:
9
- version: '1.0.0' # Required - semver format
10
- title: 'My Types' # Required - descriptive title
7
+ ## Valid Root-Level Keys (Complete List)
11
8
 
12
- types: # Optional - flat/top-level types
13
- TypeName: { ... }
9
+ A spec file has exactly **three** possible root-level keys:
14
10
 
15
- groupedTypes: # Optional - organized into namespaces
16
- GroupName:
17
- TypeName: { ... }
18
- ```
11
+ | Key | Type | Required | Description |
12
+ | --- | --- | --- | --- |
13
+ | `info` | object | Yes (for top files) | Metadata with version and title |
14
+ | `types` | object | At least one required | Flat/top-level type definitions |
15
+ | `groupedTypes` | object | At least one required | Namespaced type definitions |
16
+
17
+ **No other root-level keys exist.** Do not add `schemas`, `definitions`, `components`, `models`, `imports`, `config`, or anything else.
19
18
 
20
19
  **Rule:** At least ONE of `types` or `groupedTypes` is required.
21
20
 
22
21
  ---
23
22
 
24
- ## The `info` Section
23
+ ## The `info` Object (Complete List)
24
+
25
+ The `info` object accepts exactly **two** keys:
26
+
27
+ | Key | Type | Required |
28
+ | --- | --- | --- |
29
+ | `version` | string (semver) | Yes |
30
+ | `title` | string | Yes |
31
+
32
+ **No other info keys exist.** Do not add `description`, `contact`, `license`, `baseUrl`, `servers`, or anything else.
25
33
 
26
34
  ```yaml
27
35
  info:
28
- version: '1.0.0' # String, semver format
29
- title: 'API Types' # String, describes the spec
36
+ version: '1.0.0'
37
+ title: 'API Types'
30
38
  ```
31
39
 
32
- Both fields are **required**. Without them, the file is a "non-top file" with different reference rules.
40
+ Without a valid `info` section, the file is a "non-top file" with different reference rules.
33
41
 
34
42
  ---
35
43
 
@@ -38,7 +46,6 @@ Both fields are **required**. Without them, the file is a "non-top file" with di
38
46
  ### Top File (has `info` section)
39
47
 
40
48
  ```yaml
41
- # top-file.yaml
42
49
  info:
43
50
  version: '1.0.0'
44
51
  title: 'Main Types'
@@ -48,11 +55,12 @@ types:
48
55
  type: object
49
56
  properties:
50
57
  profile:
51
- $ref: '#/types/Profile' # Can use #/ for same-file refs
58
+ $ref: '#/types/Profile'
52
59
  Profile:
53
60
  type: object
54
61
  properties:
55
- bio: { type: string }
62
+ bio:
63
+ type: string
56
64
  ```
57
65
 
58
66
  **Rules for top files:**
@@ -64,18 +72,17 @@ types:
64
72
  ### Non-Top File (no `info` section)
65
73
 
66
74
  ```yaml
67
- # shared/cart.yaml - NO info section
68
75
  Cart:
69
76
  CartItem:
70
77
  type: object
71
78
  properties:
72
79
  product:
73
- # MUST use full path, even for same-file refs
74
80
  $ref: './shared/cart.yaml#/Cart/Product'
75
81
  Product:
76
82
  type: object
77
83
  properties:
78
- name: { type: string }
84
+ name:
85
+ type: string
79
86
  ```
80
87
 
81
88
  **Rules for non-top files:**
@@ -94,13 +101,17 @@ For standalone, top-level types:
94
101
  types:
95
102
  User:
96
103
  type: object
97
- required: [id]
104
+ required:
105
+ - id
98
106
  properties:
99
- id: { type: string }
107
+ id:
108
+ type: string
100
109
 
101
110
  Status:
102
111
  type: string
103
- enum: [active, inactive]
112
+ enum:
113
+ - active
114
+ - inactive
104
115
 
105
116
  ApiResponse:
106
117
  oneOf:
@@ -108,14 +119,6 @@ types:
108
119
  - type: string
109
120
  ```
110
121
 
111
- **Generated TypeScript:**
112
-
113
- ```typescript
114
- export type User = { id: string };
115
- export type Status = 'active' | 'inactive';
116
- export type ApiResponse = User | string;
117
- ```
118
-
119
122
  ---
120
123
 
121
124
  ## `groupedTypes` Section (Namespaced Types)
@@ -127,41 +130,37 @@ groupedTypes:
127
130
  Auth:
128
131
  LoginRequest:
129
132
  type: object
130
- required: [email, password]
133
+ required:
134
+ - email
135
+ - password
131
136
  properties:
132
- email: { type: string }
133
- password: { type: string }
137
+ email:
138
+ type: string
139
+ password:
140
+ type: string
134
141
 
135
142
  LoginResponse:
136
143
  type: object
137
- required: [token]
144
+ required:
145
+ - token
138
146
  properties:
139
- token: { type: string }
147
+ token:
148
+ type: string
140
149
  user:
141
150
  $ref: '#/groupedTypes/Auth/User'
142
151
 
143
152
  User:
144
153
  type: object
145
154
  properties:
146
- id: { type: string }
155
+ id:
156
+ type: string
147
157
 
148
158
  Shop:
149
159
  Product:
150
160
  type: object
151
161
  properties:
152
- name: { type: string }
153
- ```
154
-
155
- **Generated TypeScript (with FolderWithFiles mode):**
156
-
157
- ```
158
- output/
159
- Auth/
160
- LoginRequest.ts
161
- LoginResponse.ts
162
- User.ts
163
- Shop/
164
- Product.ts
162
+ name:
163
+ type: string
165
164
  ```
166
165
 
167
166
  ---
@@ -176,22 +175,24 @@ info:
176
175
  title: 'Full API'
177
176
 
178
177
  types:
179
- # Shared/common types
180
178
  Timestamp:
181
179
  type: object
182
- required: [createdAt]
180
+ required:
181
+ - createdAt
183
182
  properties:
184
- createdAt: { type: string, format: date }
183
+ createdAt:
184
+ type: string
185
+ format: date
185
186
 
186
187
  groupedTypes:
187
- # Domain-specific types
188
188
  Users:
189
189
  User:
190
190
  allOf:
191
191
  - $ref: '#/types/Timestamp'
192
192
  - type: object
193
193
  properties:
194
- name: { type: string }
194
+ name:
195
+ type: string
195
196
  ```
196
197
 
197
198
  ---