@kubb/plugin-oas 3.16.2 → 3.16.4

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 (110) hide show
  1. package/dist/Oas-CuqAnIw-.js +60 -0
  2. package/dist/Oas-CuqAnIw-.js.map +1 -0
  3. package/dist/Oas-Cv_pyXRM.cjs +78 -0
  4. package/dist/Oas-Cv_pyXRM.cjs.map +1 -0
  5. package/dist/OperationGenerator-CgbXErhW.d.cts +900 -0
  6. package/dist/OperationGenerator-OtLcGk2y.d.ts +900 -0
  7. package/dist/Schema-DJshqHto.d.cts +38 -0
  8. package/dist/Schema-DOXGUW1m.d.ts +38 -0
  9. package/dist/SchemaGenerator-8205BXCp.cjs +942 -0
  10. package/dist/SchemaGenerator-8205BXCp.cjs.map +1 -0
  11. package/dist/SchemaGenerator-B8Io6kky.js +930 -0
  12. package/dist/SchemaGenerator-B8Io6kky.js.map +1 -0
  13. package/dist/SchemaMapper-BaZQKrQB.js +54 -0
  14. package/dist/SchemaMapper-BaZQKrQB.js.map +1 -0
  15. package/dist/SchemaMapper-BiagBQN4.d.cts +388 -0
  16. package/dist/SchemaMapper-C2J2d3o4.d.ts +388 -0
  17. package/dist/SchemaMapper-D8J0V9Pj.cjs +66 -0
  18. package/dist/SchemaMapper-D8J0V9Pj.cjs.map +1 -0
  19. package/dist/chunk-CUT6urMc.cjs +30 -0
  20. package/dist/components.cjs +4 -19
  21. package/dist/components.d.cts +42 -35
  22. package/dist/components.d.ts +42 -35
  23. package/dist/components.js +3 -3
  24. package/dist/generators-BhLMlRNk.js +137 -0
  25. package/dist/generators-BhLMlRNk.js.map +1 -0
  26. package/dist/generators-DLH2kvlh.cjs +155 -0
  27. package/dist/generators-DLH2kvlh.cjs.map +1 -0
  28. package/dist/generators.cjs +4 -13
  29. package/dist/generators.d.cts +5 -7
  30. package/dist/generators.d.ts +5 -7
  31. package/dist/generators.js +5 -5
  32. package/dist/getFooter-BChY2kC1.cjs +43 -0
  33. package/dist/getFooter-BChY2kC1.cjs.map +1 -0
  34. package/dist/getFooter-T7_pZ6f8.js +31 -0
  35. package/dist/getFooter-T7_pZ6f8.js.map +1 -0
  36. package/dist/getSchemas-D8mP129c.cjs +67 -0
  37. package/dist/getSchemas-D8mP129c.cjs.map +1 -0
  38. package/dist/getSchemas-WoSBIxG8.js +55 -0
  39. package/dist/getSchemas-WoSBIxG8.js.map +1 -0
  40. package/dist/hooks.cjs +213 -195
  41. package/dist/hooks.cjs.map +1 -1
  42. package/dist/hooks.d.cts +91 -86
  43. package/dist/hooks.d.ts +91 -86
  44. package/dist/hooks.js +212 -193
  45. package/dist/hooks.js.map +1 -1
  46. package/dist/index.cjs +280 -342
  47. package/dist/index.cjs.map +1 -1
  48. package/dist/index.d.cts +7 -10
  49. package/dist/index.d.ts +7 -10
  50. package/dist/index.js +274 -318
  51. package/dist/index.js.map +1 -1
  52. package/dist/mocks.cjs +802 -737
  53. package/dist/mocks.cjs.map +1 -1
  54. package/dist/mocks.d.cts +12 -11
  55. package/dist/mocks.d.ts +12 -11
  56. package/dist/mocks.js +802 -735
  57. package/dist/mocks.js.map +1 -1
  58. package/dist/parseFromConfig-CMNGsef2.cjs +33 -0
  59. package/dist/parseFromConfig-CMNGsef2.cjs.map +1 -0
  60. package/dist/parseFromConfig-yAiFK03V.js +27 -0
  61. package/dist/parseFromConfig-yAiFK03V.js.map +1 -0
  62. package/dist/utils.cjs +58 -74
  63. package/dist/utils.cjs.map +1 -1
  64. package/dist/utils.d.cts +96 -42
  65. package/dist/utils.d.ts +96 -42
  66. package/dist/utils.js +47 -46
  67. package/dist/utils.js.map +1 -1
  68. package/package.json +26 -34
  69. package/src/components/Operation.tsx +1 -2
  70. package/src/mocks/schemas.ts +39 -0
  71. package/src/utils/getBanner.ts +5 -5
  72. package/src/utils/getFooter.ts +4 -4
  73. package/dist/OperationGenerator-C7NPZtOM.d.ts +0 -288
  74. package/dist/OperationGenerator-DJE2XQ83.d.cts +0 -288
  75. package/dist/Schema-AjebpeVY.d.ts +0 -32
  76. package/dist/Schema-M6983FL1.d.cts +0 -32
  77. package/dist/SchemaMapper-B21ZmWag.d.cts +0 -275
  78. package/dist/SchemaMapper-B21ZmWag.d.ts +0 -275
  79. package/dist/chunk-6S7YFY6F.js +0 -33
  80. package/dist/chunk-6S7YFY6F.js.map +0 -1
  81. package/dist/chunk-76E35IZ2.js +0 -56
  82. package/dist/chunk-76E35IZ2.js.map +0 -1
  83. package/dist/chunk-7RFNM43R.cjs +0 -41
  84. package/dist/chunk-7RFNM43R.cjs.map +0 -1
  85. package/dist/chunk-DTD4ZUDA.cjs +0 -36
  86. package/dist/chunk-DTD4ZUDA.cjs.map +0 -1
  87. package/dist/chunk-G3FDK7YW.js +0 -35
  88. package/dist/chunk-G3FDK7YW.js.map +0 -1
  89. package/dist/chunk-JNN4JPWK.js +0 -28
  90. package/dist/chunk-JNN4JPWK.js.map +0 -1
  91. package/dist/chunk-MBX66JAT.js +0 -93
  92. package/dist/chunk-MBX66JAT.js.map +0 -1
  93. package/dist/chunk-NC5PWNEF.js +0 -866
  94. package/dist/chunk-NC5PWNEF.js.map +0 -1
  95. package/dist/chunk-PORSNYI5.js +0 -47
  96. package/dist/chunk-PORSNYI5.js.map +0 -1
  97. package/dist/chunk-QJMOOF2A.cjs +0 -97
  98. package/dist/chunk-QJMOOF2A.cjs.map +0 -1
  99. package/dist/chunk-RKHCI3WI.cjs +0 -1002
  100. package/dist/chunk-RKHCI3WI.cjs.map +0 -1
  101. package/dist/chunk-YWMMI3MO.cjs +0 -59
  102. package/dist/chunk-YWMMI3MO.cjs.map +0 -1
  103. package/dist/chunk-Z2NREI4X.cjs +0 -32
  104. package/dist/chunk-Z2NREI4X.cjs.map +0 -1
  105. package/dist/chunk-ZVFL3NXX.cjs +0 -50
  106. package/dist/chunk-ZVFL3NXX.cjs.map +0 -1
  107. package/dist/components.cjs.map +0 -1
  108. package/dist/components.js.map +0 -1
  109. package/dist/generators.cjs.map +0 -1
  110. package/dist/generators.js.map +0 -1
package/dist/index.cjs CHANGED
@@ -1,350 +1,288 @@
1
- 'use strict';
1
+ const require_chunk = require('./chunk-CUT6urMc.cjs');
2
+ const require_SchemaGenerator = require('./SchemaGenerator-8205BXCp.cjs');
3
+ require('./Oas-Cv_pyXRM.cjs');
4
+ const require_generators = require('./generators-DLH2kvlh.cjs');
5
+ require('./getFooter-BChY2kC1.cjs');
6
+ const require_SchemaMapper = require('./SchemaMapper-D8J0V9Pj.cjs');
7
+ require('./getSchemas-D8mP129c.cjs');
8
+ const require_parseFromConfig = require('./parseFromConfig-CMNGsef2.cjs');
9
+ const __kubb_core = require_chunk.__toESM(require("@kubb/core"));
10
+ const __kubb_core_transformers = require_chunk.__toESM(require("@kubb/core/transformers"));
11
+ const node_path = require_chunk.__toESM(require("node:path"));
2
12
 
3
- var chunk7RFNM43R_cjs = require('./chunk-7RFNM43R.cjs');
4
- var chunkQJMOOF2A_cjs = require('./chunk-QJMOOF2A.cjs');
5
- require('./chunk-DTD4ZUDA.cjs');
6
- var chunkRKHCI3WI_cjs = require('./chunk-RKHCI3WI.cjs');
7
- var chunkYWMMI3MO_cjs = require('./chunk-YWMMI3MO.cjs');
8
- require('./chunk-ZVFL3NXX.cjs');
9
- require('./chunk-Z2NREI4X.cjs');
10
- var core = require('@kubb/core');
11
- var transformers = require('@kubb/core/transformers');
12
- var path = require('path');
13
-
14
- function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
15
-
16
- var transformers__default = /*#__PURE__*/_interopDefault(transformers);
17
- var path__default = /*#__PURE__*/_interopDefault(path);
18
-
19
- var OperationGenerator = class extends core.BaseGenerator {
20
- #getOptions(operation, method) {
21
- const { override = [] } = this.context;
22
- const operationId = operation.getOperationId({ friendlyCase: true });
23
- const contentType = operation.getContentType();
24
- return override.find(({ pattern, type }) => {
25
- switch (type) {
26
- case "tag":
27
- return operation.getTags().some((tag) => tag.name.match(pattern));
28
- case "operationId":
29
- return !!operationId.match(pattern);
30
- case "path":
31
- return !!operation.path.match(pattern);
32
- case "method":
33
- return !!method.match(pattern);
34
- case "contentType":
35
- return !!contentType.match(pattern);
36
- default:
37
- return false;
38
- }
39
- })?.options || {};
40
- }
41
- #isExcluded(operation, method) {
42
- const { exclude = [] } = this.context;
43
- const operationId = operation.getOperationId({ friendlyCase: true });
44
- const contentType = operation.getContentType();
45
- return exclude.some(({ pattern, type }) => {
46
- switch (type) {
47
- case "tag":
48
- return operation.getTags().some((tag) => tag.name.match(pattern));
49
- case "operationId":
50
- return !!operationId.match(pattern);
51
- case "path":
52
- return !!operation.path.match(pattern);
53
- case "method":
54
- return !!method.match(pattern);
55
- case "contentType":
56
- return !!contentType.match(pattern);
57
- default:
58
- return false;
59
- }
60
- });
61
- }
62
- #isIncluded(operation, method) {
63
- const { include = [] } = this.context;
64
- const operationId = operation.getOperationId({ friendlyCase: true });
65
- const contentType = operation.getContentType();
66
- return include.some(({ pattern, type }) => {
67
- switch (type) {
68
- case "tag":
69
- return operation.getTags().some((tag) => tag.name.match(pattern));
70
- case "operationId":
71
- return !!operationId.match(pattern);
72
- case "path":
73
- return !!operation.path.match(pattern);
74
- case "method":
75
- return !!method.match(pattern);
76
- case "contentType":
77
- return !!contentType.match(pattern);
78
- default:
79
- return false;
80
- }
81
- });
82
- }
83
- getSchemas(operation, {
84
- resolveName = (name) => name
85
- } = {}) {
86
- const operationId = operation.getOperationId({ friendlyCase: true });
87
- const method = operation.method;
88
- const operationName = transformers__default.default.pascalCase(operationId);
89
- const resolveKeys = (schema) => schema?.properties ? Object.keys(schema.properties) : void 0;
90
- const pathParamsSchema = this.context.oas.getParametersSchema(operation, "path");
91
- const queryParamsSchema = this.context.oas.getParametersSchema(operation, "query");
92
- const headerParamsSchema = this.context.oas.getParametersSchema(operation, "header");
93
- const requestSchema = this.context.oas.getRequestSchema(operation);
94
- const statusCodes = operation.getResponseStatusCodes().map((statusCode) => {
95
- const name = statusCode === "default" ? "error" : statusCode;
96
- const schema = this.context.oas.getResponseSchema(operation, statusCode);
97
- const keys = resolveKeys(schema);
98
- return {
99
- name: resolveName(transformers__default.default.pascalCase(`${operationId} ${name}`)),
100
- description: operation.getResponseByStatusCode(statusCode)?.description,
101
- schema,
102
- operation,
103
- operationName,
104
- statusCode: name === "error" ? void 0 : Number(statusCode),
105
- keys,
106
- keysToOmit: keys?.filter((key) => schema?.properties?.[key]?.writeOnly)
107
- };
108
- });
109
- const successful = statusCodes.filter((item) => item.statusCode?.toString().startsWith("2"));
110
- const errors = statusCodes.filter((item) => item.statusCode?.toString().startsWith("4") || item.statusCode?.toString().startsWith("5"));
111
- return {
112
- pathParams: pathParamsSchema ? {
113
- name: resolveName(transformers__default.default.pascalCase(`${operationId} PathParams`)),
114
- operation,
115
- operationName,
116
- schema: pathParamsSchema,
117
- keys: resolveKeys(pathParamsSchema)
118
- } : void 0,
119
- queryParams: queryParamsSchema ? {
120
- name: resolveName(transformers__default.default.pascalCase(`${operationId} QueryParams`)),
121
- operation,
122
- operationName,
123
- schema: queryParamsSchema,
124
- keys: resolveKeys(queryParamsSchema) || []
125
- } : void 0,
126
- headerParams: headerParamsSchema ? {
127
- name: resolveName(transformers__default.default.pascalCase(`${operationId} HeaderParams`)),
128
- operation,
129
- operationName,
130
- schema: headerParamsSchema,
131
- keys: resolveKeys(headerParamsSchema)
132
- } : void 0,
133
- request: requestSchema ? {
134
- name: resolveName(transformers__default.default.pascalCase(`${operationId} ${method === "get" ? "queryRequest" : "mutationRequest"}`)),
135
- description: operation.schema.requestBody?.description,
136
- operation,
137
- operationName,
138
- schema: requestSchema,
139
- keys: resolveKeys(requestSchema),
140
- keysToOmit: resolveKeys(requestSchema)?.filter((key) => requestSchema.properties?.[key]?.readOnly)
141
- } : void 0,
142
- response: {
143
- name: resolveName(transformers__default.default.pascalCase(`${operationId} ${method === "get" ? "queryResponse" : "mutationResponse"}`)),
144
- operation,
145
- operationName,
146
- schema: {
147
- oneOf: successful.map((item) => ({ ...item.schema, $ref: item.name })) || void 0
148
- }
149
- },
150
- responses: successful,
151
- errors,
152
- statusCodes
153
- };
154
- }
155
- async getOperations() {
156
- const { oas } = this.context;
157
- const paths = oas.getPaths();
158
- return Object.entries(paths).flatMap(
159
- ([path2, methods]) => Object.entries(methods).map((values) => {
160
- const [method, operation] = values;
161
- if (this.#isExcluded(operation, method)) {
162
- return null;
163
- }
164
- if (this.context.include && !this.#isIncluded(operation, method)) {
165
- return null;
166
- }
167
- return operation ? { path: path2, method, operation } : null;
168
- }).filter(Boolean)
169
- );
170
- }
171
- async build(...generators) {
172
- const operations = await this.getOperations();
173
- const generatorLimit = chunkRKHCI3WI_cjs.pLimit(1);
174
- const operationLimit = chunkRKHCI3WI_cjs.pLimit(10);
175
- const writeTasks = generators.map(
176
- (generator) => generatorLimit(async () => {
177
- const operationTasks = operations.map(
178
- ({ operation, method }) => operationLimit(async () => {
179
- const options = this.#getOptions(operation, method);
180
- const result = await generator.operation?.({
181
- instance: this,
182
- operation,
183
- options: { ...this.options, ...options }
184
- });
185
- return result ?? [];
186
- })
187
- );
188
- const operationResults = await Promise.all(operationTasks);
189
- const opResultsFlat = operationResults.flat();
190
- const operationsResult = await generator.operations?.({
191
- instance: this,
192
- operations: operations.map((op) => op.operation),
193
- options: this.options
194
- });
195
- return [...opResultsFlat, ...operationsResult ?? []];
196
- })
197
- );
198
- const nestedResults = await Promise.all(writeTasks);
199
- return nestedResults.flat();
200
- }
13
+ //#region src/OperationGenerator.ts
14
+ var OperationGenerator = class extends __kubb_core.BaseGenerator {
15
+ #getOptions(operation, method) {
16
+ const { override = [] } = this.context;
17
+ const operationId = operation.getOperationId({ friendlyCase: true });
18
+ const contentType = operation.getContentType();
19
+ return override.find(({ pattern, type }) => {
20
+ switch (type) {
21
+ case "tag": return operation.getTags().some((tag) => tag.name.match(pattern));
22
+ case "operationId": return !!operationId.match(pattern);
23
+ case "path": return !!operation.path.match(pattern);
24
+ case "method": return !!method.match(pattern);
25
+ case "contentType": return !!contentType.match(pattern);
26
+ default: return false;
27
+ }
28
+ })?.options || {};
29
+ }
30
+ #isExcluded(operation, method) {
31
+ const { exclude = [] } = this.context;
32
+ const operationId = operation.getOperationId({ friendlyCase: true });
33
+ const contentType = operation.getContentType();
34
+ return exclude.some(({ pattern, type }) => {
35
+ switch (type) {
36
+ case "tag": return operation.getTags().some((tag) => tag.name.match(pattern));
37
+ case "operationId": return !!operationId.match(pattern);
38
+ case "path": return !!operation.path.match(pattern);
39
+ case "method": return !!method.match(pattern);
40
+ case "contentType": return !!contentType.match(pattern);
41
+ default: return false;
42
+ }
43
+ });
44
+ }
45
+ #isIncluded(operation, method) {
46
+ const { include = [] } = this.context;
47
+ const operationId = operation.getOperationId({ friendlyCase: true });
48
+ const contentType = operation.getContentType();
49
+ return include.some(({ pattern, type }) => {
50
+ switch (type) {
51
+ case "tag": return operation.getTags().some((tag) => tag.name.match(pattern));
52
+ case "operationId": return !!operationId.match(pattern);
53
+ case "path": return !!operation.path.match(pattern);
54
+ case "method": return !!method.match(pattern);
55
+ case "contentType": return !!contentType.match(pattern);
56
+ default: return false;
57
+ }
58
+ });
59
+ }
60
+ getSchemas(operation, { resolveName = (name) => name } = {}) {
61
+ const operationId = operation.getOperationId({ friendlyCase: true });
62
+ const method = operation.method;
63
+ const operationName = __kubb_core_transformers.default.pascalCase(operationId);
64
+ const resolveKeys = (schema) => schema?.properties ? Object.keys(schema.properties) : void 0;
65
+ const pathParamsSchema = this.context.oas.getParametersSchema(operation, "path");
66
+ const queryParamsSchema = this.context.oas.getParametersSchema(operation, "query");
67
+ const headerParamsSchema = this.context.oas.getParametersSchema(operation, "header");
68
+ const requestSchema = this.context.oas.getRequestSchema(operation);
69
+ const statusCodes = operation.getResponseStatusCodes().map((statusCode) => {
70
+ const name = statusCode === "default" ? "error" : statusCode;
71
+ const schema = this.context.oas.getResponseSchema(operation, statusCode);
72
+ const keys = resolveKeys(schema);
73
+ return {
74
+ name: resolveName(__kubb_core_transformers.default.pascalCase(`${operationId} ${name}`)),
75
+ description: operation.getResponseByStatusCode(statusCode)?.description,
76
+ schema,
77
+ operation,
78
+ operationName,
79
+ statusCode: name === "error" ? void 0 : Number(statusCode),
80
+ keys,
81
+ keysToOmit: keys?.filter((key) => (schema?.properties?.[key])?.writeOnly)
82
+ };
83
+ });
84
+ const successful = statusCodes.filter((item) => item.statusCode?.toString().startsWith("2"));
85
+ const errors = statusCodes.filter((item) => item.statusCode?.toString().startsWith("4") || item.statusCode?.toString().startsWith("5"));
86
+ return {
87
+ pathParams: pathParamsSchema ? {
88
+ name: resolveName(__kubb_core_transformers.default.pascalCase(`${operationId} PathParams`)),
89
+ operation,
90
+ operationName,
91
+ schema: pathParamsSchema,
92
+ keys: resolveKeys(pathParamsSchema)
93
+ } : void 0,
94
+ queryParams: queryParamsSchema ? {
95
+ name: resolveName(__kubb_core_transformers.default.pascalCase(`${operationId} QueryParams`)),
96
+ operation,
97
+ operationName,
98
+ schema: queryParamsSchema,
99
+ keys: resolveKeys(queryParamsSchema) || []
100
+ } : void 0,
101
+ headerParams: headerParamsSchema ? {
102
+ name: resolveName(__kubb_core_transformers.default.pascalCase(`${operationId} HeaderParams`)),
103
+ operation,
104
+ operationName,
105
+ schema: headerParamsSchema,
106
+ keys: resolveKeys(headerParamsSchema)
107
+ } : void 0,
108
+ request: requestSchema ? {
109
+ name: resolveName(__kubb_core_transformers.default.pascalCase(`${operationId} ${method === "get" ? "queryRequest" : "mutationRequest"}`)),
110
+ description: operation.schema.requestBody?.description,
111
+ operation,
112
+ operationName,
113
+ schema: requestSchema,
114
+ keys: resolveKeys(requestSchema),
115
+ keysToOmit: resolveKeys(requestSchema)?.filter((key) => (requestSchema.properties?.[key])?.readOnly)
116
+ } : void 0,
117
+ response: {
118
+ name: resolveName(__kubb_core_transformers.default.pascalCase(`${operationId} ${method === "get" ? "queryResponse" : "mutationResponse"}`)),
119
+ operation,
120
+ operationName,
121
+ schema: { oneOf: successful.map((item) => ({
122
+ ...item.schema,
123
+ $ref: item.name
124
+ })) || void 0 }
125
+ },
126
+ responses: successful,
127
+ errors,
128
+ statusCodes
129
+ };
130
+ }
131
+ async getOperations() {
132
+ const { oas } = this.context;
133
+ const paths = oas.getPaths();
134
+ return Object.entries(paths).flatMap(([path$1, methods]) => Object.entries(methods).map((values) => {
135
+ const [method, operation] = values;
136
+ if (this.#isExcluded(operation, method)) return null;
137
+ if (this.context.include && !this.#isIncluded(operation, method)) return null;
138
+ return operation ? {
139
+ path: path$1,
140
+ method,
141
+ operation
142
+ } : null;
143
+ }).filter(Boolean));
144
+ }
145
+ async build(...generators) {
146
+ const operations = await this.getOperations();
147
+ const generatorLimit = require_SchemaGenerator.pLimit(1);
148
+ const operationLimit = require_SchemaGenerator.pLimit(10);
149
+ const writeTasks = generators.map((generator) => generatorLimit(async () => {
150
+ const operationTasks = operations.map(({ operation, method }) => operationLimit(async () => {
151
+ const options = this.#getOptions(operation, method);
152
+ const result = await generator.operation?.({
153
+ instance: this,
154
+ operation,
155
+ options: {
156
+ ...this.options,
157
+ ...options
158
+ }
159
+ });
160
+ return result ?? [];
161
+ }));
162
+ const operationResults = await Promise.all(operationTasks);
163
+ const opResultsFlat = operationResults.flat();
164
+ const operationsResult = await generator.operations?.({
165
+ instance: this,
166
+ operations: operations.map((op) => op.operation),
167
+ options: this.options
168
+ });
169
+ return [...opResultsFlat, ...operationsResult ?? []];
170
+ }));
171
+ const nestedResults = await Promise.all(writeTasks);
172
+ return nestedResults.flat();
173
+ }
201
174
  };
202
- var pluginOasName = "plugin-oas";
203
- var pluginOas = core.createPlugin((options) => {
204
- const {
205
- output = {
206
- path: "schemas"
207
- },
208
- group,
209
- validate = true,
210
- generators = [chunkQJMOOF2A_cjs.jsonGenerator],
211
- serverIndex,
212
- contentType,
213
- oasClass,
214
- discriminator = "strict"
215
- } = options;
216
- let oas;
217
- const getOas = async ({ config, logger }) => {
218
- oas = await chunk7RFNM43R_cjs.parseFromConfig(config, oasClass);
219
- oas.setOptions({
220
- contentType,
221
- discriminator
222
- });
223
- try {
224
- if (validate) {
225
- await oas.valdiate();
226
- }
227
- } catch (e) {
228
- const error = e;
229
- logger.emit("warning", error?.message);
230
- }
231
- return oas;
232
- };
233
- return {
234
- name: pluginOasName,
235
- options: {
236
- output,
237
- validate,
238
- discriminator,
239
- ...options
240
- },
241
- context() {
242
- const { config, logger } = this;
243
- return {
244
- getOas() {
245
- return getOas({ config, logger });
246
- },
247
- async getBaseURL() {
248
- const oasInstance = await this.getOas();
249
- if (serverIndex) {
250
- return oasInstance.api.servers?.at(serverIndex)?.url;
251
- }
252
- return void 0;
253
- }
254
- };
255
- },
256
- resolvePath(baseName, pathMode, options2) {
257
- const root = path__default.default.resolve(this.config.root, this.config.output.path);
258
- const mode = pathMode ?? core.FileManager.getMode(path__default.default.resolve(root, output.path));
259
- if (mode === "single") {
260
- return path__default.default.resolve(root, output.path);
261
- }
262
- if (group && (options2?.group?.path || options2?.group?.tag)) {
263
- const groupName = group?.name ? group.name : (ctx) => {
264
- if (group?.type === "path") {
265
- return `${ctx.group.split("/")[1]}`;
266
- }
267
- return `${transformers.camelCase(ctx.group)}Controller`;
268
- };
269
- return path__default.default.resolve(
270
- root,
271
- output.path,
272
- groupName({
273
- group: group.type === "path" ? options2.group.path : options2.group.tag
274
- }),
275
- baseName
276
- );
277
- }
278
- return path__default.default.resolve(root, output.path, baseName);
279
- },
280
- async buildStart() {
281
- if (!output) {
282
- return;
283
- }
284
- const oas2 = await getOas({
285
- config: this.config,
286
- logger: this.logger
287
- });
288
- await oas2.dereference();
289
- const schemaGenerator = new chunkRKHCI3WI_cjs.SchemaGenerator(
290
- {
291
- unknownType: "unknown",
292
- emptySchemaType: "unknown",
293
- dateType: "date",
294
- transformers: {},
295
- ...this.plugin.options
296
- },
297
- {
298
- oas: oas2,
299
- pluginManager: this.pluginManager,
300
- plugin: this.plugin,
301
- contentType,
302
- include: void 0,
303
- override: void 0,
304
- mode: "split",
305
- output: output.path
306
- }
307
- );
308
- const schemaFiles = await schemaGenerator.build(...generators);
309
- await this.addFile(...schemaFiles);
310
- const operationGenerator = new OperationGenerator(this.plugin.options, {
311
- oas: oas2,
312
- pluginManager: this.pluginManager,
313
- plugin: this.plugin,
314
- contentType,
315
- exclude: void 0,
316
- include: void 0,
317
- override: void 0,
318
- mode: "split"
319
- });
320
- const operationFiles = await operationGenerator.build(...generators);
321
- await this.addFile(...operationFiles);
322
- }
323
- };
324
- });
325
175
 
326
- Object.defineProperty(exports, "createGenerator", {
327
- enumerable: true,
328
- get: function () { return chunkQJMOOF2A_cjs.createGenerator; }
329
- });
330
- Object.defineProperty(exports, "createReactGenerator", {
331
- enumerable: true,
332
- get: function () { return chunkQJMOOF2A_cjs.createReactGenerator; }
333
- });
334
- Object.defineProperty(exports, "SchemaGenerator", {
335
- enumerable: true,
336
- get: function () { return chunkRKHCI3WI_cjs.SchemaGenerator; }
337
- });
338
- Object.defineProperty(exports, "isKeyword", {
339
- enumerable: true,
340
- get: function () { return chunkYWMMI3MO_cjs.isKeyword; }
341
- });
342
- Object.defineProperty(exports, "schemaKeywords", {
343
- enumerable: true,
344
- get: function () { return chunkYWMMI3MO_cjs.schemaKeywords; }
176
+ //#endregion
177
+ //#region src/plugin.ts
178
+ const pluginOasName = "plugin-oas";
179
+ const pluginOas = (0, __kubb_core.createPlugin)((options) => {
180
+ const { output = { path: "schemas" }, group, validate = true, generators = [require_generators.jsonGenerator], serverIndex, contentType, oasClass, discriminator = "strict" } = options;
181
+ let oas;
182
+ const getOas = async ({ config, logger }) => {
183
+ oas = await require_parseFromConfig.parseFromConfig(config, oasClass);
184
+ oas.setOptions({
185
+ contentType,
186
+ discriminator
187
+ });
188
+ try {
189
+ if (validate) await oas.valdiate();
190
+ } catch (e) {
191
+ const error = e;
192
+ logger.emit("warning", error?.message);
193
+ }
194
+ return oas;
195
+ };
196
+ return {
197
+ name: pluginOasName,
198
+ options: {
199
+ output,
200
+ validate,
201
+ discriminator,
202
+ ...options
203
+ },
204
+ context() {
205
+ const { config, logger } = this;
206
+ return {
207
+ getOas() {
208
+ return getOas({
209
+ config,
210
+ logger
211
+ });
212
+ },
213
+ async getBaseURL() {
214
+ const oasInstance = await this.getOas();
215
+ if (serverIndex) return oasInstance.api.servers?.at(serverIndex)?.url;
216
+ return void 0;
217
+ }
218
+ };
219
+ },
220
+ resolvePath(baseName, pathMode, options$1) {
221
+ const root = node_path.default.resolve(this.config.root, this.config.output.path);
222
+ const mode = pathMode ?? __kubb_core.FileManager.getMode(node_path.default.resolve(root, output.path));
223
+ if (mode === "single")
224
+ /**
225
+ * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend
226
+ * Other plugins then need to call addOrAppend instead of just add from the fileManager class
227
+ */
228
+ return node_path.default.resolve(root, output.path);
229
+ if (group && (options$1?.group?.path || options$1?.group?.tag)) {
230
+ const groupName = group?.name ? group.name : (ctx) => {
231
+ if (group?.type === "path") return `${ctx.group.split("/")[1]}`;
232
+ return `${(0, __kubb_core_transformers.camelCase)(ctx.group)}Controller`;
233
+ };
234
+ return node_path.default.resolve(root, output.path, groupName({ group: group.type === "path" ? options$1.group.path : options$1.group.tag }), baseName);
235
+ }
236
+ return node_path.default.resolve(root, output.path, baseName);
237
+ },
238
+ async buildStart() {
239
+ if (!output) return;
240
+ const oas$1 = await getOas({
241
+ config: this.config,
242
+ logger: this.logger
243
+ });
244
+ await oas$1.dereference();
245
+ const schemaGenerator = new require_SchemaGenerator.SchemaGenerator({
246
+ unknownType: "unknown",
247
+ emptySchemaType: "unknown",
248
+ dateType: "date",
249
+ transformers: {},
250
+ ...this.plugin.options
251
+ }, {
252
+ oas: oas$1,
253
+ pluginManager: this.pluginManager,
254
+ plugin: this.plugin,
255
+ contentType,
256
+ include: void 0,
257
+ override: void 0,
258
+ mode: "split",
259
+ output: output.path
260
+ });
261
+ const schemaFiles = await schemaGenerator.build(...generators);
262
+ await this.addFile(...schemaFiles);
263
+ const operationGenerator = new OperationGenerator(this.plugin.options, {
264
+ oas: oas$1,
265
+ pluginManager: this.pluginManager,
266
+ plugin: this.plugin,
267
+ contentType,
268
+ exclude: void 0,
269
+ include: void 0,
270
+ override: void 0,
271
+ mode: "split"
272
+ });
273
+ const operationFiles = await operationGenerator.build(...generators);
274
+ await this.addFile(...operationFiles);
275
+ }
276
+ };
345
277
  });
278
+
279
+ //#endregion
346
280
  exports.OperationGenerator = OperationGenerator;
281
+ exports.SchemaGenerator = require_SchemaGenerator.SchemaGenerator;
282
+ exports.createGenerator = require_generators.createGenerator;
283
+ exports.createReactGenerator = require_generators.createReactGenerator;
284
+ exports.isKeyword = require_SchemaMapper.isKeyword;
347
285
  exports.pluginOas = pluginOas;
348
286
  exports.pluginOasName = pluginOasName;
349
- //# sourceMappingURL=index.cjs.map
287
+ exports.schemaKeywords = require_SchemaMapper.schemaKeywords;
350
288
  //# sourceMappingURL=index.cjs.map