ts-openapi-codegen 2.0.0-beta.10 → 2.0.0-beta.11

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 (74) hide show
  1. package/README.md +2 -0
  2. package/README.rus.md +2 -2
  3. package/dist/cli/index.js +2 -0
  4. package/dist/common/Consts.d.ts.map +1 -1
  5. package/dist/common/Consts.js +3 -1
  6. package/dist/common/VersionedSchema/AllVersionedSchemas/AllMigrationPlans.d.ts.map +1 -1
  7. package/dist/common/VersionedSchema/AllVersionedSchemas/AllMigrationPlans.js +10 -0
  8. package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV1.d.ts +2 -2
  9. package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV2.d.ts +2 -2
  10. package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV3.d.ts +2 -2
  11. package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV4.d.ts +42 -0
  12. package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV4.d.ts.map +1 -0
  13. package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV4.js +41 -0
  14. package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedVersionedSchemas.d.ts +6 -4
  15. package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedVersionedSchemas.d.ts.map +1 -1
  16. package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedVersionedSchemas.js +7 -1
  17. package/dist/common/VersionedSchema/CommonSchemas.d.ts +12 -4
  18. package/dist/common/VersionedSchema/CommonSchemas.d.ts.map +1 -1
  19. package/dist/common/VersionedSchema/CommonSchemas.js +15 -7
  20. package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV1.d.ts +2 -2
  21. package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV4.d.ts +2 -2
  22. package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV5.d.ts +2 -2
  23. package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV1.d.ts +2 -2
  24. package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV4.d.ts +2 -2
  25. package/dist/common/VersionedSchema/Utils/__mocks__/compatibilityCases.d.ts.map +1 -1
  26. package/dist/common/VersionedSchema/Utils/__mocks__/compatibilityCases.js +6 -0
  27. package/dist/common/VersionedSchema/Utils/__tests__/migrateDataToLatestSchemaVersion.test.js +1 -1
  28. package/dist/common/defaultOptions.d.ts.map +1 -1
  29. package/dist/common/defaultOptions.js +2 -0
  30. package/dist/common/utils/__tests__/convertArrayToObject.test.js +10 -5
  31. package/dist/common/utils/convertArrayToObject.d.ts.map +1 -1
  32. package/dist/common/utils/convertArrayToObject.js +1 -0
  33. package/dist/core/OpenApiClient.d.ts.map +1 -1
  34. package/dist/core/OpenApiClient.js +7 -1
  35. package/dist/core/WriteClient.d.ts +7 -1
  36. package/dist/core/WriteClient.d.ts.map +1 -1
  37. package/dist/core/WriteClient.js +44 -7
  38. package/dist/core/__tests__/WriteClient.test.js +2 -0
  39. package/dist/core/types/enums/EmptySchemaStrategy.enum.d.ts +6 -0
  40. package/dist/core/types/enums/EmptySchemaStrategy.enum.d.ts.map +1 -0
  41. package/dist/core/types/enums/EmptySchemaStrategy.enum.js +9 -0
  42. package/dist/core/utils/__tests__/writeClientSchemas.test.js +2 -0
  43. package/dist/core/utils/precompileTemplates.js +1 -0
  44. package/dist/core/utils/registerHandlebarHelpers.d.ts.map +1 -1
  45. package/dist/core/utils/registerHandlebarHelpers.js +25 -0
  46. package/dist/core/utils/writeClientSchemas.d.ts +4 -1
  47. package/dist/core/utils/writeClientSchemas.d.ts.map +1 -1
  48. package/dist/core/utils/writeClientSchemas.js +11 -2
  49. package/dist/templatesCompiled/client/joi/exportSchema.js +2 -2
  50. package/dist/templatesCompiled/client/joi/partials/joiSchemaInterface.d.ts +5 -3
  51. package/dist/templatesCompiled/client/joi/partials/joiSchemaInterface.d.ts.map +1 -1
  52. package/dist/templatesCompiled/client/joi/partials/joiSchemaInterface.js +36 -9
  53. package/dist/templatesCompiled/client/jsonschema/exportSchema.js +2 -2
  54. package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchemaInterface.d.ts +3 -1
  55. package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchemaInterface.d.ts.map +1 -1
  56. package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchemaInterface.js +43 -13
  57. package/dist/templatesCompiled/client/yup/exportSchema.js +2 -2
  58. package/dist/templatesCompiled/client/yup/partials/yupSchemaInterface.d.ts +5 -3
  59. package/dist/templatesCompiled/client/yup/partials/yupSchemaInterface.d.ts.map +1 -1
  60. package/dist/templatesCompiled/client/yup/partials/yupSchemaInterface.js +36 -9
  61. package/dist/templatesCompiled/client/zod/exportSchema.js +2 -2
  62. package/dist/templatesCompiled/client/zod/partials/zodSchemaArray.d.ts +5 -6
  63. package/dist/templatesCompiled/client/zod/partials/zodSchemaArray.d.ts.map +1 -1
  64. package/dist/templatesCompiled/client/zod/partials/zodSchemaArray.js +14 -28
  65. package/dist/templatesCompiled/client/zod/partials/zodSchemaComposition.d.ts +3 -0
  66. package/dist/templatesCompiled/client/zod/partials/zodSchemaComposition.d.ts.map +1 -1
  67. package/dist/templatesCompiled/client/zod/partials/zodSchemaComposition.js +28 -4
  68. package/dist/templatesCompiled/client/zod/partials/zodSchemaDictionary.d.ts +3 -4
  69. package/dist/templatesCompiled/client/zod/partials/zodSchemaDictionary.d.ts.map +1 -1
  70. package/dist/templatesCompiled/client/zod/partials/zodSchemaDictionary.js +9 -23
  71. package/dist/templatesCompiled/client/zod/partials/zodSchemaInterface.d.ts +4 -2
  72. package/dist/templatesCompiled/client/zod/partials/zodSchemaInterface.d.ts.map +1 -1
  73. package/dist/templatesCompiled/client/zod/partials/zodSchemaInterface.js +15 -4
  74. package/package.json +1 -1
@@ -9,6 +9,7 @@ const pathHelpers_1 = require("../common/utils/pathHelpers");
9
9
  const Parser_1 = require("./api/v2/Parser");
10
10
  const Parser_2 = require("./api/v3/Parser");
11
11
  const Context_1 = require("./Context");
12
+ const EmptySchemaStrategy_enum_1 = require("./types/enums/EmptySchemaStrategy.enum");
12
13
  const ValidationLibrary_enum_1 = require("./types/enums/ValidationLibrary.enum");
13
14
  const getOpenApiSpec_1 = require("./utils/getOpenApiSpec");
14
15
  const getOpenApiVersion_1 = require("./utils/getOpenApiVersion");
@@ -44,6 +45,7 @@ class OpenApiClient {
44
45
  sortByRequired: rawOptions.sortByRequired,
45
46
  useSeparatedIndexes: rawOptions.useSeparatedIndexes,
46
47
  validationLibrary: rawOptions.validationLibrary,
48
+ emptySchemaStrategy: rawOptions.emptySchemaStrategy,
47
49
  }));
48
50
  }
49
51
  else {
@@ -71,6 +73,7 @@ class OpenApiClient {
71
73
  sortByRequired: rawOptions.sortByRequired,
72
74
  useSeparatedIndexes: rawOptions.useSeparatedIndexes,
73
75
  validationLibrary: rawOptions.validationLibrary,
76
+ emptySchemaStrategy: rawOptions.emptySchemaStrategy,
74
77
  },
75
78
  ];
76
79
  }
@@ -98,6 +101,7 @@ class OpenApiClient {
98
101
  sortByRequired: item.sortByRequired ?? Consts_1.COMMON_DEFAULT_OPTIONS_VALUES.sortByRequired,
99
102
  useSeparatedIndexes: item.useSeparatedIndexes ?? Consts_1.COMMON_DEFAULT_OPTIONS_VALUES.useSeparatedIndexes,
100
103
  validationLibrary: item.validationLibrary ?? Consts_1.COMMON_DEFAULT_OPTIONS_VALUES.validationLibrary,
104
+ emptySchemaStrategy: item.emptySchemaStrategy ?? Consts_1.COMMON_DEFAULT_OPTIONS_VALUES.emptySchemaStrategy,
101
105
  };
102
106
  }
103
107
  async cleanOutputDirectories(option) {
@@ -142,7 +146,7 @@ class OpenApiClient {
142
146
  this.writeClient.logger.shutdownLogger();
143
147
  }
144
148
  async generateSingle(item) {
145
- const { input, output, outputCore, outputServices, outputModels, outputSchemas, httpClient, useOptions, useUnionTypes, excludeCoreServiceFiles, request, interfacePrefix, enumPrefix, typePrefix, useCancelableRequest, sortByRequired, useSeparatedIndexes, validationLibrary = ValidationLibrary_enum_1.ValidationLibrary.NONE, } = item;
149
+ const { input, output, outputCore, outputServices, outputModels, outputSchemas, httpClient, useOptions, useUnionTypes, excludeCoreServiceFiles, request, interfacePrefix, enumPrefix, typePrefix, useCancelableRequest, sortByRequired, useSeparatedIndexes, validationLibrary = ValidationLibrary_enum_1.ValidationLibrary.NONE, emptySchemaStrategy = EmptySchemaStrategy_enum_1.EmptySchemaStrategy.KEEP, } = item;
146
150
  const outputPaths = (0, getOutputPaths_1.getOutputPaths)({
147
151
  output,
148
152
  outputCore,
@@ -178,6 +182,7 @@ class OpenApiClient {
178
182
  useCancelableRequest,
179
183
  useSeparatedIndexes,
180
184
  validationLibrary,
185
+ emptySchemaStrategy,
181
186
  });
182
187
  break;
183
188
  }
@@ -197,6 +202,7 @@ class OpenApiClient {
197
202
  useCancelableRequest,
198
203
  useSeparatedIndexes,
199
204
  validationLibrary,
205
+ emptySchemaStrategy,
200
206
  });
201
207
  break;
202
208
  }
@@ -1,9 +1,11 @@
1
1
  import { Logger } from '../common/Logger';
2
2
  import { OutputPaths } from './types/base/OutputPaths.model';
3
3
  import { Templates } from './types/base/Templates.model';
4
+ import { EmptySchemaStrategy } from './types/enums/EmptySchemaStrategy.enum';
4
5
  import { HttpClient } from './types/enums/HttpClient.enum';
5
6
  import { ValidationLibrary } from './types/enums/ValidationLibrary.enum';
6
7
  import type { Client } from './types/shared/Client.model';
8
+ import type { Model } from './types/shared/Model.model';
7
9
  import { writeClientCore } from './utils/writeClientCore';
8
10
  import { writeClientCoreIndex } from './utils/writeClientCoreIndex';
9
11
  import { writeClientExecutor } from './utils/writeClientExecutor';
@@ -40,8 +42,11 @@ type TWriteClientProps = {
40
42
  useCancelableRequest?: boolean;
41
43
  useSeparatedIndexes?: boolean;
42
44
  validationLibrary?: ValidationLibrary;
45
+ emptySchemaStrategy: EmptySchemaStrategy;
46
+ };
47
+ type TAPIClientGeneratorConfig = Omit<TWriteClientProps, 'httpClient' | 'useOptions' | 'request' | 'useCancelableRequest' | 'useSeparatedIndexes'> & {
48
+ schemaModels: Model[];
43
49
  };
44
- type TAPIClientGeneratorConfig = Omit<TWriteClientProps, 'httpClient' | 'useOptions' | 'request' | 'useCancelableRequest' | 'useSeparatedIndexes'>;
45
50
  /**
46
51
  * The client which is writing all items and keep the parameters to write index file
47
52
  */
@@ -53,6 +58,7 @@ export declare class WriteClient {
53
58
  * Write our OpenAPI client, using the given templates at the given output
54
59
  */
55
60
  writeClient(options: TWriteClientProps): Promise<void>;
61
+ private writeModelsAndFinalize;
56
62
  /**
57
63
  * Method keeps all options that is need to create index file
58
64
  * @param config
@@ -1 +1 @@
1
- {"version":3,"file":"WriteClient.d.ts","sourceRoot":"","sources":["../../src/core/WriteClient.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAM1C,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAE7D,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAC;AACzE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAI1D,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AACxE,OAAO,EAAE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O,CAAC,yBAAyB;IAyCjC,OAAO,CAAC,mBAAmB;YA4Db,gBAAgB;YAUhB,uBAAuB;IAMrC,OAAO,CAAC,aAAa;IAIrB,OAAO,CAAC,iBAAiB;IAezB,OAAO,CAAC,uBAAuB;IAe/B,OAAO,CAAC,WAAW;IAInB,OAAO,CAAC,WAAW;IAInB,OAAO,CAAC,aAAa;IAId,eAAe,yBAAmB;IAClC,oBAAoB,8BAAwB;IAC5C,oBAAoB,8BAAwB;IAC5C,iBAAiB,2BAAqB;IACtC,sBAAsB,gCAA0B;IAChD,kBAAkB,4BAAsB;IACxC,uBAAuB,iCAA2B;IAClD,mBAAmB,6BAAuB;IAC1C,wBAAwB,kCAA4B;IACpD,sBAAsB,gCAA0B;IAChD,mBAAmB,6BAAuB;CACpD"}
@@ -39,7 +39,7 @@ class WriteClient {
39
39
  * Write our OpenAPI client, using the given templates at the given output
40
40
  */
41
41
  async writeClient(options) {
42
- const { client, templates, outputPaths, httpClient, useOptions, useUnionTypes, excludeCoreServiceFiles = false, request, useCancelableRequest = false, useSeparatedIndexes = false, validationLibrary = ValidationLibrary_enum_1.ValidationLibrary.NONE, } = options;
42
+ const { client, templates, outputPaths, httpClient, useOptions, useUnionTypes, excludeCoreServiceFiles = false, request, useCancelableRequest = false, useSeparatedIndexes = false, validationLibrary = ValidationLibrary_enum_1.ValidationLibrary.NONE, emptySchemaStrategy, } = options;
43
43
  if (!excludeCoreServiceFiles) {
44
44
  const executorPath = (0, pathHelpers_1.resolveHelper)(outputPaths.outputCore, 'executor');
45
45
  const interceptorsPath = (0, pathHelpers_1.resolveHelper)(outputPaths.outputCore, 'interceptors');
@@ -87,21 +87,56 @@ class WriteClient {
87
87
  */
88
88
  if (validationLibrary !== ValidationLibrary_enum_1.ValidationLibrary.NONE) {
89
89
  await fileSystemHelpers_1.fileSystemHelpers.mkdir(outputPaths.outputSchemas);
90
- await this.writeClientSchemas({
90
+ const schemaModels = await this.writeClientSchemas({
91
91
  models: client.models,
92
92
  templates,
93
93
  outputSchemasPath: outputPaths.outputSchemas,
94
94
  httpClient,
95
95
  useUnionTypes,
96
96
  validationLibrary,
97
+ emptySchemaStrategy,
97
98
  });
98
99
  await this.writeClientSchemasIndex({
99
- models: client.models,
100
+ models: schemaModels,
100
101
  templates,
101
102
  outputSchemasPath: outputPaths.outputSchemas,
102
103
  useSeparatedIndexes,
103
104
  });
105
+ await this.writeModelsAndFinalize({
106
+ client,
107
+ templates,
108
+ outputPaths,
109
+ httpClient,
110
+ useOptions,
111
+ useUnionTypes,
112
+ excludeCoreServiceFiles,
113
+ request,
114
+ useCancelableRequest,
115
+ useSeparatedIndexes,
116
+ validationLibrary,
117
+ emptySchemaStrategy,
118
+ schemaModels,
119
+ });
120
+ return;
104
121
  }
122
+ await this.writeModelsAndFinalize({
123
+ client,
124
+ templates,
125
+ outputPaths,
126
+ httpClient,
127
+ useOptions,
128
+ useUnionTypes,
129
+ excludeCoreServiceFiles,
130
+ request,
131
+ useCancelableRequest,
132
+ useSeparatedIndexes,
133
+ validationLibrary,
134
+ emptySchemaStrategy,
135
+ schemaModels: [],
136
+ });
137
+ }
138
+ async writeModelsAndFinalize(config) {
139
+ const { client, templates, outputPaths, httpClient, useUnionTypes, useSeparatedIndexes, excludeCoreServiceFiles, validationLibrary, emptySchemaStrategy, schemaModels } = config;
105
140
  await fileSystemHelpers_1.fileSystemHelpers.mkdir(outputPaths.outputModels);
106
141
  await this.writeClientModels({
107
142
  models: client.models,
@@ -124,6 +159,8 @@ class WriteClient {
124
159
  useUnionTypes,
125
160
  excludeCoreServiceFiles,
126
161
  validationLibrary,
162
+ emptySchemaStrategy,
163
+ schemaModels,
127
164
  });
128
165
  }
129
166
  /**
@@ -155,7 +192,7 @@ class WriteClient {
155
192
  const result = new Map();
156
193
  for (const [key, value] of this.config.entries()) {
157
194
  for (const item of value) {
158
- const { outputPaths, templates, excludeCoreServiceFiles, validationLibrary } = item;
195
+ const { outputPaths, templates, excludeCoreServiceFiles, validationLibrary, schemaModels } = item;
159
196
  const outputCore = this.getOutputPath(outputPaths?.outputCore, key, 'core');
160
197
  const outputModels = this.getOutputPath(outputPaths?.outputModels, key, 'models');
161
198
  const outputSchemas = this.getOutputPath(outputPaths?.outputSchemas, key, 'schemas');
@@ -175,7 +212,7 @@ class WriteClient {
175
212
  if (!clientIndex.models.includes(relativePathModel)) {
176
213
  clientIndex.models.push(relativePathModel);
177
214
  }
178
- if (validationLibrary !== ValidationLibrary_enum_1.ValidationLibrary.NONE) {
215
+ if (validationLibrary !== ValidationLibrary_enum_1.ValidationLibrary.NONE && schemaModels.length > 0) {
179
216
  const relativePathSchema = (0, pathHelpers_1.relativeHelper)(key, outputSchemas);
180
217
  if (!clientIndex.schemas.includes(relativePathSchema)) {
181
218
  clientIndex.schemas.push(relativePathSchema);
@@ -189,7 +226,7 @@ class WriteClient {
189
226
  const result = new Map();
190
227
  for (const [key, value] of this.config.entries()) {
191
228
  for (const item of value) {
192
- const { outputPaths, client, templates, useUnionTypes, excludeCoreServiceFiles, validationLibrary } = item;
229
+ const { outputPaths, client, templates, useUnionTypes, excludeCoreServiceFiles, validationLibrary, schemaModels } = item;
193
230
  const outputCore = this.getOutputPath(outputPaths?.outputCore, key, 'core');
194
231
  const outputModels = this.getOutputPath(outputPaths?.outputModels, key, 'models');
195
232
  const outputSchemas = this.getOutputPath(outputPaths?.outputSchemas, key, 'schemas');
@@ -225,7 +262,7 @@ class WriteClient {
225
262
  if (!clientIndex.models.some(m => this.isSameModel(m, modelFinal))) {
226
263
  clientIndex.models.push(modelFinal);
227
264
  }
228
- if (validationLibrary !== ValidationLibrary_enum_1.ValidationLibrary.NONE) {
265
+ if (validationLibrary !== ValidationLibrary_enum_1.ValidationLibrary.NONE && schemaModels.some(schemaModel => schemaModel.name === model.name && schemaModel.path === model.path)) {
229
266
  const schema = { ...modelFinal, package: relativePathSchema };
230
267
  if (!clientIndex.schemas.some(s => this.isSameShema(s, schema))) {
231
268
  clientIndex.schemas.push(schema);
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const strict_1 = __importDefault(require("node:assert/strict"));
7
7
  const node_test_1 = require("node:test");
8
8
  const fileSystemHelpers_1 = require("../../common/utils/fileSystemHelpers");
9
+ const EmptySchemaStrategy_enum_1 = require("../types/enums/EmptySchemaStrategy.enum");
9
10
  const HttpClient_enum_1 = require("../types/enums/HttpClient.enum");
10
11
  const ValidationLibrary_enum_1 = require("../types/enums/ValidationLibrary.enum");
11
12
  const getOutputPaths_1 = require("../utils/getOutputPaths");
@@ -70,6 +71,7 @@ const WriteClient_1 = require("../WriteClient");
70
71
  useUnionTypes: false,
71
72
  excludeCoreServiceFiles: false,
72
73
  validationLibrary: ValidationLibrary_enum_1.ValidationLibrary.NONE,
74
+ emptySchemaStrategy: EmptySchemaStrategy_enum_1.EmptySchemaStrategy.KEEP,
73
75
  });
74
76
  strict_1.default.ok(mkdirCalls.length > 0, 'mkdir should be called at least once');
75
77
  strict_1.default.ok(writeFileCalls.length > 0, 'writeFile should be called at least once');
@@ -0,0 +1,6 @@
1
+ export declare enum EmptySchemaStrategy {
2
+ SEMANTIC = "semantic",
3
+ SKIP = "skip",
4
+ KEEP = "keep"
5
+ }
6
+ //# sourceMappingURL=EmptySchemaStrategy.enum.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EmptySchemaStrategy.enum.d.ts","sourceRoot":"","sources":["../../../../src/core/types/enums/EmptySchemaStrategy.enum.ts"],"names":[],"mappings":"AAAA,oBAAY,mBAAmB;IAC3B,QAAQ,aAAa;IACrB,IAAI,SAAS;IACb,IAAI,SAAS;CAChB"}
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EmptySchemaStrategy = void 0;
4
+ var EmptySchemaStrategy;
5
+ (function (EmptySchemaStrategy) {
6
+ EmptySchemaStrategy["SEMANTIC"] = "semantic";
7
+ EmptySchemaStrategy["SKIP"] = "skip";
8
+ EmptySchemaStrategy["KEEP"] = "keep";
9
+ })(EmptySchemaStrategy || (exports.EmptySchemaStrategy = EmptySchemaStrategy = {}));
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const node_assert_1 = __importDefault(require("node:assert"));
7
7
  const node_test_1 = require("node:test");
8
8
  const fileSystemHelpers_1 = require("../../../common/utils/fileSystemHelpers");
9
+ const EmptySchemaStrategy_enum_1 = require("../../types/enums/EmptySchemaStrategy.enum");
9
10
  const HttpClient_enum_1 = require("../../types/enums/HttpClient.enum");
10
11
  const ValidationLibrary_enum_1 = require("../../types/enums/ValidationLibrary.enum");
11
12
  const WriteClient_1 = require("../../WriteClient");
@@ -47,6 +48,7 @@ const templates_1 = require("../__mocks__/templates");
47
48
  httpClient: HttpClient_enum_1.HttpClient.FETCH,
48
49
  useUnionTypes: false,
49
50
  validationLibrary: ValidationLibrary_enum_1.ValidationLibrary.NONE,
51
+ emptySchemaStrategy: EmptySchemaStrategy_enum_1.EmptySchemaStrategy.KEEP,
50
52
  });
51
53
  node_assert_1.default.ok(writeFileCalls.some(([filePath, content]) => filePath.toString().includes('MyModelSchema.ts') && content.toString().includes('schema')), 'Expected writeFile to be called with schema content for MyModelSchema.ts');
52
54
  // Restoring the original function
@@ -66,6 +66,7 @@ const precompileTemplates = () => {
66
66
  isBasicType: true,
67
67
  yupBaseSchema: true,
68
68
  joiBaseSchema: true,
69
+ zodBaseSchema: true,
69
70
  getRequiredFields: true,
70
71
  getEnumType: true,
71
72
  camelCase: true,
@@ -1 +1 @@
1
- {"version":3,"file":"registerHandlebarHelpers.d.ts","sourceRoot":"","sources":["../../../src/core/utils/registerHandlebarHelpers.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAK5D,wBAAgB,wBAAwB,CAAC,IAAI,EAAE;IAAE,UAAU,EAAE,UAAU,CAAC;IAAC,UAAU,EAAE,OAAO,CAAC;IAAC,aAAa,EAAE,OAAO,CAAA;CAAE,GAAG,IAAI,CAqK5H"}
1
+ {"version":3,"file":"registerHandlebarHelpers.d.ts","sourceRoot":"","sources":["../../../src/core/utils/registerHandlebarHelpers.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAK5D,wBAAgB,wBAAwB,CAAC,IAAI,EAAE;IAAE,UAAU,EAAE,UAAU,CAAC;IAAC,UAAU,EAAE,OAAO,CAAC;IAAC,aAAa,EAAE,OAAO,CAAA;CAAE,GAAG,IAAI,CAgM5H"}
@@ -168,6 +168,31 @@ function registerHandlebarHelpers(root) {
168
168
  return 'Joi.any()';
169
169
  }
170
170
  });
171
+ Handlebars.registerHelper('zodBaseSchema', function (base) {
172
+ if (!base)
173
+ return 'z.any()';
174
+ const baseLower = base.toLowerCase();
175
+ switch (baseLower) {
176
+ case 'string':
177
+ return 'z.string()';
178
+ case 'number':
179
+ return 'z.number()';
180
+ case 'integer':
181
+ case 'int':
182
+ return 'z.number().int()';
183
+ case 'boolean':
184
+ return 'z.boolean()';
185
+ case 'null':
186
+ return 'z.null()';
187
+ case 'uuid':
188
+ return 'z.uuid()';
189
+ case 'file':
190
+ case 'any':
191
+ return 'z.any()';
192
+ default:
193
+ return `${base}Schema`;
194
+ }
195
+ });
171
196
  Handlebars.registerHelper('getRequiredFields', function (properties) {
172
197
  const required = properties
173
198
  .filter(prop => prop.isRequired)
@@ -1,4 +1,5 @@
1
1
  import { Templates } from '../types/base/Templates.model';
2
+ import { EmptySchemaStrategy } from '../types/enums/EmptySchemaStrategy.enum';
2
3
  import { HttpClient } from '../types/enums/HttpClient.enum';
3
4
  import { ValidationLibrary } from '../types/enums/ValidationLibrary.enum';
4
5
  import type { Model } from '../types/shared/Model.model';
@@ -17,7 +18,9 @@ interface IWriteClientSchemas {
17
18
  httpClient: HttpClient;
18
19
  useUnionTypes: boolean;
19
20
  validationLibrary?: ValidationLibrary;
21
+ emptySchemaStrategy: EmptySchemaStrategy;
20
22
  }
23
+ export declare function isEmptySchemaModel(model: Model): boolean;
21
24
  /**
22
25
  * Generate Schemas using the Handlebar template and write to disk.
23
26
  * @param models Array of Models to write
@@ -26,6 +29,6 @@ interface IWriteClientSchemas {
26
29
  * @param httpClient The selected httpClient (fetch, xhr or node)
27
30
  * @param useUnionTypes Use union types instead of enums
28
31
  */
29
- export declare function writeClientSchemas(this: WriteClient, options: IWriteClientSchemas): Promise<void>;
32
+ export declare function writeClientSchemas(this: WriteClient, options: IWriteClientSchemas): Promise<Model[]>;
30
33
  export {};
31
34
  //# sourceMappingURL=writeClientSchemas.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"writeClientSchemas.d.ts","sourceRoot":"","sources":["../../../src/core/utils/writeClientSchemas.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AAC1E,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C;;;;;;GAMG;AACH,UAAU,mBAAmB;IACzB,MAAM,EAAE,KAAK,EAAE,CAAC;IAChB,SAAS,EAAE,SAAS,CAAC;IACrB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,UAAU,EAAE,UAAU,CAAC;IACvB,aAAa,EAAE,OAAO,CAAC;IACvB,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;CACzC;AAED;;;;;;;GAOG;AACH,wBAAsB,kBAAkB,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CAiCvG"}
1
+ {"version":3,"file":"writeClientSchemas.d.ts","sourceRoot":"","sources":["../../../src/core/utils/writeClientSchemas.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,yCAAyC,CAAC;AAC9E,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AAC1E,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C;;;;;;GAMG;AACH,UAAU,mBAAmB;IACzB,MAAM,EAAE,KAAK,EAAE,CAAC;IAChB,SAAS,EAAE,SAAS,CAAC;IACrB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,UAAU,EAAE,UAAU,CAAC;IACvB,aAAa,EAAE,OAAO,CAAC;IACvB,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;IACtC,mBAAmB,EAAE,mBAAmB,CAAC;CAC5C;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAExD;AAED;;;;;;;GAOG;AACH,wBAAsB,kBAAkB,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC,CAwC1G"}
@@ -1,10 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isEmptySchemaModel = isEmptySchemaModel;
3
4
  exports.writeClientSchemas = writeClientSchemas;
4
5
  const fs_1 = require("fs");
5
6
  const fileSystemHelpers_1 = require("../../common/utils/fileSystemHelpers");
6
7
  const format_1 = require("../../common/utils/format");
7
8
  const pathHelpers_1 = require("../../common/utils/pathHelpers");
9
+ const EmptySchemaStrategy_enum_1 = require("../types/enums/EmptySchemaStrategy.enum");
10
+ function isEmptySchemaModel(model) {
11
+ return model.export === 'interface' && model.properties.length === 0;
12
+ }
8
13
  /**
9
14
  * Generate Schemas using the Handlebar template and write to disk.
10
15
  * @param models Array of Models to write
@@ -14,10 +19,11 @@ const pathHelpers_1 = require("../../common/utils/pathHelpers");
14
19
  * @param useUnionTypes Use union types instead of enums
15
20
  */
16
21
  async function writeClientSchemas(options) {
17
- const { models, templates, outputSchemasPath, httpClient, useUnionTypes, validationLibrary } = options;
22
+ const { models, templates, outputSchemasPath, httpClient, useUnionTypes, validationLibrary, emptySchemaStrategy } = options;
18
23
  if (templates.exports.schema) {
19
24
  this.logger.info('The recording of model validation schema files begins.');
20
- for (const model of models) {
25
+ const modelsToWrite = emptySchemaStrategy === EmptySchemaStrategy_enum_1.EmptySchemaStrategy.SKIP ? models.filter(model => !isEmptySchemaModel(model)) : models;
26
+ for (const model of modelsToWrite) {
21
27
  const modelFolderPath = model?.path;
22
28
  const dir = (0, pathHelpers_1.dirNameHelper)(modelFolderPath);
23
29
  if (dir) {
@@ -32,11 +38,14 @@ async function writeClientSchemas(options) {
32
38
  httpClient,
33
39
  useUnionTypes,
34
40
  validationLibrary,
41
+ emptySchemaStrategy,
35
42
  });
36
43
  const formattedValue = await (0, format_1.format)(templateResult);
37
44
  await fileSystemHelpers_1.fileSystemHelpers.writeFile(file, formattedValue);
38
45
  this.logger.info(`File recording completed: ${file}`);
39
46
  }
40
47
  this.logger.info('The recording of model validation schema files has been completed successfully');
48
+ return modelsToWrite;
41
49
  }
50
+ return [];
42
51
  }
@@ -27,7 +27,7 @@ exports.default = { "1": function (container, depth0, helpers, partials, data) {
27
27
  + ((stack1 = lookupProperty(helpers, "if").call(alias1, lookupProperty(depth0, "alias"), { "name": "if", "hash": {}, "fn": container.program(3, data, 0), "inverse": container.noop, "data": data, "loc": { "start": { "line": 5, "column": 25 }, "end": { "line": 5, "column": 66 } } })) != null ? stack1 : "")
28
28
  + " } from '"
29
29
  + ((stack1 = lookupProperty(helpers, "normalizePath").call(alias1, lookupProperty(depth0, "path"), { "name": "normalizePath", "hash": {}, "data": data, "loc": { "start": { "line": 5, "column": 75 }, "end": { "line": 5, "column": 99 } } })) != null ? stack1 : "")
30
- + "';\n";
30
+ + "Schema';\n";
31
31
  }, "3": function (container, depth0, helpers, partials, data) {
32
32
  var stack1;
33
33
  return " as "
@@ -67,5 +67,5 @@ exports.default = { "1": function (container, depth0, helpers, partials, data) {
67
67
  + ((stack1 = alias2(alias1(depth0, "name", { "start": { "line": 24, "column": 32 }, "end": { "line": 24, "column": 36 } }), depth0)) != null ? stack1 : "")
68
68
  + "Schema.validate(data);\n if (error) {\n throw error;\n }\n return value as "
69
69
  + ((stack1 = alias2(alias1(depth0, "name", { "start": { "line": 28, "column": 23 }, "end": { "line": 28, "column": 27 } }), depth0)) != null ? stack1 : "")
70
- + ";\n}";
70
+ + ";\n}\n";
71
71
  }, "usePartial": true, "useData": true };
@@ -1,12 +1,14 @@
1
1
  declare const _default: {
2
- "1": (container: any, depth0: any, helpers: any, partials: any, data: any) => any;
2
+ "1": (container: any, depth0: any, helpers: any, partials: any, data: any) => string;
3
3
  "2": (container: any, depth0: any, helpers: any, partials: any, data: any) => string;
4
4
  "3": (container: any, depth0: any, helpers: any, partials: any, data: any) => string;
5
5
  "5": (container: any, depth0: any, helpers: any, partials: any, data: any) => string;
6
6
  "7": (container: any, depth0: any, helpers: any, partials: any, data: any) => string;
7
- "9": (container: any, depth0: any, helpers: any, partials: any, data: any) => string;
7
+ "9": (container: any, depth0: any, helpers: any, partials: any, data: any) => any;
8
+ "10": (container: any, depth0: any, helpers: any, partials: any, data: any) => string;
9
+ "12": (container: any, depth0: any, helpers: any, partials: any, data: any) => string;
8
10
  compiler: (string | number)[];
9
- main: (container: any, depth0: any, helpers: any, partials: any, data: any) => string;
11
+ main: (container: any, depth0: any, helpers: any, partials: any, data: any) => any;
10
12
  usePartial: boolean;
11
13
  useData: boolean;
12
14
  };
@@ -1 +1 @@
1
- {"version":3,"file":"joiSchemaInterface.d.ts","sourceRoot":"","sources":["../../../../../src/templatesCompiled/client/joi/partials/joiSchemaInterface.ts"],"names":[],"mappings":";;;;;;;;;;;;AAMA,wBA4CmC"}
1
+ {"version":3,"file":"joiSchemaInterface.d.ts","sourceRoot":"","sources":["../../../../../src/templatesCompiled/client/joi/partials/joiSchemaInterface.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAMA,wBA0EmC"}
@@ -7,13 +7,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
7
7
  /* eslint: disable */
8
8
  // @ts-nocheck
9
9
  exports.default = { "1": function (container, depth0, helpers, partials, data) {
10
- var stack1, lookupProperty = container.lookupProperty || function (parent, propertyName) {
10
+ var stack1, alias1 = depth0 != null ? depth0 : (container.nullContext || {}), lookupProperty = container.lookupProperty || function (parent, propertyName) {
11
11
  if (Object.prototype.hasOwnProperty.call(parent, propertyName)) {
12
12
  return parent[propertyName];
13
13
  }
14
14
  return undefined;
15
15
  };
16
- return ((stack1 = lookupProperty(helpers, "each").call(depth0 != null ? depth0 : (container.nullContext || {}), lookupProperty(depth0, "properties"), { "name": "each", "hash": {}, "fn": container.program(2, data, 0), "inverse": container.noop, "data": data, "loc": { "start": { "line": 3, "column": 0 }, "end": { "line": 5, "column": 9 } } })) != null ? stack1 : "");
16
+ return "Joi.object({\n"
17
+ + ((stack1 = lookupProperty(helpers, "each").call(alias1, lookupProperty(depth0, "properties"), { "name": "each", "hash": {}, "fn": container.program(2, data, 0), "inverse": container.noop, "data": data, "loc": { "start": { "line": 3, "column": 0 }, "end": { "line": 5, "column": 9 } } })) != null ? stack1 : "")
18
+ + "})"
19
+ + ((stack1 = lookupProperty(helpers, "if").call(alias1, lookupProperty(depth0, "isNullable"), { "name": "if", "hash": {}, "fn": container.program(7, data, 0), "inverse": container.noop, "data": data, "loc": { "start": { "line": 6, "column": 2 }, "end": { "line": 6, "column": 39 } } })) != null ? stack1 : "")
20
+ + "\n";
17
21
  }, "2": function (container, depth0, helpers, partials, data) {
18
22
  var stack1, alias1 = depth0 != null ? depth0 : (container.nullContext || {}), lookupProperty = container.lookupProperty || function (parent, propertyName) {
19
23
  if (Object.prototype.hasOwnProperty.call(parent, propertyName)) {
@@ -33,18 +37,41 @@ exports.default = { "1": function (container, depth0, helpers, partials, data) {
33
37
  }, "5": function (container, depth0, helpers, partials, data) {
34
38
  return ",";
35
39
  }, "7": function (container, depth0, helpers, partials, data) {
36
- return "})\n";
37
- }, "9": function (container, depth0, helpers, partials, data) {
38
40
  return ".allow(null)";
41
+ }, "9": function (container, depth0, helpers, partials, data) {
42
+ var stack1, lookupProperty = container.lookupProperty || function (parent, propertyName) {
43
+ if (Object.prototype.hasOwnProperty.call(parent, propertyName)) {
44
+ return parent[propertyName];
45
+ }
46
+ return undefined;
47
+ };
48
+ return ((stack1 = lookupProperty(helpers, "equals").call(depth0 != null ? depth0 : (container.nullContext || {}), lookupProperty(depth0, "emptySchemaStrategy"), "semantic", { "name": "equals", "hash": {}, "fn": container.program(10, data, 0), "inverse": container.program(12, data, 0), "data": data, "loc": { "start": { "line": 8, "column": 0 }, "end": { "line": 12, "column": 11 } } })) != null ? stack1 : "");
49
+ }, "10": function (container, depth0, helpers, partials, data) {
50
+ var stack1, lookupProperty = container.lookupProperty || function (parent, propertyName) {
51
+ if (Object.prototype.hasOwnProperty.call(parent, propertyName)) {
52
+ return parent[propertyName];
53
+ }
54
+ return undefined;
55
+ };
56
+ return "Joi.object().unknown(true)"
57
+ + ((stack1 = lookupProperty(helpers, "if").call(depth0 != null ? depth0 : (container.nullContext || {}), lookupProperty(depth0, "isNullable"), { "name": "if", "hash": {}, "fn": container.program(7, data, 0), "inverse": container.noop, "data": data, "loc": { "start": { "line": 9, "column": 26 }, "end": { "line": 9, "column": 63 } } })) != null ? stack1 : "")
58
+ + "\n";
59
+ }, "12": function (container, depth0, helpers, partials, data) {
60
+ var stack1, lookupProperty = container.lookupProperty || function (parent, propertyName) {
61
+ if (Object.prototype.hasOwnProperty.call(parent, propertyName)) {
62
+ return parent[propertyName];
63
+ }
64
+ return undefined;
65
+ };
66
+ return "Joi.object({})"
67
+ + ((stack1 = lookupProperty(helpers, "if").call(depth0 != null ? depth0 : (container.nullContext || {}), lookupProperty(depth0, "isNullable"), { "name": "if", "hash": {}, "fn": container.program(7, data, 0), "inverse": container.noop, "data": data, "loc": { "start": { "line": 11, "column": 14 }, "end": { "line": 11, "column": 51 } } })) != null ? stack1 : "")
68
+ + "\n";
39
69
  }, "compiler": [8, ">= 4.3.0"], "main": function (container, depth0, helpers, partials, data) {
40
- var stack1, alias1 = depth0 != null ? depth0 : (container.nullContext || {}), lookupProperty = container.lookupProperty || function (parent, propertyName) {
70
+ var stack1, lookupProperty = container.lookupProperty || function (parent, propertyName) {
41
71
  if (Object.prototype.hasOwnProperty.call(parent, propertyName)) {
42
72
  return parent[propertyName];
43
73
  }
44
74
  return undefined;
45
75
  };
46
- return "Joi.object({\n"
47
- + ((stack1 = lookupProperty(helpers, "if").call(alias1, lookupProperty(depth0, "properties"), { "name": "if", "hash": {}, "fn": container.program(1, data, 0), "inverse": container.program(7, data, 0), "data": data, "loc": { "start": { "line": 2, "column": 0 }, "end": { "line": 8, "column": 7 } } })) != null ? stack1 : "")
48
- + "})"
49
- + ((stack1 = lookupProperty(helpers, "if").call(alias1, lookupProperty(depth0, "isNullable"), { "name": "if", "hash": {}, "fn": container.program(9, data, 0), "inverse": container.noop, "data": data, "loc": { "start": { "line": 9, "column": 2 }, "end": { "line": 9, "column": 39 } } })) != null ? stack1 : "");
76
+ return ((stack1 = lookupProperty(helpers, "if").call(depth0 != null ? depth0 : (container.nullContext || {}), lookupProperty(depth0, "properties"), { "name": "if", "hash": {}, "fn": container.program(1, data, 0), "inverse": container.program(9, data, 0), "data": data, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 13, "column": 7 } } })) != null ? stack1 : "");
50
77
  }, "usePartial": true, "useData": true };
@@ -27,7 +27,7 @@ exports.default = { "1": function (container, depth0, helpers, partials, data) {
27
27
  + ((stack1 = lookupProperty(helpers, "if").call(alias1, lookupProperty(depth0, "alias"), { "name": "if", "hash": {}, "fn": container.program(3, data, 0), "inverse": container.noop, "data": data, "loc": { "start": { "line": 5, "column": 25 }, "end": { "line": 5, "column": 66 } } })) != null ? stack1 : "")
28
28
  + " } from '"
29
29
  + ((stack1 = lookupProperty(helpers, "normalizePath").call(alias1, lookupProperty(depth0, "path"), { "name": "normalizePath", "hash": {}, "data": data, "loc": { "start": { "line": 5, "column": 75 }, "end": { "line": 5, "column": 99 } } })) != null ? stack1 : "")
30
- + "';\n";
30
+ + "Schema';\n";
31
31
  }, "3": function (container, depth0, helpers, partials, data) {
32
32
  var stack1;
33
33
  return " as "
@@ -65,5 +65,5 @@ exports.default = { "1": function (container, depth0, helpers, partials, data) {
65
65
  + ((stack1 = alias2(alias1(depth0, "name", { "start": { "line": 29, "column": 36 }, "end": { "line": 29, "column": 40 } }), depth0)) != null ? stack1 : "")
66
66
  + "Schema);\n const valid = validate(data);\n if (!valid) {\n throw new Error(ajv.errorsText(validate.errors));\n }\n return data as "
67
67
  + ((stack1 = alias2(alias1(depth0, "name", { "start": { "line": 34, "column": 22 }, "end": { "line": 34, "column": 26 } }), depth0)) != null ? stack1 : "")
68
- + ";\n}";
68
+ + ";\n}\n";
69
69
  }, "usePartial": true, "useData": true };
@@ -5,7 +5,9 @@ declare const _default: {
5
5
  "5": (container: any, depth0: any, helpers: any, partials: any, data: any) => string;
6
6
  "7": (container: any, depth0: any, helpers: any, partials: any, data: any) => string;
7
7
  "9": (container: any, depth0: any, helpers: any, partials: any, data: any) => string;
8
- "11": (container: any, depth0: any, helpers: any, partials: any, data: any) => string;
8
+ "11": (container: any, depth0: any, helpers: any, partials: any, data: any) => any;
9
+ "12": (container: any, depth0: any, helpers: any, partials: any, data: any) => string;
10
+ "14": (container: any, depth0: any, helpers: any, partials: any, data: any) => string;
9
11
  compiler: (string | number)[];
10
12
  main: (container: any, depth0: any, helpers: any, partials: any, data: any) => string;
11
13
  usePartial: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"jsonschemaSchemaInterface.d.ts","sourceRoot":"","sources":["../../../../../src/templatesCompiled/client/jsonschema/partials/jsonschemaSchemaInterface.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAMA,wBA2DmC"}
1
+ {"version":3,"file":"jsonschemaSchemaInterface.d.ts","sourceRoot":"","sources":["../../../../../src/templatesCompiled/client/jsonschema/partials/jsonschemaSchemaInterface.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAMA,wBA4FmC"}