@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.
- package/dist/docs/RULES_COMPOSITION.md +115 -137
- package/dist/docs/RULES_NULLABLE.md +69 -141
- package/dist/docs/RULES_PATTERNS.md +90 -85
- package/dist/docs/RULES_REFERENCES.md +46 -114
- package/dist/docs/RULES_STRUCTURE.md +58 -57
- package/dist/docs/RULES_TYPES.md +88 -91
- package/dist/docs/WRITING_GUIDE.md +144 -123
- package/package.json +1 -1
package/dist/docs/RULES_TYPES.md
CHANGED
|
@@ -1,66 +1,89 @@
|
|
|
1
1
|
# Types Rules
|
|
2
2
|
|
|
3
|
+
**Only the keywords documented here are valid. Anything not listed will be rejected.**
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Valid Type Values (Complete List)
|
|
8
|
+
|
|
9
|
+
These are the **only** values the `type` field accepts:
|
|
10
|
+
|
|
11
|
+
| `type` value | Notes |
|
|
12
|
+
| --- | --- |
|
|
13
|
+
| `string` | Accepts optional `format: date` and/or `enum` |
|
|
14
|
+
| `number` | Accepts optional `enum` |
|
|
15
|
+
| `integer` | Same as number. Accepts optional `enum` |
|
|
16
|
+
| `boolean` | |
|
|
17
|
+
| `unknown` | Dynamic/untyped value |
|
|
18
|
+
| `object` | Requires `properties` and/or `additionalProperties` |
|
|
19
|
+
| `array` | Requires `items`. Cannot be a top-level type |
|
|
20
|
+
|
|
21
|
+
**No other type values exist.** `date`, `datetime`, `float`, `int`, `any`, `null`, `void`, `map`, `list` are all invalid.
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## Valid Format Values (Complete List)
|
|
26
|
+
|
|
27
|
+
There is exactly **one** valid format:
|
|
28
|
+
|
|
29
|
+
| `format` value | Applies to |
|
|
30
|
+
| --- | --- |
|
|
31
|
+
| `date` | `type: string` only |
|
|
32
|
+
|
|
33
|
+
**No other format values exist.** `date-time`, `datetime`, `time`, `email`, `uri`, `uuid`, `iso8601`, `url` are all invalid.
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
3
37
|
## Primitive Types
|
|
4
38
|
|
|
5
|
-
|
|
6
|
-
| ------------------------- | ---------- | ------------------- |
|
|
7
|
-
| `string` | `string` | Basic string |
|
|
8
|
-
| `string` + `format: date` | `Date` | Date object |
|
|
9
|
-
| `number` | `number` | Floating point |
|
|
10
|
-
| `integer` | `number` | Also becomes number |
|
|
11
|
-
| `boolean` | `boolean` | True/false |
|
|
12
|
-
| `unknown` | `unknown` | Dynamic/any type |
|
|
39
|
+
Valid keywords on a primitive: `type`, `enum`, `format`, `description`, `example`. Nothing else.
|
|
13
40
|
|
|
14
41
|
```yaml
|
|
15
42
|
properties:
|
|
16
|
-
name:
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
43
|
+
name:
|
|
44
|
+
type: string
|
|
45
|
+
age:
|
|
46
|
+
type: number
|
|
47
|
+
isActive:
|
|
48
|
+
type: boolean
|
|
49
|
+
birthDate:
|
|
50
|
+
type: string
|
|
51
|
+
format: date
|
|
52
|
+
metadata:
|
|
53
|
+
type: unknown
|
|
21
54
|
```
|
|
22
55
|
|
|
23
56
|
---
|
|
24
57
|
|
|
25
58
|
## Object Types
|
|
26
59
|
|
|
60
|
+
Valid keywords on an object: `type`, `properties`, `required`, `additionalProperties`, `description`, `example`. Nothing else.
|
|
61
|
+
|
|
27
62
|
```yaml
|
|
28
63
|
User:
|
|
29
64
|
type: object
|
|
30
|
-
description: 'User account'
|
|
31
|
-
example: "{ id: '123' }" # Optional - becomes JSDoc
|
|
65
|
+
description: 'User account'
|
|
32
66
|
required:
|
|
33
67
|
- id
|
|
34
68
|
- email
|
|
35
69
|
properties:
|
|
36
70
|
id:
|
|
37
71
|
type: string
|
|
38
|
-
description: 'Unique ID'
|
|
39
|
-
example: 'user-123' # Optional
|
|
72
|
+
description: 'Unique ID'
|
|
40
73
|
email:
|
|
41
74
|
type: string
|
|
42
75
|
name:
|
|
43
|
-
type: string
|
|
76
|
+
type: string
|
|
44
77
|
```
|
|
45
78
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
```typescript
|
|
49
|
-
/**
|
|
50
|
-
* @description User account
|
|
51
|
-
*/
|
|
52
|
-
export type User = {
|
|
53
|
-
/** @description Unique ID */
|
|
54
|
-
id: string;
|
|
55
|
-
email: string;
|
|
56
|
-
name: string | null;
|
|
57
|
-
};
|
|
58
|
-
```
|
|
79
|
+
In this example, `name` is not in `required`, so it is nullable.
|
|
59
80
|
|
|
60
81
|
---
|
|
61
82
|
|
|
62
83
|
## Enum Types
|
|
63
84
|
|
|
85
|
+
Enums use the `enum` keyword with either `type: string` or `type: number`. No other enum mechanism exists (`allowed_values`, `values`, `options`, `choices` are all invalid).
|
|
86
|
+
|
|
64
87
|
### String Enum (Top-Level)
|
|
65
88
|
|
|
66
89
|
```yaml
|
|
@@ -72,8 +95,6 @@ Status:
|
|
|
72
95
|
- pending
|
|
73
96
|
```
|
|
74
97
|
|
|
75
|
-
**TypeScript:** `export type Status = 'active' | 'inactive' | 'pending';`
|
|
76
|
-
|
|
77
98
|
### Number Enum (Top-Level)
|
|
78
99
|
|
|
79
100
|
```yaml
|
|
@@ -85,8 +106,6 @@ Priority:
|
|
|
85
106
|
- 3
|
|
86
107
|
```
|
|
87
108
|
|
|
88
|
-
**TypeScript:** `export type Priority = 1 | 2 | 3;`
|
|
89
|
-
|
|
90
109
|
### Inline Enum (Property)
|
|
91
110
|
|
|
92
111
|
```yaml
|
|
@@ -101,28 +120,22 @@ User:
|
|
|
101
120
|
- guest
|
|
102
121
|
```
|
|
103
122
|
|
|
104
|
-
**TypeScript:**
|
|
105
|
-
|
|
106
|
-
```typescript
|
|
107
|
-
export type User = {
|
|
108
|
-
role: ('admin' | 'user' | 'guest') | null;
|
|
109
|
-
};
|
|
110
|
-
```
|
|
111
|
-
|
|
112
123
|
---
|
|
113
124
|
|
|
114
125
|
## Array Types
|
|
115
126
|
|
|
116
|
-
|
|
127
|
+
Valid keywords on an array: `type`, `items`, `description`. Nothing else.
|
|
128
|
+
|
|
129
|
+
### Arrays Cannot Be Top-Level Types
|
|
117
130
|
|
|
118
131
|
```yaml
|
|
119
|
-
# WRONG -
|
|
132
|
+
# WRONG - will not work
|
|
120
133
|
Tags:
|
|
121
134
|
type: array
|
|
122
135
|
items:
|
|
123
136
|
type: string
|
|
124
137
|
|
|
125
|
-
# CORRECT -
|
|
138
|
+
# CORRECT - arrays must be properties
|
|
126
139
|
Post:
|
|
127
140
|
type: object
|
|
128
141
|
properties:
|
|
@@ -142,8 +155,6 @@ properties:
|
|
|
142
155
|
type: string
|
|
143
156
|
```
|
|
144
157
|
|
|
145
|
-
**TypeScript:** `tags: string[] | null`
|
|
146
|
-
|
|
147
158
|
### Array of Objects
|
|
148
159
|
|
|
149
160
|
```yaml
|
|
@@ -152,14 +163,15 @@ properties:
|
|
|
152
163
|
type: array
|
|
153
164
|
items:
|
|
154
165
|
type: object
|
|
155
|
-
required:
|
|
166
|
+
required:
|
|
167
|
+
- text
|
|
156
168
|
properties:
|
|
157
|
-
text:
|
|
158
|
-
|
|
169
|
+
text:
|
|
170
|
+
type: string
|
|
171
|
+
author:
|
|
172
|
+
type: string
|
|
159
173
|
```
|
|
160
174
|
|
|
161
|
-
**TypeScript:** `comments: { text: string; author: string | null }[] | null`
|
|
162
|
-
|
|
163
175
|
### Array of References
|
|
164
176
|
|
|
165
177
|
```yaml
|
|
@@ -170,12 +182,12 @@ properties:
|
|
|
170
182
|
$ref: '#/types/Post'
|
|
171
183
|
```
|
|
172
184
|
|
|
173
|
-
**TypeScript:** `posts: Post[] | null`
|
|
174
|
-
|
|
175
185
|
---
|
|
176
186
|
|
|
177
187
|
## Nested Objects
|
|
178
188
|
|
|
189
|
+
Each nested object follows the same keyword rules as top-level objects.
|
|
190
|
+
|
|
179
191
|
```yaml
|
|
180
192
|
Company:
|
|
181
193
|
type: object
|
|
@@ -198,23 +210,12 @@ Company:
|
|
|
198
210
|
type: string
|
|
199
211
|
```
|
|
200
212
|
|
|
201
|
-
**TypeScript:**
|
|
202
|
-
|
|
203
|
-
```typescript
|
|
204
|
-
export type Company = {
|
|
205
|
-
id: string;
|
|
206
|
-
address: {
|
|
207
|
-
street: string;
|
|
208
|
-
city: string | null;
|
|
209
|
-
zip: string | null;
|
|
210
|
-
};
|
|
211
|
-
};
|
|
212
|
-
```
|
|
213
|
-
|
|
214
213
|
---
|
|
215
214
|
|
|
216
215
|
## Additional Properties (Hashmaps/Dictionaries)
|
|
217
216
|
|
|
217
|
+
`additionalProperties` accepts either `true` or an object with `keyType` and `valueType`. No other forms.
|
|
218
|
+
|
|
218
219
|
### Simple Hashmap (any values)
|
|
219
220
|
|
|
220
221
|
```yaml
|
|
@@ -223,8 +224,6 @@ Metadata:
|
|
|
223
224
|
additionalProperties: true
|
|
224
225
|
```
|
|
225
226
|
|
|
226
|
-
**TypeScript:** `{ [keys: string]: unknown }`
|
|
227
|
-
|
|
228
227
|
### Typed Hashmap
|
|
229
228
|
|
|
230
229
|
```yaml
|
|
@@ -236,8 +235,6 @@ StringMap:
|
|
|
236
235
|
type: string
|
|
237
236
|
```
|
|
238
237
|
|
|
239
|
-
**TypeScript:** `{ [keys: string]: string }`
|
|
240
|
-
|
|
241
238
|
### Number Keys
|
|
242
239
|
|
|
243
240
|
```yaml
|
|
@@ -249,8 +246,6 @@ IdMap:
|
|
|
249
246
|
$ref: '#/types/User'
|
|
250
247
|
```
|
|
251
248
|
|
|
252
|
-
**TypeScript:** `{ [keys: number]: User }`
|
|
253
|
-
|
|
254
249
|
### Mixed: Properties + Additional
|
|
255
250
|
|
|
256
251
|
```yaml
|
|
@@ -267,25 +262,27 @@ UserWithMeta:
|
|
|
267
262
|
type: string
|
|
268
263
|
```
|
|
269
264
|
|
|
270
|
-
|
|
265
|
+
---
|
|
271
266
|
|
|
272
|
-
|
|
273
|
-
export type UserWithMeta = {
|
|
274
|
-
id: string;
|
|
275
|
-
[keys: string]: string;
|
|
276
|
-
};
|
|
277
|
-
```
|
|
267
|
+
## Valid Keywords Summary
|
|
278
268
|
|
|
279
|
-
|
|
269
|
+
| Type Kind | Valid Keywords (and ONLY these) |
|
|
270
|
+
| --- | --- |
|
|
271
|
+
| Primitive | `type`, `enum`, `format`, `description`, `example` |
|
|
272
|
+
| Object | `type`, `properties`, `required`, `additionalProperties`, `description`, `example` |
|
|
273
|
+
| Array | `type`, `items`, `description` |
|
|
274
|
+
| Reference | `$ref` |
|
|
275
|
+
| Union | `oneOf` |
|
|
276
|
+
| Intersection | `allOf` |
|
|
280
277
|
|
|
281
278
|
## Type Definition Summary
|
|
282
279
|
|
|
283
|
-
| Type
|
|
284
|
-
|
|
|
285
|
-
| Object
|
|
286
|
-
| Enum
|
|
287
|
-
| Primitive
|
|
288
|
-
| Array
|
|
289
|
-
| Union
|
|
290
|
-
| Intersection | `allOf
|
|
291
|
-
| Reference
|
|
280
|
+
| Type | Structure | Top-Level? |
|
|
281
|
+
| --- | --- | --- |
|
|
282
|
+
| Object | `type: object` + `properties` | Yes |
|
|
283
|
+
| Enum | `type: string` or `type: number` + `enum` | Yes |
|
|
284
|
+
| Primitive | `type: string` / `number` / `boolean` / `unknown` | Yes |
|
|
285
|
+
| Array | `type: array` + `items` | **NO** |
|
|
286
|
+
| Union | `oneOf` with array | Yes |
|
|
287
|
+
| Intersection | `allOf` with array | Yes |
|
|
288
|
+
| Reference | `$ref` with path | Yes |
|
|
@@ -1,147 +1,165 @@
|
|
|
1
1
|
# Type Crafter YAML Specification Guide
|
|
2
2
|
|
|
3
|
-
Type Crafter generates
|
|
3
|
+
Type Crafter generates typed code from YAML specifications. This guide is the definitive reference for what is valid. **If something is not listed here, it is not supported and will be rejected.**
|
|
4
4
|
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
-
##
|
|
7
|
+
## Complete Valid Keyword Reference
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
info:
|
|
11
|
-
version: '1.0.0'
|
|
12
|
-
title: 'My API Types'
|
|
9
|
+
### Root-Level Keys (ONLY these three exist)
|
|
13
10
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
- email
|
|
20
|
-
properties:
|
|
21
|
-
id:
|
|
22
|
-
type: string
|
|
23
|
-
email:
|
|
24
|
-
type: string
|
|
25
|
-
name:
|
|
26
|
-
type: string # Not in required = nullable (string | null)
|
|
27
|
-
```
|
|
11
|
+
| Key | Required | Description |
|
|
12
|
+
| --- | --- | --- |
|
|
13
|
+
| `info` | Yes (for top files) | Version and title metadata |
|
|
14
|
+
| `types` | At least one of `types` or `groupedTypes` | Flat/top-level type definitions |
|
|
15
|
+
| `groupedTypes` | At least one of `types` or `groupedTypes` | Namespaced type definitions |
|
|
28
16
|
|
|
29
|
-
**
|
|
17
|
+
**No other root-level keys exist.** Do not add `schemas`, `definitions`, `components`, or anything else at the root.
|
|
30
18
|
|
|
31
|
-
|
|
32
|
-
export type User = {
|
|
33
|
-
id: string;
|
|
34
|
-
email: string;
|
|
35
|
-
name: string | null;
|
|
36
|
-
};
|
|
37
|
-
```
|
|
19
|
+
### The `info` Object (ONLY these two keys)
|
|
38
20
|
|
|
39
|
-
|
|
21
|
+
| Key | Type | Required | Description |
|
|
22
|
+
| --- | --- | --- | --- |
|
|
23
|
+
| `version` | string | Yes | Semver format, e.g. `'1.0.0'` |
|
|
24
|
+
| `title` | string | Yes | Descriptive title |
|
|
40
25
|
|
|
41
|
-
|
|
26
|
+
**No other info keys exist.** Do not add `description`, `contact`, `license`, or anything else.
|
|
42
27
|
|
|
43
|
-
###
|
|
28
|
+
### Valid Type Values (ONLY these)
|
|
44
29
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
# name is NOT here, so it becomes nullable
|
|
55
|
-
properties:
|
|
56
|
-
id: { type: string }
|
|
57
|
-
name: { type: string } # Generates: string | null
|
|
58
|
-
```
|
|
30
|
+
| `type` value | Notes |
|
|
31
|
+
| --- | --- |
|
|
32
|
+
| `string` | Basic string |
|
|
33
|
+
| `number` | Numeric value |
|
|
34
|
+
| `integer` | Numeric value (same as number) |
|
|
35
|
+
| `boolean` | True/false |
|
|
36
|
+
| `unknown` | Dynamic/untyped value |
|
|
37
|
+
| `object` | Must have `properties` and/or `additionalProperties` |
|
|
38
|
+
| `array` | Must have `items`. **Cannot be a top-level type.** |
|
|
59
39
|
|
|
60
|
-
|
|
40
|
+
**No other type values exist.** Do not use `date`, `datetime`, `float`, `int`, `any`, `null`, `void`, `map`, `list`, `dict`, or anything else.
|
|
61
41
|
|
|
62
|
-
|
|
63
|
-
# WRONG
|
|
64
|
-
name:
|
|
65
|
-
type: string
|
|
66
|
-
optional: true # THIS PROPERTY DOES NOT EXIST
|
|
67
|
-
|
|
68
|
-
# CORRECT - Use required array
|
|
69
|
-
required: [id] # Only id is required
|
|
70
|
-
properties:
|
|
71
|
-
id: { type: string }
|
|
72
|
-
name: { type: string } # Not in required = nullable
|
|
73
|
-
```
|
|
42
|
+
### Valid Format Values (ONLY one exists)
|
|
74
43
|
|
|
75
|
-
|
|
44
|
+
| `format` value | Applies to | Description |
|
|
45
|
+
| --- | --- | --- |
|
|
46
|
+
| `date` | `type: string` only | Represents a date value |
|
|
76
47
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
48
|
+
**No other format values exist.** Do not use `date-time`, `datetime`, `time`, `email`, `uri`, `url`, `uuid`, `iso8601`, or anything else.
|
|
49
|
+
|
|
50
|
+
### Valid Keywords Per Type Kind
|
|
51
|
+
|
|
52
|
+
#### On a primitive (`type: string | number | integer | boolean | unknown`)
|
|
53
|
+
|
|
54
|
+
| Keyword | Required | Description |
|
|
55
|
+
| --- | --- | --- |
|
|
56
|
+
| `type` | Yes | One of: `string`, `number`, `integer`, `boolean`, `unknown` |
|
|
57
|
+
| `enum` | No | Array of allowed values. Creates a union of literals. |
|
|
58
|
+
| `format` | No | Only `date`, only on `type: string` |
|
|
59
|
+
| `description` | No | Documentation comment |
|
|
60
|
+
| `example` | No | Documentation example |
|
|
61
|
+
|
|
62
|
+
#### On an object (`type: object`)
|
|
63
|
+
|
|
64
|
+
| Keyword | Required | Description |
|
|
65
|
+
| --- | --- | --- |
|
|
66
|
+
| `type` | Yes | Must be `object` |
|
|
67
|
+
| `properties` | Yes (unless `additionalProperties` only) | Map of property names to type definitions |
|
|
68
|
+
| `required` | No | Array of property names that are non-nullable |
|
|
69
|
+
| `additionalProperties` | No | `true` or object with `keyType` and `valueType` for hashmaps |
|
|
70
|
+
| `description` | No | Documentation comment |
|
|
71
|
+
| `example` | No | Documentation example |
|
|
72
|
+
|
|
73
|
+
#### On an array (`type: array`)
|
|
88
74
|
|
|
89
|
-
|
|
75
|
+
| Keyword | Required | Description |
|
|
76
|
+
| --- | --- | --- |
|
|
77
|
+
| `type` | Yes | Must be `array` |
|
|
78
|
+
| `items` | Yes | Type definition for array elements |
|
|
79
|
+
| `description` | No | Documentation comment |
|
|
80
|
+
|
|
81
|
+
#### On a reference
|
|
82
|
+
|
|
83
|
+
| Keyword | Required | Description |
|
|
84
|
+
| --- | --- | --- |
|
|
85
|
+
| `$ref` | Yes | Path to referenced type |
|
|
86
|
+
|
|
87
|
+
#### On a composition
|
|
88
|
+
|
|
89
|
+
| Keyword | Required | Description |
|
|
90
|
+
| --- | --- | --- |
|
|
91
|
+
| `oneOf` | Yes (for unions) | Array of type definitions. Union of types. |
|
|
92
|
+
| `allOf` | Yes (for intersections) | Array of type definitions. Intersection of types. |
|
|
93
|
+
|
|
94
|
+
**No other keywords exist anywhere.** Do not use `nullable`, `optional`, `extensible`, `default`, `minimum`, `maximum`, `minLength`, `maxLength`, `pattern`, `title` (on properties), `readOnly`, `writeOnly`, `deprecated`, `discriminator`, `allowed_values`, `values`, `options`, `choices`, or anything from OpenAPI/JSON Schema that is not listed above.
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
98
|
+
## Nullability: The Only Mechanism
|
|
99
|
+
|
|
100
|
+
Properties **not** listed in the `required` array become nullable. This is the **only** way to make a property nullable. There is no other mechanism.
|
|
90
101
|
|
|
91
102
|
```yaml
|
|
92
|
-
|
|
93
|
-
Tags:
|
|
94
|
-
type: array
|
|
95
|
-
items:
|
|
96
|
-
type: string
|
|
97
|
-
|
|
98
|
-
# CORRECT - Arrays must be properties within objects
|
|
99
|
-
Post:
|
|
103
|
+
User:
|
|
100
104
|
type: object
|
|
105
|
+
required:
|
|
106
|
+
- id
|
|
107
|
+
- email
|
|
101
108
|
properties:
|
|
102
|
-
|
|
103
|
-
type:
|
|
104
|
-
|
|
105
|
-
|
|
109
|
+
id:
|
|
110
|
+
type: string
|
|
111
|
+
email:
|
|
112
|
+
type: string
|
|
113
|
+
name:
|
|
114
|
+
type: string
|
|
106
115
|
```
|
|
107
116
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
```yaml
|
|
111
|
-
# WRONG - Relative paths from current file
|
|
112
|
-
$ref: '../common/types.yaml#/User'
|
|
117
|
+
In this example, `id` and `email` are non-nullable. `name` is not in `required`, so it is nullable.
|
|
113
118
|
|
|
114
|
-
|
|
115
|
-
$ref: './src/common/types.yaml#/User'
|
|
116
|
-
```
|
|
119
|
+
---
|
|
117
120
|
|
|
118
|
-
|
|
121
|
+
## Minimal Valid Spec
|
|
119
122
|
|
|
120
123
|
```yaml
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
+
info:
|
|
125
|
+
version: '1.0.0'
|
|
126
|
+
title: 'My API Types'
|
|
124
127
|
|
|
125
|
-
|
|
126
|
-
|
|
128
|
+
types:
|
|
129
|
+
User:
|
|
130
|
+
type: object
|
|
131
|
+
required:
|
|
132
|
+
- id
|
|
133
|
+
- email
|
|
134
|
+
properties:
|
|
135
|
+
id:
|
|
136
|
+
type: string
|
|
137
|
+
email:
|
|
138
|
+
type: string
|
|
139
|
+
name:
|
|
140
|
+
type: string
|
|
127
141
|
```
|
|
128
142
|
|
|
129
143
|
---
|
|
130
144
|
|
|
131
145
|
## Quick Reference
|
|
132
146
|
|
|
133
|
-
| Concept
|
|
134
|
-
|
|
|
135
|
-
| Required property |
|
|
136
|
-
| Nullable property | NOT in `required`
|
|
137
|
-
| String
|
|
138
|
-
| Number
|
|
139
|
-
| Boolean
|
|
140
|
-
| Date
|
|
141
|
-
|
|
|
142
|
-
|
|
|
143
|
-
|
|
|
144
|
-
|
|
|
147
|
+
| Concept | YAML |
|
|
148
|
+
| --- | --- |
|
|
149
|
+
| Required property | Listed in `required` array |
|
|
150
|
+
| Nullable property | NOT listed in `required` array |
|
|
151
|
+
| String | `type: string` |
|
|
152
|
+
| Number | `type: number` |
|
|
153
|
+
| Boolean | `type: boolean` |
|
|
154
|
+
| Date | `type: string` with `format: date` |
|
|
155
|
+
| Unknown | `type: unknown` |
|
|
156
|
+
| String enum | `type: string` with `enum` list |
|
|
157
|
+
| Number enum | `type: number` with `enum` list |
|
|
158
|
+
| Array | `type: array` with `items` |
|
|
159
|
+
| Union | `oneOf` with array of types |
|
|
160
|
+
| Intersection | `allOf` with array of types |
|
|
161
|
+
| Reference | `$ref` with path |
|
|
162
|
+
| Hashmap | `additionalProperties: true` or with `keyType`/`valueType` |
|
|
145
163
|
|
|
146
164
|
---
|
|
147
165
|
|
|
@@ -149,21 +167,21 @@ $ref: './docs/cart.yaml#/Cart/CartItem'
|
|
|
149
167
|
|
|
150
168
|
Call `get-rules-section` with these topics for deep dives:
|
|
151
169
|
|
|
152
|
-
| Section
|
|
153
|
-
|
|
|
154
|
-
| `structure`
|
|
155
|
-
| `types`
|
|
156
|
-
| `nullable`
|
|
157
|
-
| `references`
|
|
158
|
-
| `composition` | oneOf (unions), allOf (intersections)
|
|
159
|
-
| `patterns`
|
|
170
|
+
| Section | What You'll Learn |
|
|
171
|
+
| --- | --- |
|
|
172
|
+
| `structure` | Root structure, info section, types vs groupedTypes |
|
|
173
|
+
| `types` | Objects, enums, primitives, arrays, nested objects |
|
|
174
|
+
| `nullable` | How `required` array controls nullability |
|
|
175
|
+
| `references` | $ref syntax, top-file vs non-top-file rules |
|
|
176
|
+
| `composition` | oneOf (unions), allOf (intersections) |
|
|
177
|
+
| `patterns` | Common patterns with full examples |
|
|
160
178
|
|
|
161
179
|
---
|
|
162
180
|
|
|
163
181
|
## Workflow
|
|
164
182
|
|
|
165
183
|
1. Read this guide (you just did)
|
|
166
|
-
2. Write your YAML spec
|
|
184
|
+
2. Write your YAML spec using ONLY the keywords listed above
|
|
167
185
|
3. Call `validate-spec` to check for errors
|
|
168
186
|
4. Fix any issues
|
|
169
187
|
5. Run `type-crafter generate` CLI in your project
|
|
@@ -172,8 +190,11 @@ Call `get-rules-section` with these topics for deep dives:
|
|
|
172
190
|
|
|
173
191
|
## Key Rules Summary
|
|
174
192
|
|
|
175
|
-
1. **
|
|
176
|
-
2. **
|
|
177
|
-
3. **
|
|
178
|
-
4. **
|
|
179
|
-
5. **
|
|
193
|
+
1. **Only use keywords listed in this guide** - Anything else is invalid and will be rejected
|
|
194
|
+
2. **Nullability = `required` array** - The only mechanism that controls this
|
|
195
|
+
3. **Only valid format is `date`** - No other format values exist
|
|
196
|
+
4. **Only valid types are `string`, `number`, `integer`, `boolean`, `unknown`, `object`, `array`**
|
|
197
|
+
5. **Arrays = properties only** - Never top-level types
|
|
198
|
+
6. **Paths = from project root** - Where you run the CLI
|
|
199
|
+
7. **Top file = has `info` section** - Can use `#/` references
|
|
200
|
+
8. **Non-top file = no `info`** - Must use full file paths for ALL references
|