ts-openapi-codegen 2.0.0-beta.0 → 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 (177) hide show
  1. package/README.md +145 -55
  2. package/README.rus.md +144 -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 +8 -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 +3 -0
  35. package/dist/core/utils/__mocks__/templates.d.ts.map +1 -0
  36. package/dist/core/utils/__mocks__/templates.js +33 -0
  37. package/dist/core/utils/__tests__/writeClientCore.test.js +2 -25
  38. package/dist/core/utils/__tests__/writeClientFullIndex.test.js +2 -25
  39. package/dist/core/utils/__tests__/writeClientModels.test.js +2 -25
  40. package/dist/core/utils/__tests__/writeClientSchemas.test.js +4 -25
  41. package/dist/core/utils/__tests__/writeClientServices.test.js +2 -25
  42. package/dist/core/utils/precompileTemplates.js +6 -0
  43. package/dist/core/utils/registerHandlebarHelpers.d.ts.map +1 -1
  44. package/dist/core/utils/registerHandlebarHelpers.js +74 -0
  45. package/dist/core/utils/registerHandlebarTemplates.d.ts +8 -0
  46. package/dist/core/utils/registerHandlebarTemplates.d.ts.map +1 -1
  47. package/dist/core/utils/registerHandlebarTemplates.js +88 -0
  48. package/dist/core/utils/writeClientCore.d.ts.map +1 -1
  49. package/dist/core/utils/writeClientCore.js +3 -0
  50. package/dist/core/utils/writeClientSchemas.d.ts +2 -0
  51. package/dist/core/utils/writeClientSchemas.d.ts.map +1 -1
  52. package/dist/core/utils/writeClientSchemas.js +14 -2
  53. package/dist/templatesCompiled/client/core/legacy-request-adapter.d.ts +8 -0
  54. package/dist/templatesCompiled/client/core/legacy-request-adapter.d.ts.map +1 -0
  55. package/dist/templatesCompiled/client/core/legacy-request-adapter.js +18 -0
  56. package/dist/templatesCompiled/client/core/request-executor.d.ts +7 -0
  57. package/dist/templatesCompiled/client/core/request-executor.d.ts.map +1 -0
  58. package/dist/templatesCompiled/client/core/request-executor.js +11 -0
  59. package/dist/templatesCompiled/client/exportService.d.ts.map +1 -1
  60. package/dist/templatesCompiled/client/exportService.js +46 -50
  61. package/dist/templatesCompiled/client/joi/exportSchema.d.ts +11 -0
  62. package/dist/templatesCompiled/client/joi/exportSchema.d.ts.map +1 -0
  63. package/dist/templatesCompiled/client/joi/exportSchema.js +71 -0
  64. package/dist/templatesCompiled/client/joi/partials/joiSchema.d.ts +22 -0
  65. package/dist/templatesCompiled/client/joi/partials/joiSchema.d.ts.map +1 -0
  66. package/dist/templatesCompiled/client/joi/partials/joiSchema.js +129 -0
  67. package/dist/templatesCompiled/client/joi/partials/joiSchemaArray.d.ts +16 -0
  68. package/dist/templatesCompiled/client/joi/partials/joiSchemaArray.d.ts.map +1 -0
  69. package/dist/templatesCompiled/client/joi/partials/joiSchemaArray.js +84 -0
  70. package/dist/templatesCompiled/client/joi/partials/joiSchemaComposition.d.ts +18 -0
  71. package/dist/templatesCompiled/client/joi/partials/joiSchemaComposition.d.ts.map +1 -0
  72. package/dist/templatesCompiled/client/joi/partials/joiSchemaComposition.js +96 -0
  73. package/dist/templatesCompiled/client/joi/partials/joiSchemaDictionary.d.ts +14 -0
  74. package/dist/templatesCompiled/client/joi/partials/joiSchemaDictionary.d.ts.map +1 -0
  75. package/dist/templatesCompiled/client/joi/partials/joiSchemaDictionary.js +72 -0
  76. package/dist/templatesCompiled/client/joi/partials/joiSchemaEnum.d.ts +14 -0
  77. package/dist/templatesCompiled/client/joi/partials/joiSchemaEnum.d.ts.map +1 -0
  78. package/dist/templatesCompiled/client/joi/partials/joiSchemaEnum.js +74 -0
  79. package/dist/templatesCompiled/client/joi/partials/joiSchemaGeneric.d.ts +35 -0
  80. package/dist/templatesCompiled/client/joi/partials/joiSchemaGeneric.d.ts.map +1 -0
  81. package/dist/templatesCompiled/client/joi/partials/joiSchemaGeneric.js +201 -0
  82. package/dist/templatesCompiled/client/joi/partials/joiSchemaInterface.d.ts +14 -0
  83. package/dist/templatesCompiled/client/joi/partials/joiSchemaInterface.d.ts.map +1 -0
  84. package/dist/templatesCompiled/client/joi/partials/joiSchemaInterface.js +50 -0
  85. package/dist/templatesCompiled/client/joi/partials/joiSchemaReference.d.ts +9 -0
  86. package/dist/templatesCompiled/client/joi/partials/joiSchemaReference.d.ts.map +1 -0
  87. package/dist/templatesCompiled/client/joi/partials/joiSchemaReference.js +25 -0
  88. package/dist/templatesCompiled/client/jsonschema/exportSchema.d.ts +11 -0
  89. package/dist/templatesCompiled/client/jsonschema/exportSchema.d.ts.map +1 -0
  90. package/dist/templatesCompiled/client/jsonschema/exportSchema.js +69 -0
  91. package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchema.d.ts +22 -0
  92. package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchema.d.ts.map +1 -0
  93. package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchema.js +129 -0
  94. package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchemaArray.d.ts +16 -0
  95. package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchemaArray.d.ts.map +1 -0
  96. package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchemaArray.js +74 -0
  97. package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchemaComposition.d.ts +16 -0
  98. package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchemaComposition.d.ts.map +1 -0
  99. package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchemaComposition.js +84 -0
  100. package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchemaDictionary.d.ts +13 -0
  101. package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchemaDictionary.d.ts.map +1 -0
  102. package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchemaDictionary.js +56 -0
  103. package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchemaEnum.d.ts +12 -0
  104. package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchemaEnum.d.ts.map +1 -0
  105. package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchemaEnum.js +49 -0
  106. package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchemaGeneric.d.ts +29 -0
  107. package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchemaGeneric.d.ts.map +1 -0
  108. package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchemaGeneric.js +175 -0
  109. package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchemaInterface.d.ts +15 -0
  110. package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchemaInterface.d.ts.map +1 -0
  111. package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchemaInterface.js +63 -0
  112. package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchemaReference.d.ts +9 -0
  113. package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchemaReference.d.ts.map +1 -0
  114. package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchemaReference.js +25 -0
  115. package/dist/templatesCompiled/client/yup/exportSchema.d.ts +11 -0
  116. package/dist/templatesCompiled/client/yup/exportSchema.d.ts.map +1 -0
  117. package/dist/templatesCompiled/client/yup/exportSchema.js +73 -0
  118. package/dist/templatesCompiled/client/yup/partials/yupSchema.d.ts +22 -0
  119. package/dist/templatesCompiled/client/yup/partials/yupSchema.d.ts.map +1 -0
  120. package/dist/templatesCompiled/client/yup/partials/yupSchema.js +129 -0
  121. package/dist/templatesCompiled/client/yup/partials/yupSchemaArray.d.ts +16 -0
  122. package/dist/templatesCompiled/client/yup/partials/yupSchemaArray.d.ts.map +1 -0
  123. package/dist/templatesCompiled/client/yup/partials/yupSchemaArray.js +84 -0
  124. package/dist/templatesCompiled/client/yup/partials/yupSchemaComposition.d.ts +18 -0
  125. package/dist/templatesCompiled/client/yup/partials/yupSchemaComposition.d.ts.map +1 -0
  126. package/dist/templatesCompiled/client/yup/partials/yupSchemaComposition.js +96 -0
  127. package/dist/templatesCompiled/client/yup/partials/yupSchemaDictionary.d.ts +14 -0
  128. package/dist/templatesCompiled/client/yup/partials/yupSchemaDictionary.d.ts.map +1 -0
  129. package/dist/templatesCompiled/client/yup/partials/yupSchemaDictionary.js +72 -0
  130. package/dist/templatesCompiled/client/yup/partials/yupSchemaEnum.d.ts +14 -0
  131. package/dist/templatesCompiled/client/yup/partials/yupSchemaEnum.d.ts.map +1 -0
  132. package/dist/templatesCompiled/client/yup/partials/yupSchemaEnum.js +74 -0
  133. package/dist/templatesCompiled/client/yup/partials/yupSchemaGeneric.d.ts +34 -0
  134. package/dist/templatesCompiled/client/yup/partials/yupSchemaGeneric.d.ts.map +1 -0
  135. package/dist/templatesCompiled/client/yup/partials/yupSchemaGeneric.js +201 -0
  136. package/dist/templatesCompiled/client/yup/partials/yupSchemaInterface.d.ts +14 -0
  137. package/dist/templatesCompiled/client/yup/partials/yupSchemaInterface.d.ts.map +1 -0
  138. package/dist/templatesCompiled/client/yup/partials/yupSchemaInterface.js +50 -0
  139. package/dist/templatesCompiled/client/yup/partials/yupSchemaReference.d.ts +9 -0
  140. package/dist/templatesCompiled/client/yup/partials/yupSchemaReference.d.ts.map +1 -0
  141. package/dist/templatesCompiled/client/yup/partials/yupSchemaReference.js +25 -0
  142. package/dist/templatesCompiled/client/zod/exportSchema.d.ts +11 -0
  143. package/dist/templatesCompiled/client/zod/exportSchema.d.ts.map +1 -0
  144. package/dist/templatesCompiled/client/zod/exportSchema.js +67 -0
  145. package/dist/templatesCompiled/client/zod/partials/zodSchema.d.ts +22 -0
  146. package/dist/templatesCompiled/client/zod/partials/zodSchema.d.ts.map +1 -0
  147. package/dist/templatesCompiled/client/zod/partials/zodSchema.js +129 -0
  148. package/dist/templatesCompiled/client/zod/partials/zodSchemaArray.d.ts +14 -0
  149. package/dist/templatesCompiled/client/zod/partials/zodSchemaArray.d.ts.map +1 -0
  150. package/dist/templatesCompiled/client/zod/partials/zodSchemaArray.js +65 -0
  151. package/dist/templatesCompiled/client/zod/partials/zodSchemaComposition.d.ts +15 -0
  152. package/dist/templatesCompiled/client/zod/partials/zodSchemaComposition.d.ts.map +1 -0
  153. package/dist/templatesCompiled/client/zod/partials/zodSchemaComposition.js +70 -0
  154. package/dist/templatesCompiled/client/zod/partials/zodSchemaDictionary.d.ts +12 -0
  155. package/dist/templatesCompiled/client/zod/partials/zodSchemaDictionary.d.ts.map +1 -0
  156. package/dist/templatesCompiled/client/zod/partials/zodSchemaDictionary.js +53 -0
  157. package/dist/templatesCompiled/client/zod/partials/zodSchemaEnum.d.ts +15 -0
  158. package/dist/templatesCompiled/client/zod/partials/zodSchemaEnum.d.ts.map +1 -0
  159. package/dist/templatesCompiled/client/zod/partials/zodSchemaEnum.js +86 -0
  160. package/dist/templatesCompiled/client/zod/partials/zodSchemaGeneric.d.ts +34 -0
  161. package/dist/templatesCompiled/client/zod/partials/zodSchemaGeneric.d.ts.map +1 -0
  162. package/dist/templatesCompiled/client/zod/partials/zodSchemaGeneric.js +193 -0
  163. package/dist/templatesCompiled/client/zod/partials/zodSchemaInterface.d.ts +14 -0
  164. package/dist/templatesCompiled/client/zod/partials/zodSchemaInterface.d.ts.map +1 -0
  165. package/dist/templatesCompiled/client/zod/partials/zodSchemaInterface.js +50 -0
  166. package/dist/templatesCompiled/client/zod/partials/zodSchemaReference.d.ts +9 -0
  167. package/dist/templatesCompiled/client/zod/partials/zodSchemaReference.d.ts.map +1 -0
  168. package/dist/templatesCompiled/client/zod/partials/zodSchemaReference.js +25 -0
  169. package/package.json +12 -3
  170. package/dist/common/VersionedSchema/UnifiedOptionsVersioned/UnifiedOptionsMigrationPlan.d.ts +0 -3
  171. package/dist/common/VersionedSchema/UnifiedOptionsVersioned/UnifiedOptionsMigrationPlan.d.ts.map +0 -1
  172. package/dist/common/VersionedSchema/UnifiedOptionsVersioned/UnifiedOptionsMigrationPlan.js +0 -28
  173. package/dist/common/VersionedSchema/UnifiedOptionsVersioned/UnifiedOptionsSchemaV1.d.ts.map +0 -1
  174. package/dist/common/VersionedSchema/UnifiedOptionsVersioned/UnifiedOptionsVersionedSchemas.d.ts +0 -3
  175. package/dist/common/VersionedSchema/UnifiedOptionsVersioned/UnifiedOptionsVersionedSchemas.d.ts.map +0 -1
  176. package/dist/common/VersionedSchema/UnifiedOptionsVersioned/UnifiedOptionsVersionedSchemas.js +0 -10
  177. /package/dist/common/VersionedSchema/{UnifiedOptionsVersioned → AllVersionedSchemas}/UnifiedOptionsSchemaV1.d.ts +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"AllMigrationPlans.d.ts","sourceRoot":"","sources":["../../../../src/common/VersionedSchema/AllVersionedSchemas/AllMigrationPlans.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAc/C;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,EAAE,mBAAmB,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,EAY5F,CAAC"}
1
+ {"version":3,"file":"AllMigrationPlans.d.ts","sourceRoot":"","sources":["../../../../src/common/VersionedSchema/AllVersionedSchemas/AllMigrationPlans.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAc/C;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,EAAE,mBAAmB,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,EAmB5F,CAAC"}
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.allMigrationPlans = void 0;
4
+ const ValidationLibrary_enum_1 = require("../../../core/types/enums/ValidationLibrary.enum");
4
5
  const MultiOptionsMigrationPlan_1 = require("../MultiOptionsVersioned/MultiOptionsMigrationPlan");
5
6
  const OptionsMigrationPlans_1 = require("../OptionsVersioned/OptionsMigrationPlans");
6
7
  const createTrivialMigration_1 = require("../Utils/createTrivialMigration");
@@ -28,4 +29,11 @@ exports.allMigrationPlans = [
28
29
  ...addVersionPrefixToMigrationPlans(MultiOptionsMigrationPlan_1.multiOptionsMigrationPlan, 'MULTI_OPTIONS'),
29
30
  // Migration from MULTI_OPTIONS v5 to UNIFIED v1
30
31
  (0, createTrivialMigration_1.createTrivialMigration)('MULTI_OPTIONS_v5', 'UNIFIED_v1', 'Migrate from MULTI_OPTIONS to UNIFIED schema'),
32
+ {
33
+ fromVersion: 'UNIFIED_v1',
34
+ toVersion: 'UNIFIED_v2',
35
+ migrate: ({ includeSchemasFiles, ...otherProps }) => {
36
+ return { ...otherProps, validationLibrary: !includeSchemasFiles ? ValidationLibrary_enum_1.ValidationLibrary.NONE : undefined };
37
+ },
38
+ },
31
39
  ];
@@ -1 +1 @@
1
- {"version":3,"file":"AllVersionedSchemas.d.ts","sourceRoot":"","sources":["../../../../src/common/VersionedSchema/AllVersionedSchemas/AllVersionedSchemas.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAgB3C;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,EAAE,eAAe,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,EAarE,CAAC"}
1
+ {"version":3,"file":"AllVersionedSchemas.d.ts","sourceRoot":"","sources":["../../../../src/common/VersionedSchema/AllVersionedSchemas/AllVersionedSchemas.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAiB3C;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,EAAE,eAAe,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,EAkBrE,CAAC"}
@@ -4,7 +4,8 @@ exports.allVersionedSchemas = void 0;
4
4
  const Enums_1 = require("../Enums");
5
5
  const MultiOptionsVersionedSchemas_1 = require("../MultiOptionsVersioned/MultiOptionsVersionedSchemas");
6
6
  const OptionsVersionedSchemas_1 = require("../OptionsVersioned/OptionsVersionedSchemas");
7
- const UnifiedOptionsSchemaV1_1 = require("../UnifiedOptionsVersioned/UnifiedOptionsSchemaV1");
7
+ const UnifiedOptionsSchemaV1_1 = require("./UnifiedOptionsSchemaV1");
8
+ const UnifiedOptionsSchemaV2_1 = require("./UnifiedOptionsSchemaV2");
8
9
  /**
9
10
  * Adds a prefix to all version strings in a versioned schema array.
10
11
  */
@@ -30,4 +31,9 @@ exports.allVersionedSchemas = [
30
31
  schema: UnifiedOptionsSchemaV1_1.unifiedOptionsSchemaV1,
31
32
  type: Enums_1.EVersionedSchemaType.UNIFIED_OPTIONS,
32
33
  },
34
+ {
35
+ version: 'UNIFIED_v2',
36
+ schema: UnifiedOptionsSchemaV2_1.unifiedOptionsSchemaV2,
37
+ type: Enums_1.EVersionedSchemaType.UNIFIED_OPTIONS,
38
+ }
33
39
  ];
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UnifiedOptionsSchemaV1.d.ts","sourceRoot":"","sources":["../../../../src/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV1.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,KAAK,CAAC;AAqBtB;;;GAGG;AACH,eAAO,MAAM,sBAAsB,uBA6BZ,CAAC"}
@@ -5,12 +5,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.unifiedOptionsSchemaV1 = void 0;
7
7
  const joi_1 = __importDefault(require("joi"));
8
- const core_1 = require("../../../core");
8
+ const HttpClient_enum_1 = require("../../../core/types/enums/HttpClient.enum");
9
9
  const CommonSchemas_1 = require("../CommonSchemas");
10
10
  const mergeObjectSchemas_1 = require("../Utils/mergeObjectSchemas");
11
11
  const itemSchema = (0, mergeObjectSchemas_1.mergeObjectSchemas)(joi_1.default.object({
12
12
  input: joi_1.default.string().required().description('Путь, URL или строка OpenAPI спецификации'),
13
- httpClient: joi_1.default.string().valid(...Object.values(core_1.HttpClient)).optional(),
13
+ httpClient: joi_1.default.string().valid(...Object.values(HttpClient_enum_1.HttpClient)).optional(),
14
14
  }), CommonSchemas_1.outputPathsSchema, CommonSchemas_1.additionalParametersSchemaV2, CommonSchemas_1.experimentalParametersSchemaV2);
15
15
  /**
16
16
  * Unified options schema that supports both single and multi-item configurations.
@@ -0,0 +1,7 @@
1
+ import Joi from 'joi';
2
+ /**
3
+ * Unified options schema that supports both single and multi-item configurations.
4
+ * Use either 'items' array for multiple specs OR 'input'/'output' for single spec.
5
+ */
6
+ export declare const unifiedOptionsSchemaV2: Joi.ObjectSchema<any>;
7
+ //# sourceMappingURL=UnifiedOptionsSchemaV2.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UnifiedOptionsSchemaV2.d.ts","sourceRoot":"","sources":["../../../../src/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV2.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,KAAK,CAAC;AAqBtB;;;GAGG;AACH,eAAO,MAAM,sBAAsB,uBA6BZ,CAAC"}
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.unifiedOptionsSchemaV2 = void 0;
7
+ const joi_1 = __importDefault(require("joi"));
8
+ const HttpClient_enum_1 = require("../../../core/types/enums/HttpClient.enum");
9
+ const CommonSchemas_1 = require("../CommonSchemas");
10
+ const mergeObjectSchemas_1 = require("../Utils/mergeObjectSchemas");
11
+ const itemSchema = (0, mergeObjectSchemas_1.mergeObjectSchemas)(joi_1.default.object({
12
+ input: joi_1.default.string().required().description('Путь, URL или строка OpenAPI спецификации'),
13
+ httpClient: joi_1.default.string().valid(...Object.values(HttpClient_enum_1.HttpClient)).optional(),
14
+ }), CommonSchemas_1.outputPathsSchema, CommonSchemas_1.additionalParametersSchemaV2, CommonSchemas_1.experimentalParametersSchemaV2);
15
+ /**
16
+ * Unified options schema that supports both single and multi-item configurations.
17
+ * Use either 'items' array for multiple specs OR 'input'/'output' for single spec.
18
+ */
19
+ exports.unifiedOptionsSchemaV2 = (0, mergeObjectSchemas_1.mergeObjectSchemas)(joi_1.default.object({
20
+ // Multi-item configuration
21
+ items: joi_1.default.array()
22
+ .items(itemSchema)
23
+ .min(1)
24
+ .optional()
25
+ .description('Массив спецификаций для генерации'),
26
+ // Single-item configuration (mutually exclusive with items)
27
+ input: joi_1.default.string()
28
+ .when('items', {
29
+ is: joi_1.default.exist(),
30
+ then: joi_1.default.forbidden(),
31
+ otherwise: joi_1.default.required(),
32
+ })
33
+ .description('Путь, URL или строка OpenAPI спецификации'),
34
+ output: joi_1.default.string()
35
+ .when('items', {
36
+ is: joi_1.default.exist(),
37
+ then: joi_1.default.forbidden(),
38
+ otherwise: joi_1.default.required(),
39
+ })
40
+ .description('Выходная директория'),
41
+ }), CommonSchemas_1.outputPathsSchema, // outputCore, outputServices, etc. for single-item mode
42
+ CommonSchemas_1.specialParametersSchemasV3, CommonSchemas_1.additionalParametersSchemaV2, CommonSchemas_1.experimentalParametersSchemaV2).xor('items', 'input');
@@ -11,6 +11,7 @@ export declare const specialParametersSchemas: Joi.ObjectSchema<any>;
11
11
  * The scheme of the "accessibility" parameter set.
12
12
  */
13
13
  export declare const specialParametersSchemasV2: Joi.ObjectSchema<any>;
14
+ export declare const specialParametersSchemasV3: Joi.ObjectSchema<any>;
14
15
  /**
15
16
  * The scheme of additional parameters.
16
17
  */
@@ -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,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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;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: {
@@ -51,6 +56,8 @@ const WriteClient_1 = require("../WriteClient");
51
56
  request: () => 'request',
52
57
  cancelablePromise: () => 'cancelablePromise',
53
58
  httpStatusCode: () => 'httpStatusCode',
59
+ legacyRequestAdapter: () => 'legacyRequestAdapter',
60
+ requestExecutor: () => 'requestExecutor',
54
61
  },
55
62
  };
56
63
  const outputPaths = (0, getOutputPaths_1.getOutputPaths)({ output: './dist' });
@@ -62,7 +69,7 @@ const WriteClient_1 = require("../WriteClient");
62
69
  useOptions: false,
63
70
  useUnionTypes: false,
64
71
  excludeCoreServiceFiles: false,
65
- includeSchemasFiles: false,
72
+ validationLibrary: ValidationLibrary_enum_1.ValidationLibrary.NONE,
66
73
  });
67
74
  strict_1.default.ok(mkdirCalls.length > 0, 'mkdir should be called at least once');
68
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 = {}));
@@ -0,0 +1,3 @@
1
+ import { Templates } from '../registerHandlebarTemplates';
2
+ export declare const templates: Templates;
3
+ //# sourceMappingURL=templates.d.ts.map
@@ -0,0 +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,SA6BvB,CAAC"}