schemantic 0.1.0

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.
Files changed (131) hide show
  1. package/CHANGELOG.md +92 -0
  2. package/LICENSE +21 -0
  3. package/README.md +827 -0
  4. package/dist/__tests__/setup.d.ts +6 -0
  5. package/dist/__tests__/setup.d.ts.map +1 -0
  6. package/dist/__tests__/setup.js +30 -0
  7. package/dist/__tests__/setup.js.map +1 -0
  8. package/dist/__tests__/test-config.d.ts +36 -0
  9. package/dist/__tests__/test-config.d.ts.map +1 -0
  10. package/dist/__tests__/test-config.js +563 -0
  11. package/dist/__tests__/test-config.js.map +1 -0
  12. package/dist/cli/index.d.ts +118 -0
  13. package/dist/cli/index.d.ts.map +1 -0
  14. package/dist/cli/index.js +657 -0
  15. package/dist/cli/index.js.map +1 -0
  16. package/dist/core/index.d.ts +5 -0
  17. package/dist/core/index.d.ts.map +1 -0
  18. package/dist/core/index.js +21 -0
  19. package/dist/core/index.js.map +1 -0
  20. package/dist/core/schemantic.d.ts +95 -0
  21. package/dist/core/schemantic.d.ts.map +1 -0
  22. package/dist/core/schemantic.js +543 -0
  23. package/dist/core/schemantic.js.map +1 -0
  24. package/dist/generators/api-client-generator.d.ts +145 -0
  25. package/dist/generators/api-client-generator.d.ts.map +1 -0
  26. package/dist/generators/api-client-generator.js +856 -0
  27. package/dist/generators/api-client-generator.js.map +1 -0
  28. package/dist/generators/base.d.ts +117 -0
  29. package/dist/generators/base.d.ts.map +1 -0
  30. package/dist/generators/base.js +232 -0
  31. package/dist/generators/base.js.map +1 -0
  32. package/dist/generators/enum-generator.d.ts +52 -0
  33. package/dist/generators/enum-generator.d.ts.map +1 -0
  34. package/dist/generators/enum-generator.js +178 -0
  35. package/dist/generators/enum-generator.js.map +1 -0
  36. package/dist/generators/factory.d.ts +59 -0
  37. package/dist/generators/factory.d.ts.map +1 -0
  38. package/dist/generators/factory.js +127 -0
  39. package/dist/generators/factory.js.map +1 -0
  40. package/dist/generators/hook-generator.d.ts +36 -0
  41. package/dist/generators/hook-generator.d.ts.map +1 -0
  42. package/dist/generators/hook-generator.js +495 -0
  43. package/dist/generators/hook-generator.js.map +1 -0
  44. package/dist/generators/index.d.ts +10 -0
  45. package/dist/generators/index.d.ts.map +1 -0
  46. package/dist/generators/index.js +26 -0
  47. package/dist/generators/index.js.map +1 -0
  48. package/dist/generators/object-generator.d.ts +48 -0
  49. package/dist/generators/object-generator.d.ts.map +1 -0
  50. package/dist/generators/object-generator.js +280 -0
  51. package/dist/generators/object-generator.js.map +1 -0
  52. package/dist/generators/primitive-generator.d.ts +40 -0
  53. package/dist/generators/primitive-generator.d.ts.map +1 -0
  54. package/dist/generators/primitive-generator.js +150 -0
  55. package/dist/generators/primitive-generator.js.map +1 -0
  56. package/dist/index.d.ts +17 -0
  57. package/dist/index.d.ts.map +1 -0
  58. package/dist/index.js +42 -0
  59. package/dist/index.js.map +1 -0
  60. package/dist/parsers/base.d.ts +101 -0
  61. package/dist/parsers/base.d.ts.map +1 -0
  62. package/dist/parsers/base.js +77 -0
  63. package/dist/parsers/base.js.map +1 -0
  64. package/dist/parsers/factory.d.ts +64 -0
  65. package/dist/parsers/factory.d.ts.map +1 -0
  66. package/dist/parsers/factory.js +116 -0
  67. package/dist/parsers/factory.js.map +1 -0
  68. package/dist/parsers/index.d.ts +7 -0
  69. package/dist/parsers/index.d.ts.map +1 -0
  70. package/dist/parsers/index.js +23 -0
  71. package/dist/parsers/index.js.map +1 -0
  72. package/dist/parsers/openapi.d.ts +52 -0
  73. package/dist/parsers/openapi.d.ts.map +1 -0
  74. package/dist/parsers/openapi.js +396 -0
  75. package/dist/parsers/openapi.js.map +1 -0
  76. package/dist/plugins/branded-types.d.ts +28 -0
  77. package/dist/plugins/branded-types.d.ts.map +1 -0
  78. package/dist/plugins/branded-types.js +568 -0
  79. package/dist/plugins/branded-types.js.map +1 -0
  80. package/dist/plugins/builtin.d.ts +38 -0
  81. package/dist/plugins/builtin.d.ts.map +1 -0
  82. package/dist/plugins/builtin.js +283 -0
  83. package/dist/plugins/builtin.js.map +1 -0
  84. package/dist/plugins/index.d.ts +7 -0
  85. package/dist/plugins/index.d.ts.map +1 -0
  86. package/dist/plugins/index.js +23 -0
  87. package/dist/plugins/index.js.map +1 -0
  88. package/dist/plugins/loader.d.ts +92 -0
  89. package/dist/plugins/loader.d.ts.map +1 -0
  90. package/dist/plugins/loader.js +245 -0
  91. package/dist/plugins/loader.js.map +1 -0
  92. package/dist/plugins/manager.d.ts +99 -0
  93. package/dist/plugins/manager.d.ts.map +1 -0
  94. package/dist/plugins/manager.js +233 -0
  95. package/dist/plugins/manager.js.map +1 -0
  96. package/dist/plugins/performance-monitoring.d.ts +98 -0
  97. package/dist/plugins/performance-monitoring.d.ts.map +1 -0
  98. package/dist/plugins/performance-monitoring.js +596 -0
  99. package/dist/plugins/performance-monitoring.js.map +1 -0
  100. package/dist/plugins/request-deduplication.d.ts +27 -0
  101. package/dist/plugins/request-deduplication.d.ts.map +1 -0
  102. package/dist/plugins/request-deduplication.js +650 -0
  103. package/dist/plugins/request-deduplication.js.map +1 -0
  104. package/dist/plugins/zod-validation.d.ts +63 -0
  105. package/dist/plugins/zod-validation.d.ts.map +1 -0
  106. package/dist/plugins/zod-validation.js +743 -0
  107. package/dist/plugins/zod-validation.js.map +1 -0
  108. package/dist/types/core.d.ts +203 -0
  109. package/dist/types/core.d.ts.map +1 -0
  110. package/dist/types/core.js +24 -0
  111. package/dist/types/core.js.map +1 -0
  112. package/dist/types/index.d.ts +7 -0
  113. package/dist/types/index.d.ts.map +1 -0
  114. package/dist/types/index.js +23 -0
  115. package/dist/types/index.js.map +1 -0
  116. package/dist/types/openapi.d.ts +250 -0
  117. package/dist/types/openapi.d.ts.map +1 -0
  118. package/dist/types/openapi.js +8 -0
  119. package/dist/types/openapi.js.map +1 -0
  120. package/dist/types/schema.d.ts +68 -0
  121. package/dist/types/schema.d.ts.map +1 -0
  122. package/dist/types/schema.js +22 -0
  123. package/dist/types/schema.js.map +1 -0
  124. package/docs/ADVANCED_PLUGINS_IMPLEMENTATION.md +355 -0
  125. package/docs/ADVANCED_PLUGIN_DEVELOPMENT.md +309 -0
  126. package/docs/API.md +600 -0
  127. package/docs/CONFIGURATION.md +722 -0
  128. package/docs/FASTAPI_TUTORIAL.md +1497 -0
  129. package/docs/PLUGINS.md +683 -0
  130. package/docs/PLUGIN_DEVELOPMENT.md +720 -0
  131. package/package.json +90 -0
@@ -0,0 +1,722 @@
1
+ # Configuration Guide
2
+
3
+ This guide explains all configuration options available in Schemantic.
4
+
5
+ ## Configuration Sources
6
+
7
+ Schemantic can be configured through multiple sources:
8
+
9
+ 1. **Command Line Arguments** - Highest priority
10
+ 2. **Configuration Files** - Medium priority
11
+ 3. **Default Values** - Lowest priority
12
+
13
+ ## Configuration File Formats
14
+
15
+ ### JSON Configuration
16
+
17
+ Create a `schemantic.config.json` file:
18
+
19
+ ```json
20
+ {
21
+ "schemaUrl": "http://localhost:8000/openapi.json",
22
+ "outputDir": "./src/generated",
23
+ "generateTypes": true,
24
+ "generateApiClient": true,
25
+ "useStrictTypes": true,
26
+ "namingConvention": "camelCase",
27
+ "plugins": [
28
+ { "name": "jsdoc", "enabled": true },
29
+ { "name": "validation", "enabled": true }
30
+ ]
31
+ }
32
+ ```
33
+
34
+ ### JavaScript Configuration
35
+
36
+ Create a `schemantic.config.js` file:
37
+
38
+ ```javascript
39
+ module.exports = {
40
+ schemaUrl: "http://localhost:8000/openapi.json",
41
+ outputDir: "./src/generated",
42
+ generateTypes: true,
43
+ generateApiClient: true,
44
+ useStrictTypes: true,
45
+ namingConvention: "camelCase",
46
+ plugins: [
47
+ { name: "jsdoc", enabled: true },
48
+ { name: "validation", enabled: true },
49
+ ],
50
+ };
51
+ ```
52
+
53
+ ### TypeScript Configuration
54
+
55
+ Create a `schemantic.config.ts` file:
56
+
57
+ ```typescript
58
+ import { SchemanticConfig } from "schemantic";
59
+
60
+ const config: SchemanticConfig = {
61
+ schemaUrl: "http://localhost:8000/openapi.json",
62
+ outputDir: "./src/generated",
63
+ generateTypes: true,
64
+ generateApiClient: true,
65
+ useStrictTypes: true,
66
+ namingConvention: "camelCase",
67
+ plugins: [
68
+ { name: "jsdoc", enabled: true },
69
+ { name: "validation", enabled: true },
70
+ ],
71
+ };
72
+
73
+ export default config;
74
+ ```
75
+
76
+ ## Configuration Options
77
+
78
+ ### Input Configuration
79
+
80
+ #### `schemaUrl`
81
+
82
+ URL to the OpenAPI schema endpoint.
83
+
84
+ ```typescript
85
+ schemaUrl: "http://localhost:8000/openapi.json";
86
+ ```
87
+
88
+ Common framework endpoints:
89
+
90
+ - FastAPI (default): `http://localhost:8000/openapi.json`
91
+ - ASP.NET Core (.NET): `https://localhost:5001/swagger/v1/swagger.json`
92
+
93
+ Examples to fetch a local snapshot:
94
+
95
+ ```bash
96
+ # FastAPI
97
+ curl -s http://localhost:8000/openapi.json -o ./openapi-schema.json
98
+
99
+ # ASP.NET Core (.NET) — dev certs
100
+ curl -k -s https://localhost:5001/swagger/v1/swagger.json -o ./openapi-schema.json
101
+
102
+ # Generate from file
103
+ npx schemantic generate --file ./openapi-schema.json --output ./src/generated --client --types
104
+ ```
105
+
106
+ #### `schemaFile`
107
+
108
+ Path to a local OpenAPI schema file.
109
+
110
+ ```typescript
111
+ schemaFile: "./schema.json";
112
+ ```
113
+
114
+ #### `schemaData`
115
+
116
+ OpenAPI schema object (for programmatic usage).
117
+
118
+ ```typescript
119
+ schemaData: {
120
+ openapi: '3.0.0',
121
+ info: { title: 'My API', version: '1.0.0' },
122
+ paths: { /* ... */ }
123
+ }
124
+ ```
125
+
126
+ ### Output Configuration
127
+
128
+ #### `outputDir`
129
+
130
+ Directory where generated files will be saved.
131
+
132
+ ```typescript
133
+ outputDir: "./src/generated";
134
+ ```
135
+
136
+ #### `outputFileName`
137
+
138
+ Custom filename for the generated API client.
139
+
140
+ ```typescript
141
+ outputFileName: "api-client.ts";
142
+ ```
143
+
144
+ ### Generation Options
145
+
146
+ #### `generateTypes`
147
+
148
+ Whether to generate TypeScript types.
149
+
150
+ ```typescript
151
+ generateTypes: true;
152
+ ```
153
+
154
+ #### `generateApiClient`
155
+
156
+ Whether to generate API client.
157
+
158
+ ```typescript
159
+ generateApiClient: true;
160
+ ```
161
+
162
+ #### `generateHooks`
163
+
164
+ Whether to generate React hooks factory.
165
+
166
+ ```typescript
167
+ generateHooks: false;
168
+ ```
169
+
170
+ When enabled, generates `hooks.ts` with a `createApiHooks(client)` function that returns query and mutation hooks for each endpoint. The hooks follow React patterns:
171
+
172
+ - Query hooks (GET methods): `useXxxQuery` with automatic fetching
173
+ - Mutation hooks (POST/PUT/PATCH/DELETE): `useXxxMutation` with manual trigger
174
+
175
+ Example usage:
176
+
177
+ ```typescript
178
+ import { ECommerceApiClient, createApiHooks } from "./generated";
179
+
180
+ const client = new ECommerceApiClient({ baseUrl: "http://localhost:8000" });
181
+ const { useGetUsersUsersGetQuery, useCreateUserUsersPostMutation } =
182
+ createApiHooks(client);
183
+
184
+ function UsersList() {
185
+ const { data, loading, error, refetch } = useGetUsersUsersGetQuery();
186
+ const { mutate: createUser } = useCreateUserUsersPostMutation();
187
+ // ... component logic
188
+ }
189
+ ```
190
+
191
+ #### `generateQueries`
192
+
193
+ Whether to generate query builders.
194
+
195
+ ```typescript
196
+ generateQueries: false;
197
+ ```
198
+
199
+ ### TypeScript Configuration
200
+
201
+ #### `useStrictTypes`
202
+
203
+ Whether to use strict TypeScript types.
204
+
205
+ ```typescript
206
+ useStrictTypes: true;
207
+ ```
208
+
209
+ #### `useOptionalChaining`
210
+
211
+ Whether to use optional chaining (`?.`).
212
+
213
+ ```typescript
214
+ useOptionalChaining: true;
215
+ ```
216
+
217
+ #### `useNullishCoalescing`
218
+
219
+ Whether to use nullish coalescing (`??`).
220
+
221
+ ```typescript
222
+ useNullishCoalescing: true;
223
+ ```
224
+
225
+ ### Naming Conventions
226
+
227
+ #### `namingConvention`
228
+
229
+ Naming convention for generated types and methods.
230
+
231
+ ```typescript
232
+ namingConvention: "camelCase"; // 'camelCase' | 'snake_case' | 'PascalCase'
233
+ ```
234
+
235
+ Examples:
236
+
237
+ - `camelCase`: `getUser`, `createUser`, `userId`
238
+ - `snake_case`: `get_user`, `create_user`, `user_id`
239
+ - `PascalCase`: `GetUser`, `CreateUser`, `UserId`
240
+
241
+ #### `typePrefix`
242
+
243
+ Prefix to add to generated type names.
244
+
245
+ ```typescript
246
+ typePrefix: "Api";
247
+ ```
248
+
249
+ Default prefix is `API`, producing names like `APIUser`, `APIProduct`. Customize if desired.
250
+
251
+ #### `typeSuffix`
252
+
253
+ Suffix to add to generated type names.
254
+
255
+ ```typescript
256
+ typeSuffix: "Type";
257
+ ```
258
+
259
+ This will generate types like `UserType`, `ProductType`, etc.
260
+
261
+ ### Customization
262
+
263
+ #### `customTypeMappings`
264
+
265
+ Custom mappings for OpenAPI schema types to TypeScript types.
266
+
267
+ ```typescript
268
+ customTypeMappings: {
269
+ 'uuid': 'string',
270
+ 'datetime': 'Date',
271
+ 'decimal': 'number',
272
+ 'email': 'string',
273
+ 'password': 'string'
274
+ }
275
+ ```
276
+
277
+ #### `excludePaths`
278
+
279
+ Paths to exclude from API client generation.
280
+
281
+ ```typescript
282
+ excludePaths: ["/health", "/docs", "/redoc"];
283
+ ```
284
+
285
+ #### `includePaths`
286
+
287
+ Paths to include in API client generation (all others will be excluded).
288
+
289
+ ```typescript
290
+ includePaths: ["/api/v1/*"];
291
+ ```
292
+
293
+ #### `excludeSchemas`
294
+
295
+ Schema names to exclude from type generation.
296
+
297
+ ```typescript
298
+ excludeSchemas: ["Error", "ValidationError", "InternalError"];
299
+ ```
300
+
301
+ #### `includeSchemas`
302
+
303
+ Schema names to include in type generation (all others will be excluded).
304
+
305
+ ```typescript
306
+ includeSchemas: ["User", "Product", "Order"];
307
+ ```
308
+
309
+ ### Plugin Configuration
310
+
311
+ #### `plugins`
312
+
313
+ Array of plugin configurations.
314
+
315
+ ```typescript
316
+ plugins: [
317
+ { name: "jsdoc", enabled: true },
318
+ { name: "validation", enabled: true },
319
+ { name: "react-hooks", enabled: false },
320
+ { name: "custom-plugin", enabled: true, options: { debug: true } },
321
+ ];
322
+ ```
323
+
324
+ Plugin configuration options:
325
+
326
+ - `name`: Plugin name (required)
327
+ - `enabled`: Whether the plugin is enabled (required)
328
+ - `options`: Plugin-specific options (optional)
329
+
330
+ ### Advanced Options
331
+
332
+ #### `preserveComments`
333
+
334
+ Whether to preserve comments from the OpenAPI schema.
335
+
336
+ ```typescript
337
+ preserveComments: true;
338
+ ```
339
+
340
+ #### `generateIndexFile`
341
+
342
+ Whether to generate an index file that exports all generated types.
343
+
344
+ ```typescript
345
+ generateIndexFile: true;
346
+ ```
347
+
348
+ #### `generateBarrelExports`
349
+
350
+ Whether to generate barrel export files.
351
+
352
+ ```typescript
353
+ generateBarrelExports: true;
354
+ ```
355
+
356
+ ## Environment Variables
357
+
358
+ You can use environment variables for configuration:
359
+
360
+ ```bash
361
+ export TYPE_SYNC_SCHEMA_URL="http://localhost:8000/openapi.json"
362
+ export TYPE_SYNC_OUTPUT_DIR="./generated"
363
+ export TYPE_SYNC_NAMING_CONVENTION="camelCase"
364
+ ```
365
+
366
+ Access in configuration:
367
+
368
+ ```typescript
369
+ const config: SchemanticConfig = {
370
+ schemaUrl: process.env.TYPE_SYNC_SCHEMA_URL,
371
+ outputDir: process.env.TYPE_SYNC_OUTPUT_DIR || "./generated",
372
+ namingConvention:
373
+ (process.env.TYPE_SYNC_NAMING_CONVENTION as any) || "camelCase",
374
+ };
375
+ ```
376
+
377
+ ## CLI Configuration
378
+
379
+ ### Global Options
380
+
381
+ ```bash
382
+ --verbose, -v # Verbose output
383
+ --quiet, -q # Quiet output
384
+ --no-color # Disable colored output
385
+ --config <file> # Configuration file path
386
+ ```
387
+
388
+ ### Input Options
389
+
390
+ ```bash
391
+ --url, -u <url> # OpenAPI schema URL
392
+ --file, -f <file> # OpenAPI schema file path
393
+ ```
394
+
395
+ ### Output Options
396
+
397
+ ```bash
398
+ --output, -o <dir> # Output directory
399
+ ```
400
+
401
+ ### Generation Options
402
+
403
+ ```bash
404
+ --types # Generate types only
405
+ --client # Generate API client only
406
+ --hooks # Generate React hooks factory
407
+ ```
408
+
409
+ ### TypeScript Options
410
+
411
+ ```bash
412
+ --strict # Use strict TypeScript types
413
+ --naming <convention> # Naming convention
414
+ ```
415
+
416
+ ### Customization Options
417
+
418
+ ```bash
419
+ --prefix <prefix> # Type name prefix
420
+ --suffix <suffix> # Type name suffix
421
+ --exclude-paths <paths> # Exclude paths (comma-separated)
422
+ --include-paths <paths> # Include paths (comma-separated)
423
+ --exclude-schemas <schemas> # Exclude schemas (comma-separated)
424
+ --include-schemas <schemas> # Include schemas (comma-separated)
425
+ ```
426
+
427
+ ### Plugin Options
428
+
429
+ ```bash
430
+ --plugins <plugins> # Enable plugins (comma-separated)
431
+ ```
432
+
433
+ ## Configuration Examples
434
+
435
+ ### Basic Configuration
436
+
437
+ ```typescript
438
+ const basicConfig: SchemanticConfig = {
439
+ schemaUrl: "http://localhost:8000/openapi.json",
440
+ outputDir: "./generated",
441
+ generateTypes: true,
442
+ generateApiClient: true,
443
+ };
444
+ ```
445
+
446
+ ### Advanced Configuration
447
+
448
+ ```typescript
449
+ const advancedConfig: SchemanticConfig = {
450
+ schemaUrl: "http://localhost:8000/openapi.json",
451
+ outputDir: "./src/generated",
452
+ outputFileName: "api-client.ts",
453
+
454
+ generateTypes: true,
455
+ generateApiClient: true,
456
+ generateHooks: true,
457
+
458
+ useStrictTypes: true,
459
+ useOptionalChaining: true,
460
+ useNullishCoalescing: true,
461
+
462
+ namingConvention: "camelCase",
463
+ typePrefix: "Api",
464
+ typeSuffix: "Type",
465
+
466
+ customTypeMappings: {
467
+ uuid: "string",
468
+ datetime: "Date",
469
+ decimal: "number",
470
+ },
471
+
472
+ excludePaths: ["/health", "/docs", "/redoc"],
473
+ includePaths: ["/api/v1/*"],
474
+
475
+ excludeSchemas: ["Error", "ValidationError"],
476
+ includeSchemas: ["User", "Product", "Order"],
477
+
478
+ plugins: [
479
+ { name: "jsdoc", enabled: true },
480
+ { name: "validation", enabled: true },
481
+ { name: "react-hooks", enabled: true },
482
+ ],
483
+
484
+ preserveComments: true,
485
+ generateIndexFile: true,
486
+ generateBarrelExports: true,
487
+ };
488
+ ```
489
+
490
+ ### FastAPI Specific Configuration
491
+
492
+ ```typescript
493
+ const fastApiConfig: SchemanticConfig = {
494
+ schemaUrl: "http://localhost:8000/openapi.json",
495
+ outputDir: "./generated",
496
+
497
+ generateTypes: true,
498
+ generateApiClient: true,
499
+
500
+ useStrictTypes: true,
501
+ namingConvention: "camelCase",
502
+
503
+ customTypeMappings: {
504
+ uuid: "string",
505
+ datetime: "string",
506
+ date: "string",
507
+ time: "string",
508
+ email: "string",
509
+ url: "string",
510
+ password: "string",
511
+ },
512
+
513
+ excludePaths: ["/docs", "/redoc", "/openapi.json"],
514
+
515
+ plugins: [
516
+ { name: "jsdoc", enabled: true },
517
+ { name: "validation", enabled: true },
518
+ ],
519
+ };
520
+ ```
521
+
522
+ ### React Application Configuration
523
+
524
+ ```typescript
525
+ const reactConfig: SchemanticConfig = {
526
+ schemaUrl: "http://localhost:8000/openapi.json",
527
+ outputDir: "./src/api",
528
+
529
+ generateTypes: true,
530
+ generateApiClient: true,
531
+ generateHooks: true,
532
+
533
+ useStrictTypes: true,
534
+ namingConvention: "camelCase",
535
+
536
+ plugins: [
537
+ { name: "jsdoc", enabled: true },
538
+ { name: "react-hooks", enabled: true },
539
+ { name: "validation", enabled: true },
540
+ ],
541
+
542
+ generateIndexFile: true,
543
+ };
544
+ ```
545
+
546
+ ### Node.js Application Configuration
547
+
548
+ ```typescript
549
+ const nodeConfig: SchemanticConfig = {
550
+ schemaUrl: "http://localhost:8000/openapi.json",
551
+ outputDir: "./lib/api",
552
+
553
+ generateTypes: true,
554
+ generateApiClient: true,
555
+
556
+ useStrictTypes: true,
557
+ namingConvention: "camelCase",
558
+
559
+ plugins: [
560
+ { name: "jsdoc", enabled: true },
561
+ { name: "validation", enabled: true },
562
+ ],
563
+
564
+ generateIndexFile: true,
565
+ };
566
+ ```
567
+
568
+ ## Configuration Validation
569
+
570
+ Schemantic validates your configuration and will throw errors for:
571
+
572
+ - Missing required fields
573
+ - Invalid values
574
+ - Conflicting options
575
+ - Plugin configuration errors
576
+
577
+ Example validation errors:
578
+
579
+ ```typescript
580
+ // Error: Missing required field
581
+ const invalidConfig = {
582
+ // Missing outputDir
583
+ schemaUrl: "http://localhost:8000/openapi.json",
584
+ };
585
+
586
+ // Error: Invalid naming convention
587
+ const invalidNamingConfig = {
588
+ schemaUrl: "http://localhost:8000/openapi.json",
589
+ outputDir: "./generated",
590
+ namingConvention: "invalid", // Must be 'camelCase', 'snake_case', or 'PascalCase'
591
+ };
592
+
593
+ // Error: Conflicting options
594
+ const conflictingConfig = {
595
+ schemaUrl: "http://localhost:8000/openapi.json",
596
+ outputDir: "./generated",
597
+ excludePaths: ["/api/*"],
598
+ includePaths: ["/api/v1/*"], // This conflicts with excludePaths
599
+ };
600
+ ```
601
+
602
+ ## Configuration Inheritance
603
+
604
+ You can extend configurations:
605
+
606
+ ```typescript
607
+ const baseConfig: SchemanticConfig = {
608
+ schemaUrl: "http://localhost:8000/openapi.json",
609
+ outputDir: "./generated",
610
+ generateTypes: true,
611
+ generateApiClient: true,
612
+ useStrictTypes: true,
613
+ namingConvention: "camelCase",
614
+ };
615
+
616
+ const developmentConfig: SchemanticConfig = {
617
+ ...baseConfig,
618
+ plugins: [
619
+ { name: "jsdoc", enabled: true },
620
+ { name: "validation", enabled: true },
621
+ ],
622
+ };
623
+
624
+ const productionConfig: SchemanticConfig = {
625
+ ...baseConfig,
626
+ outputDir: "./dist/api",
627
+ plugins: [{ name: "jsdoc", enabled: true }],
628
+ };
629
+ ```
630
+
631
+ ## Configuration Tips
632
+
633
+ ### 1. Use Configuration Files
634
+
635
+ For complex configurations, use configuration files instead of CLI arguments:
636
+
637
+ ```bash
638
+ # Instead of long CLI command
639
+ npx schemantic generate --url http://localhost:8000/openapi.json --output ./generated --naming camelCase --plugins jsdoc,validation
640
+
641
+ # Use configuration file
642
+ npx schemantic generate --config schemantic.config.json
643
+ ```
644
+
645
+ ### 2. Environment-Specific Configurations
646
+
647
+ Create different configurations for different environments:
648
+
649
+ ```typescript
650
+ // config/development.ts
651
+ export const developmentConfig: SchemanticConfig = {
652
+ schemaUrl: "http://localhost:8000/openapi.json",
653
+ outputDir: "./src/generated",
654
+ plugins: [
655
+ { name: "jsdoc", enabled: true },
656
+ { name: "validation", enabled: true },
657
+ ],
658
+ };
659
+
660
+ // config/production.ts
661
+ export const productionConfig: SchemanticConfig = {
662
+ schemaUrl: "https://api.example.com/openapi.json",
663
+ outputDir: "./dist/api",
664
+ plugins: [{ name: "jsdoc", enabled: true }],
665
+ };
666
+ ```
667
+
668
+ ### 3. Plugin Configuration
669
+
670
+ Configure plugins with options:
671
+
672
+ ```typescript
673
+ plugins: [
674
+ {
675
+ name: "validation",
676
+ enabled: true,
677
+ options: {
678
+ strict: true,
679
+ addImports: true,
680
+ },
681
+ },
682
+ {
683
+ name: "react-hooks",
684
+ enabled: true,
685
+ options: {
686
+ useReactQuery: true,
687
+ generateMutations: true,
688
+ },
689
+ },
690
+ ];
691
+ ```
692
+
693
+ ### 4. Path Filtering
694
+
695
+ Use path filtering to control what gets generated:
696
+
697
+ ```typescript
698
+ // Only generate API v1 endpoints
699
+ includePaths: ['/api/v1/*'],
700
+
701
+ // Exclude documentation endpoints
702
+ excludePaths: ['/docs', '/redoc', '/openapi.json'],
703
+
704
+ // Only generate specific schemas
705
+ includeSchemas: ['User', 'Product', 'Order'],
706
+ ```
707
+
708
+ ### 5. Custom Type Mappings
709
+
710
+ Map OpenAPI types to your preferred TypeScript types:
711
+
712
+ ```typescript
713
+ customTypeMappings: {
714
+ 'uuid': 'string', // UUID to string
715
+ 'datetime': 'Date', // DateTime to Date
716
+ 'decimal': 'number', // Decimal to number
717
+ 'email': 'string', // Email to string
718
+ 'password': 'string', // Password to string
719
+ 'binary': 'Buffer', // Binary to Buffer
720
+ 'byte': 'string', // Byte to string (base64)
721
+ };
722
+ ```