ts-openapi-codegen 2.0.0-beta.1 → 2.0.0-beta.2

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 (162) hide show
  1. package/README.md +71 -55
  2. package/README.rus.md +71 -54
  3. package/dist/cli/index.js +2 -1
  4. package/dist/common/Consts.d.ts.map +1 -1
  5. package/dist/common/Consts.js +2 -1
  6. package/dist/common/TRawOptions.d.ts +2 -1
  7. package/dist/common/TRawOptions.d.ts.map +1 -1
  8. package/dist/common/VersionedSchema/AllVersionedSchemas/AllMigrationPlans.d.ts.map +1 -1
  9. package/dist/common/VersionedSchema/AllVersionedSchemas/AllMigrationPlans.js +8 -0
  10. package/dist/common/VersionedSchema/AllVersionedSchemas/AllVersionedSchemas.d.ts.map +1 -1
  11. package/dist/common/VersionedSchema/AllVersionedSchemas/AllVersionedSchemas.js +7 -1
  12. package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV1.d.ts.map +1 -0
  13. package/dist/common/VersionedSchema/{UnifiedOptionsVersioned → AllVersionedSchemas}/UnifiedOptionsSchemaV1.js +2 -2
  14. package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV2.d.ts +7 -0
  15. package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV2.d.ts.map +1 -0
  16. package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV2.js +42 -0
  17. package/dist/common/VersionedSchema/CommonSchemas.d.ts +1 -0
  18. package/dist/common/VersionedSchema/CommonSchemas.d.ts.map +1 -1
  19. package/dist/common/VersionedSchema/CommonSchemas.js +8 -1
  20. package/dist/common/defaultOptions.d.ts.map +1 -1
  21. package/dist/common/defaultOptions.js +2 -1
  22. package/dist/common/utils/__tests__/convertArrayToObject.test.js +5 -6
  23. package/dist/common/utils/convertArrayToObject.d.ts.map +1 -1
  24. package/dist/common/utils/convertArrayToObject.js +1 -2
  25. package/dist/core/OpenApiClient.d.ts.map +1 -1
  26. package/dist/core/OpenApiClient.js +6 -4
  27. package/dist/core/WriteClient.d.ts +3 -12
  28. package/dist/core/WriteClient.d.ts.map +1 -1
  29. package/dist/core/WriteClient.js +20 -22
  30. package/dist/core/__tests__/WriteClient.test.js +6 -1
  31. package/dist/core/types/enums/ValidationLibrary.enum.d.ts +8 -0
  32. package/dist/core/types/enums/ValidationLibrary.enum.d.ts.map +1 -0
  33. package/dist/core/types/enums/ValidationLibrary.enum.js +11 -0
  34. package/dist/core/utils/__mocks__/templates.d.ts.map +1 -1
  35. package/dist/core/utils/__mocks__/templates.js +4 -0
  36. package/dist/core/utils/__tests__/writeClientSchemas.test.js +2 -0
  37. package/dist/core/utils/precompileTemplates.js +6 -0
  38. package/dist/core/utils/registerHandlebarHelpers.d.ts.map +1 -1
  39. package/dist/core/utils/registerHandlebarHelpers.js +74 -0
  40. package/dist/core/utils/registerHandlebarTemplates.d.ts +6 -0
  41. package/dist/core/utils/registerHandlebarTemplates.d.ts.map +1 -1
  42. package/dist/core/utils/registerHandlebarTemplates.js +84 -0
  43. package/dist/core/utils/writeClientSchemas.d.ts +2 -0
  44. package/dist/core/utils/writeClientSchemas.d.ts.map +1 -1
  45. package/dist/core/utils/writeClientSchemas.js +14 -2
  46. package/dist/templatesCompiled/client/joi/exportSchema.d.ts +11 -0
  47. package/dist/templatesCompiled/client/joi/exportSchema.d.ts.map +1 -0
  48. package/dist/templatesCompiled/client/joi/exportSchema.js +71 -0
  49. package/dist/templatesCompiled/client/joi/partials/joiSchema.d.ts +22 -0
  50. package/dist/templatesCompiled/client/joi/partials/joiSchema.d.ts.map +1 -0
  51. package/dist/templatesCompiled/client/joi/partials/joiSchema.js +129 -0
  52. package/dist/templatesCompiled/client/joi/partials/joiSchemaArray.d.ts +16 -0
  53. package/dist/templatesCompiled/client/joi/partials/joiSchemaArray.d.ts.map +1 -0
  54. package/dist/templatesCompiled/client/joi/partials/joiSchemaArray.js +84 -0
  55. package/dist/templatesCompiled/client/joi/partials/joiSchemaComposition.d.ts +18 -0
  56. package/dist/templatesCompiled/client/joi/partials/joiSchemaComposition.d.ts.map +1 -0
  57. package/dist/templatesCompiled/client/joi/partials/joiSchemaComposition.js +96 -0
  58. package/dist/templatesCompiled/client/joi/partials/joiSchemaDictionary.d.ts +14 -0
  59. package/dist/templatesCompiled/client/joi/partials/joiSchemaDictionary.d.ts.map +1 -0
  60. package/dist/templatesCompiled/client/joi/partials/joiSchemaDictionary.js +72 -0
  61. package/dist/templatesCompiled/client/joi/partials/joiSchemaEnum.d.ts +14 -0
  62. package/dist/templatesCompiled/client/joi/partials/joiSchemaEnum.d.ts.map +1 -0
  63. package/dist/templatesCompiled/client/joi/partials/joiSchemaEnum.js +74 -0
  64. package/dist/templatesCompiled/client/joi/partials/joiSchemaGeneric.d.ts +35 -0
  65. package/dist/templatesCompiled/client/joi/partials/joiSchemaGeneric.d.ts.map +1 -0
  66. package/dist/templatesCompiled/client/joi/partials/joiSchemaGeneric.js +201 -0
  67. package/dist/templatesCompiled/client/joi/partials/joiSchemaInterface.d.ts +14 -0
  68. package/dist/templatesCompiled/client/joi/partials/joiSchemaInterface.d.ts.map +1 -0
  69. package/dist/templatesCompiled/client/joi/partials/joiSchemaInterface.js +50 -0
  70. package/dist/templatesCompiled/client/joi/partials/joiSchemaReference.d.ts +9 -0
  71. package/dist/templatesCompiled/client/joi/partials/joiSchemaReference.d.ts.map +1 -0
  72. package/dist/templatesCompiled/client/joi/partials/joiSchemaReference.js +25 -0
  73. package/dist/templatesCompiled/client/jsonschema/exportSchema.d.ts +11 -0
  74. package/dist/templatesCompiled/client/jsonschema/exportSchema.d.ts.map +1 -0
  75. package/dist/templatesCompiled/client/jsonschema/exportSchema.js +69 -0
  76. package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchema.d.ts +22 -0
  77. package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchema.d.ts.map +1 -0
  78. package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchema.js +129 -0
  79. package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchemaArray.d.ts +16 -0
  80. package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchemaArray.d.ts.map +1 -0
  81. package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchemaArray.js +74 -0
  82. package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchemaComposition.d.ts +16 -0
  83. package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchemaComposition.d.ts.map +1 -0
  84. package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchemaComposition.js +84 -0
  85. package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchemaDictionary.d.ts +13 -0
  86. package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchemaDictionary.d.ts.map +1 -0
  87. package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchemaDictionary.js +56 -0
  88. package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchemaEnum.d.ts +12 -0
  89. package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchemaEnum.d.ts.map +1 -0
  90. package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchemaEnum.js +49 -0
  91. package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchemaGeneric.d.ts +29 -0
  92. package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchemaGeneric.d.ts.map +1 -0
  93. package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchemaGeneric.js +175 -0
  94. package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchemaInterface.d.ts +15 -0
  95. package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchemaInterface.d.ts.map +1 -0
  96. package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchemaInterface.js +63 -0
  97. package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchemaReference.d.ts +9 -0
  98. package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchemaReference.d.ts.map +1 -0
  99. package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchemaReference.js +25 -0
  100. package/dist/templatesCompiled/client/yup/exportSchema.d.ts +11 -0
  101. package/dist/templatesCompiled/client/yup/exportSchema.d.ts.map +1 -0
  102. package/dist/templatesCompiled/client/yup/exportSchema.js +73 -0
  103. package/dist/templatesCompiled/client/yup/partials/yupSchema.d.ts +22 -0
  104. package/dist/templatesCompiled/client/yup/partials/yupSchema.d.ts.map +1 -0
  105. package/dist/templatesCompiled/client/yup/partials/yupSchema.js +129 -0
  106. package/dist/templatesCompiled/client/yup/partials/yupSchemaArray.d.ts +16 -0
  107. package/dist/templatesCompiled/client/yup/partials/yupSchemaArray.d.ts.map +1 -0
  108. package/dist/templatesCompiled/client/yup/partials/yupSchemaArray.js +84 -0
  109. package/dist/templatesCompiled/client/yup/partials/yupSchemaComposition.d.ts +18 -0
  110. package/dist/templatesCompiled/client/yup/partials/yupSchemaComposition.d.ts.map +1 -0
  111. package/dist/templatesCompiled/client/yup/partials/yupSchemaComposition.js +96 -0
  112. package/dist/templatesCompiled/client/yup/partials/yupSchemaDictionary.d.ts +14 -0
  113. package/dist/templatesCompiled/client/yup/partials/yupSchemaDictionary.d.ts.map +1 -0
  114. package/dist/templatesCompiled/client/yup/partials/yupSchemaDictionary.js +72 -0
  115. package/dist/templatesCompiled/client/yup/partials/yupSchemaEnum.d.ts +14 -0
  116. package/dist/templatesCompiled/client/yup/partials/yupSchemaEnum.d.ts.map +1 -0
  117. package/dist/templatesCompiled/client/yup/partials/yupSchemaEnum.js +74 -0
  118. package/dist/templatesCompiled/client/yup/partials/yupSchemaGeneric.d.ts +34 -0
  119. package/dist/templatesCompiled/client/yup/partials/yupSchemaGeneric.d.ts.map +1 -0
  120. package/dist/templatesCompiled/client/yup/partials/yupSchemaGeneric.js +201 -0
  121. package/dist/templatesCompiled/client/yup/partials/yupSchemaInterface.d.ts +14 -0
  122. package/dist/templatesCompiled/client/yup/partials/yupSchemaInterface.d.ts.map +1 -0
  123. package/dist/templatesCompiled/client/yup/partials/yupSchemaInterface.js +50 -0
  124. package/dist/templatesCompiled/client/yup/partials/yupSchemaReference.d.ts +9 -0
  125. package/dist/templatesCompiled/client/yup/partials/yupSchemaReference.d.ts.map +1 -0
  126. package/dist/templatesCompiled/client/yup/partials/yupSchemaReference.js +25 -0
  127. package/dist/templatesCompiled/client/zod/exportSchema.d.ts +11 -0
  128. package/dist/templatesCompiled/client/zod/exportSchema.d.ts.map +1 -0
  129. package/dist/templatesCompiled/client/zod/exportSchema.js +67 -0
  130. package/dist/templatesCompiled/client/zod/partials/zodSchema.d.ts +22 -0
  131. package/dist/templatesCompiled/client/zod/partials/zodSchema.d.ts.map +1 -0
  132. package/dist/templatesCompiled/client/zod/partials/zodSchema.js +129 -0
  133. package/dist/templatesCompiled/client/zod/partials/zodSchemaArray.d.ts +14 -0
  134. package/dist/templatesCompiled/client/zod/partials/zodSchemaArray.d.ts.map +1 -0
  135. package/dist/templatesCompiled/client/zod/partials/zodSchemaArray.js +65 -0
  136. package/dist/templatesCompiled/client/zod/partials/zodSchemaComposition.d.ts +15 -0
  137. package/dist/templatesCompiled/client/zod/partials/zodSchemaComposition.d.ts.map +1 -0
  138. package/dist/templatesCompiled/client/zod/partials/zodSchemaComposition.js +70 -0
  139. package/dist/templatesCompiled/client/zod/partials/zodSchemaDictionary.d.ts +12 -0
  140. package/dist/templatesCompiled/client/zod/partials/zodSchemaDictionary.d.ts.map +1 -0
  141. package/dist/templatesCompiled/client/zod/partials/zodSchemaDictionary.js +53 -0
  142. package/dist/templatesCompiled/client/zod/partials/zodSchemaEnum.d.ts +15 -0
  143. package/dist/templatesCompiled/client/zod/partials/zodSchemaEnum.d.ts.map +1 -0
  144. package/dist/templatesCompiled/client/zod/partials/zodSchemaEnum.js +86 -0
  145. package/dist/templatesCompiled/client/zod/partials/zodSchemaGeneric.d.ts +34 -0
  146. package/dist/templatesCompiled/client/zod/partials/zodSchemaGeneric.d.ts.map +1 -0
  147. package/dist/templatesCompiled/client/zod/partials/zodSchemaGeneric.js +193 -0
  148. package/dist/templatesCompiled/client/zod/partials/zodSchemaInterface.d.ts +14 -0
  149. package/dist/templatesCompiled/client/zod/partials/zodSchemaInterface.d.ts.map +1 -0
  150. package/dist/templatesCompiled/client/zod/partials/zodSchemaInterface.js +50 -0
  151. package/dist/templatesCompiled/client/zod/partials/zodSchemaReference.d.ts +9 -0
  152. package/dist/templatesCompiled/client/zod/partials/zodSchemaReference.d.ts.map +1 -0
  153. package/dist/templatesCompiled/client/zod/partials/zodSchemaReference.js +25 -0
  154. package/package.json +12 -3
  155. package/dist/common/VersionedSchema/UnifiedOptionsVersioned/UnifiedOptionsMigrationPlan.d.ts +0 -3
  156. package/dist/common/VersionedSchema/UnifiedOptionsVersioned/UnifiedOptionsMigrationPlan.d.ts.map +0 -1
  157. package/dist/common/VersionedSchema/UnifiedOptionsVersioned/UnifiedOptionsMigrationPlan.js +0 -28
  158. package/dist/common/VersionedSchema/UnifiedOptionsVersioned/UnifiedOptionsSchemaV1.d.ts.map +0 -1
  159. package/dist/common/VersionedSchema/UnifiedOptionsVersioned/UnifiedOptionsVersionedSchemas.d.ts +0 -3
  160. package/dist/common/VersionedSchema/UnifiedOptionsVersioned/UnifiedOptionsVersionedSchemas.d.ts.map +0 -1
  161. package/dist/common/VersionedSchema/UnifiedOptionsVersioned/UnifiedOptionsVersionedSchemas.js +0 -10
  162. /package/dist/common/VersionedSchema/{UnifiedOptionsVersioned → AllVersionedSchemas}/UnifiedOptionsSchemaV1.d.ts +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"CommonSchemas.d.ts","sourceRoot":"","sources":["../../../src/common/VersionedSchema/CommonSchemas.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,KAAK,CAAC;AAEtB;;GAEG;AACH,eAAO,MAAM,iBAAiB,uBAM5B,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,wBAAwB,uBAQnC,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,0BAA0B,uBAMrC,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,0BAA0B,uBAMrC,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,4BAA4B,uBAKvC,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,4BAA4B,uBAEvC,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,8BAA8B,uBAIzC,CAAC"}
1
+ {"version":3,"file":"CommonSchemas.d.ts","sourceRoot":"","sources":["../../../src/common/VersionedSchema/CommonSchemas.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,KAAK,CAAC;AAItB;;GAEG;AACH,eAAO,MAAM,iBAAiB,uBAM5B,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,wBAAwB,uBAQnC,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,0BAA0B,uBAMrC,CAAC;AAEH,eAAO,MAAM,0BAA0B,uBAMrC,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,0BAA0B,uBAMrC,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,4BAA4B,uBAKvC,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,4BAA4B,uBAEvC,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,8BAA8B,uBAIzC,CAAC"}
@@ -3,8 +3,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.experimentalParametersSchemaV2 = exports.experimentalParametersSchema = exports.additionalParametersSchemaV2 = exports.additionalParametersSchema = exports.specialParametersSchemasV2 = exports.specialParametersSchemas = exports.outputPathsSchema = void 0;
6
+ exports.experimentalParametersSchemaV2 = exports.experimentalParametersSchema = exports.additionalParametersSchemaV2 = exports.additionalParametersSchema = exports.specialParametersSchemasV3 = exports.specialParametersSchemasV2 = exports.specialParametersSchemas = exports.outputPathsSchema = void 0;
7
7
  const joi_1 = __importDefault(require("joi"));
8
+ const ValidationLibrary_enum_1 = require("../../core/types/enums/ValidationLibrary.enum");
8
9
  /**
9
10
  * The scheme of a set of path parameters for finite directories.
10
11
  */
@@ -35,6 +36,12 @@ exports.specialParametersSchemasV2 = joi_1.default.object({
35
36
  excludeCoreServiceFiles: joi_1.default.boolean().optional(),
36
37
  includeSchemasFiles: joi_1.default.boolean().optional(),
37
38
  });
39
+ exports.specialParametersSchemasV3 = joi_1.default.object({
40
+ useOptions: joi_1.default.boolean().optional(),
41
+ useUnionTypes: joi_1.default.boolean().optional(),
42
+ excludeCoreServiceFiles: joi_1.default.boolean().optional(),
43
+ validationLibrary: joi_1.default.string().valid(...Object.values(ValidationLibrary_enum_1.ValidationLibrary)).optional(),
44
+ });
38
45
  /**
39
46
  * The scheme of additional parameters.
40
47
  */
@@ -1 +1 @@
1
- {"version":3,"file":"defaultOptions.d.ts","sourceRoot":"","sources":["../../src/common/defaultOptions.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,KAAK,CAAC;AAItB,eAAO,MAAM,cAAc,uBAuBV,CAAC"}
1
+ {"version":3,"file":"defaultOptions.d.ts","sourceRoot":"","sources":["../../src/common/defaultOptions.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,KAAK,CAAC;AAKtB,eAAO,MAAM,cAAc,uBAuBV,CAAC"}
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.defaultOptions = void 0;
7
7
  const joi_1 = __importDefault(require("joi"));
8
8
  const HttpClient_enum_1 = require("../core/types/enums/HttpClient.enum");
9
+ const ValidationLibrary_enum_1 = require("../core/types/enums/ValidationLibrary.enum");
9
10
  exports.defaultOptions = joi_1.default.object({
10
11
  input: joi_1.default.string().required(),
11
12
  output: joi_1.default.string().required(),
@@ -17,11 +18,11 @@ exports.defaultOptions = joi_1.default.object({
17
18
  useOptions: joi_1.default.boolean().optional(),
18
19
  useUnionTypes: joi_1.default.boolean().optional(),
19
20
  excludeCoreServiceFiles: joi_1.default.boolean().optional(),
20
- includeSchemasFiles: joi_1.default.boolean().optional(),
21
21
  request: joi_1.default.string().optional(),
22
22
  interfacePrefix: joi_1.default.string().optional(),
23
23
  enumPrefix: joi_1.default.string().optional(),
24
24
  typePrefix: joi_1.default.string().optional(),
25
25
  useCancelableRequest: joi_1.default.boolean().optional(),
26
26
  useSeparatedIndexes: joi_1.default.boolean().optional(),
27
+ validationLibrary: joi_1.default.string().valid(...Object.values(ValidationLibrary_enum_1.ValidationLibrary)).optional(),
27
28
  }).unknown(false);
@@ -13,7 +13,6 @@ const convertArrayToObject_1 = require("../convertArrayToObject");
13
13
  const expected = {
14
14
  items: [],
15
15
  excludeCoreServiceFiles: undefined,
16
- includeSchemasFiles: undefined,
17
16
  request: undefined,
18
17
  useOptions: undefined,
19
18
  useCancelableRequest: undefined,
@@ -34,7 +33,6 @@ const convertArrayToObject_1 = require("../convertArrayToObject");
34
33
  enumPrefix: undefined,
35
34
  excludeCoreServiceFiles: undefined,
36
35
  httpClient: undefined,
37
- includeSchemasFiles: undefined,
38
36
  interfacePrefix: undefined,
39
37
  items: [
40
38
  {
@@ -55,6 +53,7 @@ const convertArrayToObject_1 = require("../convertArrayToObject");
55
53
  useOptions: true,
56
54
  useSeparatedIndexes: undefined,
57
55
  useUnionTypes: undefined,
56
+ validationLibrary: undefined
58
57
  };
59
58
  const result = (0, convertArrayToObject_1.convertArrayToObject)(input);
60
59
  node_assert_1.default.deepStrictEqual(result, expected);
@@ -68,7 +67,6 @@ const convertArrayToObject_1 = require("../convertArrayToObject");
68
67
  enumPrefix: undefined,
69
68
  excludeCoreServiceFiles: undefined,
70
69
  httpClient: undefined,
71
- includeSchemasFiles: undefined,
72
70
  interfacePrefix: undefined,
73
71
  items: [
74
72
  {
@@ -97,6 +95,7 @@ const convertArrayToObject_1 = require("../convertArrayToObject");
97
95
  useOptions: true,
98
96
  useSeparatedIndexes: undefined,
99
97
  useUnionTypes: undefined,
98
+ validationLibrary: undefined
100
99
  };
101
100
  const result = (0, convertArrayToObject_1.convertArrayToObject)(input);
102
101
  node_assert_1.default.deepStrictEqual(result, expected);
@@ -110,7 +109,6 @@ const convertArrayToObject_1 = require("../convertArrayToObject");
110
109
  enumPrefix: undefined,
111
110
  excludeCoreServiceFiles: undefined,
112
111
  httpClient: undefined,
113
- includeSchemasFiles: undefined,
114
112
  interfacePrefix: undefined,
115
113
  items: [
116
114
  {
@@ -139,6 +137,7 @@ const convertArrayToObject_1 = require("../convertArrayToObject");
139
137
  useOptions: true,
140
138
  useSeparatedIndexes: undefined,
141
139
  useUnionTypes: undefined,
140
+ validationLibrary: undefined
142
141
  };
143
142
  const result = (0, convertArrayToObject_1.convertArrayToObject)(input);
144
143
  node_assert_1.default.deepStrictEqual(result, expected);
@@ -152,7 +151,6 @@ const convertArrayToObject_1 = require("../convertArrayToObject");
152
151
  enumPrefix: undefined,
153
152
  excludeCoreServiceFiles: undefined,
154
153
  httpClient: undefined,
155
- includeSchemasFiles: undefined,
156
154
  interfacePrefix: undefined,
157
155
  items: [
158
156
  {
@@ -181,6 +179,7 @@ const convertArrayToObject_1 = require("../convertArrayToObject");
181
179
  useOptions: undefined,
182
180
  useSeparatedIndexes: undefined,
183
181
  useUnionTypes: undefined,
182
+ validationLibrary: undefined
184
183
  };
185
184
  const result = (0, convertArrayToObject_1.convertArrayToObject)(input);
186
185
  node_assert_1.default.deepStrictEqual(result, expected);
@@ -194,7 +193,6 @@ const convertArrayToObject_1 = require("../convertArrayToObject");
194
193
  enumPrefix: undefined,
195
194
  excludeCoreServiceFiles: undefined,
196
195
  httpClient: undefined,
197
- includeSchemasFiles: undefined,
198
196
  interfacePrefix: undefined,
199
197
  items: [
200
198
  {
@@ -223,6 +221,7 @@ const convertArrayToObject_1 = require("../convertArrayToObject");
223
221
  useOptions: undefined,
224
222
  useSeparatedIndexes: undefined,
225
223
  useUnionTypes: undefined,
224
+ validationLibrary: undefined
226
225
  };
227
226
  const result = (0, convertArrayToObject_1.convertArrayToObject)(input);
228
227
  node_assert_1.default.deepStrictEqual(result, expected);
@@ -1 +1 @@
1
- {"version":3,"file":"convertArrayToObject.d.ts","sourceRoot":"","sources":["../../../src/common/utils/convertArrayToObject.ts"],"names":[],"mappings":"AAAA,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,GAAG,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CA4DxH"}
1
+ {"version":3,"file":"convertArrayToObject.d.ts","sourceRoot":"","sources":["../../../src/common/utils/convertArrayToObject.ts"],"names":[],"mappings":"AAAA,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,GAAG,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CA2DxH"}
@@ -5,7 +5,6 @@ function convertArrayToObject(optionsArr) {
5
5
  const emptyResult = {
6
6
  items: [],
7
7
  excludeCoreServiceFiles: undefined,
8
- includeSchemasFiles: undefined,
9
8
  request: undefined,
10
9
  useOptions: undefined,
11
10
  useCancelableRequest: undefined,
@@ -31,7 +30,6 @@ function convertArrayToObject(optionsArr) {
31
30
  'useOptions',
32
31
  'useUnionTypes',
33
32
  'excludeCoreServiceFiles',
34
- 'includeSchemasFiles',
35
33
  'request',
36
34
  'interfacePrefix',
37
35
  'enumPrefix',
@@ -41,6 +39,7 @@ function convertArrayToObject(optionsArr) {
41
39
  'logTarget',
42
40
  'sortByRequired',
43
41
  'useSeparatedIndexes',
42
+ 'validationLibrary',
44
43
  ];
45
44
  const extractedFields = fieldsToExtract.reduce((acc, field) => ({
46
45
  ...acc,
@@ -1 +1 @@
1
- {"version":3,"file":"OpenApiClient.d.ts","sourceRoot":"","sources":["../../src/core/OpenApiClient.ts"],"names":[],"mappings":"AAGA,OAAO,EAAgB,WAAW,EAAsB,MAAM,uBAAuB,CAAC;AActF,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,qBAAa,aAAa;IACtB,OAAO,CAAC,YAAY,CAA4B;IAEhD,IAAW,WAAW,gBAKrB;IAED,OAAO,CAAC,gBAAgB;IAaxB,OAAO,CAAC,gBAAgB;YAyBV,sBAAsB;YAUtB,oBAAoB;YAmCpB,cAAc;IAiFtB,QAAQ,CAAC,UAAU,EAAE,WAAW;CAWzC"}
1
+ {"version":3,"file":"OpenApiClient.d.ts","sourceRoot":"","sources":["../../src/core/OpenApiClient.ts"],"names":[],"mappings":"AAGA,OAAO,EAAgB,WAAW,EAAsB,MAAM,uBAAuB,CAAC;AAetF,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,qBAAa,aAAa;IACtB,OAAO,CAAC,YAAY,CAA4B;IAEhD,IAAW,WAAW,gBAKrB;IAED,OAAO,CAAC,gBAAgB;IAaxB,OAAO,CAAC,gBAAgB;YAyBV,sBAAsB;YAUtB,oBAAoB;YAmCpB,cAAc;IAkFtB,QAAQ,CAAC,UAAU,EAAE,WAAW;CAWzC"}
@@ -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 ValidationLibrary_enum_1 = require("./types/enums/ValidationLibrary.enum");
12
13
  const getOpenApiSpec_1 = require("./utils/getOpenApiSpec");
13
14
  const getOpenApiVersion_1 = require("./utils/getOpenApiVersion");
14
15
  const getOutputPaths_1 = require("./utils/getOutputPaths");
@@ -48,7 +49,6 @@ class OpenApiClient {
48
49
  useOptions: item.useOptions ?? Consts_1.COMMON_DEFAULT_OPTIONS_VALUES.useOptions,
49
50
  useUnionTypes: item.useUnionTypes ?? Consts_1.COMMON_DEFAULT_OPTIONS_VALUES.useUnionTypes,
50
51
  excludeCoreServiceFiles: item.excludeCoreServiceFiles ?? Consts_1.COMMON_DEFAULT_OPTIONS_VALUES.excludeCoreServiceFiles,
51
- includeSchemasFiles: item.includeSchemasFiles ?? Consts_1.COMMON_DEFAULT_OPTIONS_VALUES.includeSchemasFiles,
52
52
  request: item.request || Consts_1.COMMON_DEFAULT_OPTIONS_VALUES.request,
53
53
  interfacePrefix: item.interfacePrefix || Consts_1.COMMON_DEFAULT_OPTIONS_VALUES.interfacePrefix,
54
54
  enumPrefix: item.enumPrefix || Consts_1.COMMON_DEFAULT_OPTIONS_VALUES.enumPrefix,
@@ -58,6 +58,7 @@ class OpenApiClient {
58
58
  logTarget: item.logTarget || Consts_1.COMMON_DEFAULT_OPTIONS_VALUES.logTarget,
59
59
  sortByRequired: item.sortByRequired ?? Consts_1.COMMON_DEFAULT_OPTIONS_VALUES.sortByRequired,
60
60
  useSeparatedIndexes: item.useSeparatedIndexes ?? Consts_1.COMMON_DEFAULT_OPTIONS_VALUES.useSeparatedIndexes,
61
+ validationLibrary: item.validationLibrary ?? Consts_1.COMMON_DEFAULT_OPTIONS_VALUES.validationLibrary,
61
62
  };
62
63
  }
63
64
  async cleanOutputDirectories(option) {
@@ -102,7 +103,7 @@ class OpenApiClient {
102
103
  this.writeClient.logger.shutdownLogger();
103
104
  }
104
105
  async generateSingle(item) {
105
- const { input, output, outputCore, outputServices, outputModels, outputSchemas, httpClient, useOptions, useUnionTypes, excludeCoreServiceFiles, includeSchemasFiles, request, interfacePrefix, enumPrefix, typePrefix, useCancelableRequest, sortByRequired, useSeparatedIndexes, } = item;
106
+ 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;
106
107
  const outputPaths = (0, getOutputPaths_1.getOutputPaths)({
107
108
  output,
108
109
  outputCore,
@@ -118,6 +119,7 @@ class OpenApiClient {
118
119
  httpClient,
119
120
  useUnionTypes,
120
121
  useOptions,
122
+ validationLibrary,
121
123
  });
122
124
  this.writeClient.logger.info(LoggerMessages_1.LOGGER_MESSAGES.OPENAPI.DEFINING_VERSION);
123
125
  switch (openApiVersion) {
@@ -133,10 +135,10 @@ class OpenApiClient {
133
135
  useOptions,
134
136
  useUnionTypes,
135
137
  excludeCoreServiceFiles,
136
- includeSchemasFiles,
137
138
  request,
138
139
  useCancelableRequest,
139
140
  useSeparatedIndexes,
141
+ validationLibrary,
140
142
  });
141
143
  break;
142
144
  }
@@ -152,10 +154,10 @@ class OpenApiClient {
152
154
  useOptions,
153
155
  useUnionTypes,
154
156
  excludeCoreServiceFiles,
155
- includeSchemasFiles,
156
157
  request,
157
158
  useCancelableRequest,
158
159
  useSeparatedIndexes,
160
+ validationLibrary,
159
161
  });
160
162
  break;
161
163
  }
@@ -1,6 +1,7 @@
1
1
  import { Logger } from '../common/Logger';
2
2
  import { OutputPaths } from './types/base/OutputPaths.model';
3
3
  import { HttpClient } from './types/enums/HttpClient.enum';
4
+ import { ValidationLibrary } from './types/enums/ValidationLibrary.enum';
4
5
  import type { Client } from './types/shared/Client.model';
5
6
  import { Templates } from './utils/registerHandlebarTemplates';
6
7
  import { writeClientCore } from './utils/writeClientCore';
@@ -21,10 +22,10 @@ import { writeClientSimpleIndex } from './utils/writeClientSimpleIndex';
21
22
  * @param useOptions Use options or arguments functions
22
23
  * @param useUnionTypes Use union types instead of enums
23
24
  * @param excludeCoreServiceFiles The generation of the core and services is excluded
24
- * @param includeSchemasFiles The generation of model validation schemes is enabled
25
25
  * @param request: Path to custom request file
26
26
  * @param useCancelableRequest Use cancelable request type.
27
27
  * @param useSeparatedIndexes Use separate index files for the core, models, schemas, and services
28
+ * @param validationLibrary Validation library to use for schema validation
28
29
  */
29
30
  type TWriteClientProps = {
30
31
  client: Client;
@@ -34,10 +35,10 @@ type TWriteClientProps = {
34
35
  useOptions: boolean;
35
36
  useUnionTypes: boolean;
36
37
  excludeCoreServiceFiles: boolean;
37
- includeSchemasFiles: boolean;
38
38
  request?: string;
39
39
  useCancelableRequest?: boolean;
40
40
  useSeparatedIndexes?: boolean;
41
+ validationLibrary?: ValidationLibrary;
41
42
  };
42
43
  type TAPIClientGeneratorConfig = Omit<TWriteClientProps, 'httpClient' | 'useOptions' | 'request' | 'useCancelableRequest' | 'useSeparatedIndexes'>;
43
44
  /**
@@ -49,16 +50,6 @@ export declare class WriteClient {
49
50
  constructor(logger?: Logger);
50
51
  /**
51
52
  * Write our OpenAPI client, using the given templates at the given output
52
- * @param client Client object with all the models, services, etc.
53
- * @param templates Templates wrapper with all loaded Handlebars templates
54
- * @param outputPaths A set of parameters with paths for generating main sections (folders)
55
- * @param httpClient The selected httpClient (fetch, xhr or node)
56
- * @param useOptions Use options or arguments functions
57
- * @param useUnionTypes Use union types instead of enums
58
- * @param excludeCoreServiceFiles:
59
- * @param includeSchemasFiles:
60
- * @param request: Path to custom request file
61
- * @param useCancelableRequest Use cancelable request type.
62
53
  */
63
54
  writeClient(options: TWriteClientProps): Promise<void>;
64
55
  /**
@@ -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,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC3D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAE1D,OAAO,EAAE,SAAS,EAAE,MAAM,oCAAoC,CAAC;AAG/D,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAE,iBAAiB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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;CAC1D"}
@@ -5,6 +5,7 @@ const Enums_1 = require("../common/Enums");
5
5
  const Logger_1 = require("../common/Logger");
6
6
  const fileSystemHelpers_1 = require("../common/utils/fileSystemHelpers");
7
7
  const pathHelpers_1 = require("../common/utils/pathHelpers");
8
+ const ValidationLibrary_enum_1 = require("./types/enums/ValidationLibrary.enum");
8
9
  const prepareAlias_1 = require("./utils/prepareAlias");
9
10
  const sortModelByName_1 = require("./utils/sortModelByName");
10
11
  const unique_1 = require("./utils/unique");
@@ -25,27 +26,19 @@ class WriteClient {
25
26
  config = new Map();
26
27
  _logger;
27
28
  constructor(logger) {
28
- this._logger = logger || new Logger_1.Logger({
29
- level: Enums_1.ELogLevel.ERROR,
30
- instanceId: 'client',
31
- logOutput: Enums_1.ELogOutput.CONSOLE,
32
- });
29
+ this._logger =
30
+ logger ||
31
+ new Logger_1.Logger({
32
+ level: Enums_1.ELogLevel.ERROR,
33
+ instanceId: 'client',
34
+ logOutput: Enums_1.ELogOutput.CONSOLE,
35
+ });
33
36
  }
34
37
  /**
35
38
  * Write our OpenAPI client, using the given templates at the given output
36
- * @param client Client object with all the models, services, etc.
37
- * @param templates Templates wrapper with all loaded Handlebars templates
38
- * @param outputPaths A set of parameters with paths for generating main sections (folders)
39
- * @param httpClient The selected httpClient (fetch, xhr or node)
40
- * @param useOptions Use options or arguments functions
41
- * @param useUnionTypes Use union types instead of enums
42
- * @param excludeCoreServiceFiles:
43
- * @param includeSchemasFiles:
44
- * @param request: Path to custom request file
45
- * @param useCancelableRequest Use cancelable request type.
46
39
  */
47
40
  async writeClient(options) {
48
- const { client, templates, outputPaths, httpClient, useOptions, useUnionTypes, excludeCoreServiceFiles = false, includeSchemasFiles = false, request, useCancelableRequest = false, useSeparatedIndexes = false, } = options;
41
+ const { client, templates, outputPaths, httpClient, useOptions, useUnionTypes, excludeCoreServiceFiles = false, request, useCancelableRequest = false, useSeparatedIndexes = false, validationLibrary = ValidationLibrary_enum_1.ValidationLibrary.NONE, } = options;
49
42
  if (!excludeCoreServiceFiles) {
50
43
  await fileSystemHelpers_1.fileSystemHelpers.mkdir(outputPaths.outputCore);
51
44
  await this.writeClientCore({ client, templates, outputCorePath: outputPaths.outputCore, httpClient, request, useCancelableRequest });
@@ -77,7 +70,11 @@ class WriteClient {
77
70
  useSeparatedIndexes,
78
71
  });
79
72
  }
80
- if (includeSchemasFiles) {
73
+ /**
74
+ * TODO: Нужно собирать импорты из всех вложенных моделей (link, properties в composition и т.д.) и передавать их в шаблон.
75
+ * Это делается в writeClientSchemas или в парсере моделей.
76
+ */
77
+ if (validationLibrary !== ValidationLibrary_enum_1.ValidationLibrary.NONE) {
81
78
  await fileSystemHelpers_1.fileSystemHelpers.mkdir(outputPaths.outputSchemas);
82
79
  await this.writeClientSchemas({
83
80
  models: client.models,
@@ -85,6 +82,7 @@ class WriteClient {
85
82
  outputSchemasPath: outputPaths.outputSchemas,
86
83
  httpClient,
87
84
  useUnionTypes,
85
+ validationLibrary,
88
86
  });
89
87
  await this.writeClientSchemasIndex({
90
88
  models: client.models,
@@ -114,7 +112,7 @@ class WriteClient {
114
112
  outputPaths,
115
113
  useUnionTypes,
116
114
  excludeCoreServiceFiles,
117
- includeSchemasFiles,
115
+ validationLibrary,
118
116
  });
119
117
  }
120
118
  /**
@@ -146,7 +144,7 @@ class WriteClient {
146
144
  const result = new Map();
147
145
  for (const [key, value] of this.config.entries()) {
148
146
  for (const item of value) {
149
- const { outputPaths, templates, excludeCoreServiceFiles, includeSchemasFiles } = item;
147
+ const { outputPaths, templates, excludeCoreServiceFiles, validationLibrary } = item;
150
148
  const outputCore = this.getOutputPath(outputPaths?.outputCore, key, 'core');
151
149
  const outputModels = this.getOutputPath(outputPaths?.outputModels, key, 'models');
152
150
  const outputSchemas = this.getOutputPath(outputPaths?.outputSchemas, key, 'schemas');
@@ -166,7 +164,7 @@ class WriteClient {
166
164
  if (!clientIndex.models.includes(relativePathModel)) {
167
165
  clientIndex.models.push(relativePathModel);
168
166
  }
169
- if (includeSchemasFiles) {
167
+ if (validationLibrary !== ValidationLibrary_enum_1.ValidationLibrary.NONE) {
170
168
  const relativePathSchema = (0, pathHelpers_1.relativeHelper)(key, outputSchemas);
171
169
  if (!clientIndex.schemas.includes(relativePathSchema)) {
172
170
  clientIndex.schemas.push(relativePathSchema);
@@ -180,7 +178,7 @@ class WriteClient {
180
178
  const result = new Map();
181
179
  for (const [key, value] of this.config.entries()) {
182
180
  for (const item of value) {
183
- const { outputPaths, client, templates, useUnionTypes, excludeCoreServiceFiles, includeSchemasFiles } = item;
181
+ const { outputPaths, client, templates, useUnionTypes, excludeCoreServiceFiles, validationLibrary } = item;
184
182
  const outputCore = this.getOutputPath(outputPaths?.outputCore, key, 'core');
185
183
  const outputModels = this.getOutputPath(outputPaths?.outputModels, key, 'models');
186
184
  const outputSchemas = this.getOutputPath(outputPaths?.outputSchemas, key, 'schemas');
@@ -216,7 +214,7 @@ class WriteClient {
216
214
  if (!clientIndex.models.some(m => this.isSameModel(m, modelFinal))) {
217
215
  clientIndex.models.push(modelFinal);
218
216
  }
219
- if (includeSchemasFiles) {
217
+ if (validationLibrary !== ValidationLibrary_enum_1.ValidationLibrary.NONE) {
220
218
  const schema = { ...modelFinal, package: relativePathSchema };
221
219
  if (!clientIndex.schemas.some(s => this.isSameShema(s, schema))) {
222
220
  clientIndex.schemas.push(schema);
@@ -7,6 +7,7 @@ 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
9
  const HttpClient_enum_1 = require("../types/enums/HttpClient.enum");
10
+ const ValidationLibrary_enum_1 = require("../types/enums/ValidationLibrary.enum");
10
11
  const getOutputPaths_1 = require("../utils/getOutputPaths");
11
12
  const WriteClient_1 = require("../WriteClient");
12
13
  (0, node_test_1.describe)('@unit: writeClient', () => {
@@ -41,6 +42,10 @@ const WriteClient_1 = require("../WriteClient");
41
42
  exports: {
42
43
  model: () => 'model',
43
44
  schema: () => 'schema',
45
+ zodSchema: () => 'zodSchema',
46
+ yupSchema: () => 'yupSchema',
47
+ joiSchema: () => 'joiSchema',
48
+ jsonSchemaSchema: () => 'jsonSchemaSchema',
44
49
  service: () => 'service',
45
50
  },
46
51
  core: {
@@ -64,7 +69,7 @@ const WriteClient_1 = require("../WriteClient");
64
69
  useOptions: false,
65
70
  useUnionTypes: false,
66
71
  excludeCoreServiceFiles: false,
67
- includeSchemasFiles: false,
72
+ validationLibrary: ValidationLibrary_enum_1.ValidationLibrary.NONE,
68
73
  });
69
74
  strict_1.default.ok(mkdirCalls.length > 0, 'mkdir should be called at least once');
70
75
  strict_1.default.ok(writeFileCalls.length > 0, 'writeFile should be called at least once');
@@ -0,0 +1,8 @@
1
+ export declare enum ValidationLibrary {
2
+ NONE = "none",
3
+ ZOD = "zod",
4
+ JOI = "joi",
5
+ YUP = "yup",
6
+ JSONSCHEMA = "jsonschema"
7
+ }
8
+ //# sourceMappingURL=ValidationLibrary.enum.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ValidationLibrary.enum.d.ts","sourceRoot":"","sources":["../../../../src/core/types/enums/ValidationLibrary.enum.ts"],"names":[],"mappings":"AAAA,oBAAY,iBAAiB;IACzB,IAAI,SAAS;IACb,GAAG,QAAQ;IACX,GAAG,QAAQ;IACX,GAAG,QAAQ;IACX,UAAU,eAAe;CAC5B"}
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ValidationLibrary = void 0;
4
+ var ValidationLibrary;
5
+ (function (ValidationLibrary) {
6
+ ValidationLibrary["NONE"] = "none";
7
+ ValidationLibrary["ZOD"] = "zod";
8
+ ValidationLibrary["JOI"] = "joi";
9
+ ValidationLibrary["YUP"] = "yup";
10
+ ValidationLibrary["JSONSCHEMA"] = "jsonschema";
11
+ })(ValidationLibrary || (exports.ValidationLibrary = ValidationLibrary = {}));
@@ -1 +1 @@
1
- {"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../../../../src/core/utils/__mocks__/templates.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAE1D,eAAO,MAAM,SAAS,EAAE,SAyBvB,CAAC"}
1
+ {"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../../../../src/core/utils/__mocks__/templates.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAE1D,eAAO,MAAM,SAAS,EAAE,SA6BvB,CAAC"}
@@ -13,6 +13,10 @@ exports.templates = {
13
13
  exports: {
14
14
  model: () => 'model',
15
15
  schema: () => 'schema',
16
+ zodSchema: () => 'zodSchema',
17
+ yupSchema: () => 'yupSchema',
18
+ joiSchema: () => 'joiSchema',
19
+ jsonSchemaSchema: () => 'jsonSchemaSchema',
16
20
  service: () => 'service',
17
21
  },
18
22
  core: {
@@ -7,6 +7,7 @@ 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
9
  const HttpClient_enum_1 = require("../../types/enums/HttpClient.enum");
10
+ const ValidationLibrary_enum_1 = require("../../types/enums/ValidationLibrary.enum");
10
11
  const WriteClient_1 = require("../../WriteClient");
11
12
  const templates_1 = require("../__mocks__/templates");
12
13
  (0, node_test_1.describe)('@unit: writeClientSchemas', () => {
@@ -45,6 +46,7 @@ const templates_1 = require("../__mocks__/templates");
45
46
  outputSchemasPath: '/',
46
47
  httpClient: HttpClient_enum_1.HttpClient.FETCH,
47
48
  useUnionTypes: false,
49
+ validationLibrary: ValidationLibrary_enum_1.ValidationLibrary.NONE,
48
50
  });
49
51
  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');
50
52
  // Restoring the original function
@@ -62,6 +62,12 @@ const precompileTemplates = () => {
62
62
  containsSystemName: true,
63
63
  normalizePath: true,
64
64
  joinPath: true,
65
+ isNumericEnum: true,
66
+ isBasicType: true,
67
+ yupBaseSchema: true,
68
+ joiBaseSchema: true,
69
+ getRequiredFields: true,
70
+ getEnumType: true,
65
71
  },
66
72
  });
67
73
  const tsContent = header + precompiled;
@@ -1 +1 @@
1
- {"version":3,"file":"registerHandlebarHelpers.d.ts","sourceRoot":"","sources":["../../../src/core/utils/registerHandlebarHelpers.ts"],"names":[],"mappings":"AAGA,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,CA+E5H"}
1
+ {"version":3,"file":"registerHandlebarHelpers.d.ts","sourceRoot":"","sources":["../../../src/core/utils/registerHandlebarHelpers.ts"],"names":[],"mappings":"AAGA,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,CA6J5H"}
@@ -104,4 +104,78 @@ function registerHandlebarHelpers(root) {
104
104
  const cleanedSecondPath = secondPath.startsWith('./') ? secondPath.slice(2) : secondPath;
105
105
  return `${cleanedFirstPath}/${cleanedSecondPath}`.replace(Consts_1.REGEX_BACKSLASH, '/').replace(Consts_1.REGEX_MULTIPLE_SLASHES, '/');
106
106
  });
107
+ Handlebars.registerHelper('isNumericEnum', function (enumerators, options) {
108
+ if (!enumerators || enumerators.length === 0) {
109
+ return options.inverse(this);
110
+ }
111
+ const firstEnum = enumerators[0];
112
+ return firstEnum.type === 'number' ? options.fn(this) : options.inverse(this);
113
+ });
114
+ Handlebars.registerHelper('isBasicType', function (link) {
115
+ if (!link)
116
+ return false;
117
+ // Если есть imports, это реальная схема, а не базовый тип
118
+ if (link.imports && link.imports.length > 0)
119
+ return false;
120
+ // Если есть path и это не базовый тип, это схема
121
+ if (link.path && link.path !== link.base?.toLowerCase())
122
+ return false;
123
+ // Проверяем, является ли base базовым типом
124
+ const basicTypes = ['string', 'number', 'integer', 'int', 'boolean', 'file', 'File', 'any', 'null'];
125
+ return basicTypes.includes(link.base);
126
+ });
127
+ Handlebars.registerHelper('yupBaseSchema', function (base) {
128
+ if (!base)
129
+ return 'yup.mixed()';
130
+ const baseLower = base.toLowerCase();
131
+ switch (baseLower) {
132
+ case 'string':
133
+ return 'yup.string()';
134
+ case 'number':
135
+ return 'yup.number()';
136
+ case 'integer':
137
+ case 'int':
138
+ return 'yup.number().integer()';
139
+ case 'boolean':
140
+ return 'yup.boolean()';
141
+ case 'file':
142
+ return 'yup.mixed()';
143
+ default:
144
+ return 'yup.mixed()';
145
+ }
146
+ });
147
+ Handlebars.registerHelper('joiBaseSchema', function (base) {
148
+ if (!base)
149
+ return 'Joi.any()';
150
+ const baseLower = base.toLowerCase();
151
+ switch (baseLower) {
152
+ case 'string':
153
+ return 'Joi.string()';
154
+ case 'number':
155
+ return 'Joi.number()';
156
+ case 'integer':
157
+ case 'int':
158
+ return 'Joi.number().integer()';
159
+ case 'boolean':
160
+ return 'Joi.boolean()';
161
+ case 'file':
162
+ return 'Joi.any()';
163
+ default:
164
+ return 'Joi.any()';
165
+ }
166
+ });
167
+ Handlebars.registerHelper('getRequiredFields', function (properties) {
168
+ const required = properties
169
+ .filter(prop => prop.isRequired)
170
+ .map(prop => `'${prop.name}'`)
171
+ .join(', ');
172
+ return required ? `required: [${required}],` : '';
173
+ });
174
+ Handlebars.registerHelper('getEnumType', function (enumerators) {
175
+ if (!enumerators || enumerators.length === 0) {
176
+ return 'string';
177
+ }
178
+ const firstEnum = enumerators[0];
179
+ return firstEnum.type === 'number' ? 'number' : 'string';
180
+ });
107
181
  }
@@ -1,5 +1,6 @@
1
1
  import * as Handlebars from 'handlebars/runtime';
2
2
  import { HttpClient } from '../types/enums/HttpClient.enum';
3
+ import { ValidationLibrary } from '../types/enums/ValidationLibrary.enum';
3
4
  export interface Templates {
4
5
  indexes: {
5
6
  full: Handlebars.TemplateDelegate;
@@ -12,6 +13,10 @@ export interface Templates {
12
13
  exports: {
13
14
  model: Handlebars.TemplateDelegate;
14
15
  schema: Handlebars.TemplateDelegate;
16
+ zodSchema: Handlebars.TemplateDelegate;
17
+ yupSchema: Handlebars.TemplateDelegate;
18
+ joiSchema: Handlebars.TemplateDelegate;
19
+ jsonSchemaSchema: Handlebars.TemplateDelegate;
15
20
  service: Handlebars.TemplateDelegate;
16
21
  };
17
22
  core: {
@@ -34,5 +39,6 @@ export declare function registerHandlebarTemplates(root: {
34
39
  httpClient: HttpClient;
35
40
  useOptions: boolean;
36
41
  useUnionTypes: boolean;
42
+ validationLibrary?: ValidationLibrary;
37
43
  }): Templates;
38
44
  //# sourceMappingURL=registerHandlebarTemplates.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"registerHandlebarTemplates.d.ts","sourceRoot":"","sources":["../../../src/core/utils/registerHandlebarTemplates.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,UAAU,MAAM,oBAAoB,CAAC;AAyFjD,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAE5D,MAAM,WAAW,SAAS;IACtB,OAAO,EAAE;QACL,IAAI,EAAE,UAAU,CAAC,gBAAgB,CAAC;QAClC,M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