@kubb/plugin-oas 3.0.0-alpha.1 → 3.0.0-alpha.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/dist/OperationGenerator-By5WOmWB.d.ts +165 -0
  2. package/dist/OperationGenerator-Gd1X7wUz.d.cts +165 -0
  3. package/dist/{Schema-DefwBJMc.d.ts → Schema-B1vcPGiK.d.ts} +3 -5
  4. package/dist/{Schema-an5hOrjZ.d.cts → Schema-DoSFh7Qd.d.cts} +3 -5
  5. package/dist/{SchemaMapper-CsBQ6eEx.d.cts → SchemaMapper-sGcY1xL5.d.cts} +1 -2
  6. package/dist/{SchemaMapper-CsBQ6eEx.d.ts → SchemaMapper-sGcY1xL5.d.ts} +1 -2
  7. package/dist/{chunk-LEACSHKT.js → chunk-2X5GZFQP.js} +712 -44
  8. package/dist/chunk-2X5GZFQP.js.map +1 -0
  9. package/dist/{chunk-DRLYORTT.cjs → chunk-47SNBYWH.cjs} +750 -69
  10. package/dist/chunk-47SNBYWH.cjs.map +1 -0
  11. package/dist/{chunk-UB552H4J.js → chunk-4VKHSKYX.js} +7 -24
  12. package/dist/{chunk-UB552H4J.js.map → chunk-4VKHSKYX.js.map} +1 -1
  13. package/dist/{chunk-Y4V7HHX7.js → chunk-4WUMV7QX.js} +9 -12
  14. package/dist/chunk-4WUMV7QX.js.map +1 -0
  15. package/dist/chunk-6AVEWDKE.cjs +8 -0
  16. package/dist/chunk-6AVEWDKE.cjs.map +1 -0
  17. package/dist/chunk-S6RFFHLW.cjs +38 -0
  18. package/dist/chunk-S6RFFHLW.cjs.map +1 -0
  19. package/dist/chunk-WN5S6RCU.js +6 -0
  20. package/dist/chunk-WN5S6RCU.js.map +1 -0
  21. package/dist/chunk-XQPCA75E.cjs +90 -0
  22. package/dist/chunk-XQPCA75E.cjs.map +1 -0
  23. package/dist/components.cjs +21 -17
  24. package/dist/components.cjs.map +1 -1
  25. package/dist/components.d.cts +13 -7
  26. package/dist/components.d.ts +13 -7
  27. package/dist/components.js +4 -17
  28. package/dist/components.js.map +1 -1
  29. package/dist/hooks.cjs +30 -35
  30. package/dist/hooks.cjs.map +1 -1
  31. package/dist/hooks.d.cts +4 -4
  32. package/dist/hooks.d.ts +4 -4
  33. package/dist/hooks.js +10 -23
  34. package/dist/hooks.js.map +1 -1
  35. package/dist/index.cjs +315 -262
  36. package/dist/index.cjs.map +1 -1
  37. package/dist/index.d.cts +8 -77
  38. package/dist/index.d.ts +8 -77
  39. package/dist/index.js +270 -239
  40. package/dist/index.js.map +1 -1
  41. package/dist/{types-Dte3MA6H.d.cts → types-CZTUCaE5.d.cts} +3 -1
  42. package/dist/{types-Dte3MA6H.d.ts → types-CZTUCaE5.d.ts} +3 -1
  43. package/dist/utils.cjs +39 -73
  44. package/dist/utils.cjs.map +1 -1
  45. package/dist/utils.d.cts +7 -33
  46. package/dist/utils.d.ts +7 -33
  47. package/dist/utils.js +10 -67
  48. package/dist/utils.js.map +1 -1
  49. package/package.json +11 -10
  50. package/src/OperationGenerator.ts +68 -32
  51. package/src/SchemaGenerator.ts +32 -15
  52. package/src/SchemaMapper.ts +1 -1
  53. package/src/components/Oas.tsx +9 -3
  54. package/src/components/Operation.tsx +1 -1
  55. package/src/components/Schema.tsx +29 -31
  56. package/src/generator.tsx +125 -0
  57. package/src/hooks/useOperationManager.ts +1 -0
  58. package/src/index.ts +3 -9
  59. package/src/plugin.ts +25 -38
  60. package/src/types.ts +2 -0
  61. package/src/utils/getParams.ts +1 -1
  62. package/src/utils/index.ts +2 -1
  63. package/dist/OperationGenerator-CeM_9pxW.d.cts +0 -60
  64. package/dist/OperationGenerator-DhUhvRJE.d.ts +0 -60
  65. package/dist/chunk-CJXRFYEF.cjs +0 -698
  66. package/dist/chunk-CJXRFYEF.cjs.map +0 -1
  67. package/dist/chunk-DRLYORTT.cjs.map +0 -1
  68. package/dist/chunk-K6KUETAI.js +0 -698
  69. package/dist/chunk-K6KUETAI.js.map +0 -1
  70. package/dist/chunk-LEACSHKT.js.map +0 -1
  71. package/dist/chunk-P42X362U.cjs +0 -101
  72. package/dist/chunk-P42X362U.cjs.map +0 -1
  73. package/dist/chunk-QLJIL3U5.cjs +0 -35
  74. package/dist/chunk-QLJIL3U5.cjs.map +0 -1
  75. package/dist/chunk-Y4V7HHX7.js.map +0 -1
  76. package/src/utils/getGroupedByTagFiles.ts +0 -82
package/dist/index.js CHANGED
@@ -1,149 +1,94 @@
1
- import {
2
- parseFromConfig
3
- } from "./chunk-Y4V7HHX7.js";
4
- import {
5
- SchemaGenerator,
6
- isKeyword,
7
- schemaKeywords
8
- } from "./chunk-K6KUETAI.js";
9
- import {
10
- __privateAdd,
11
- __privateGet,
12
- __privateMethod,
13
- __privateSet,
14
- getSchemas,
15
- init_esm_shims
16
- } from "./chunk-UB552H4J.js";
1
+ import { parseFromConfig } from './chunk-4WUMV7QX.js';
2
+ import './chunk-WN5S6RCU.js';
3
+ import { require_jsx_runtime, Oas } from './chunk-2X5GZFQP.js';
4
+ export { SchemaGenerator, isKeyword, schemaKeywords } from './chunk-2X5GZFQP.js';
5
+ import { init_esm_shims, getSchemas, __toESM } from './chunk-4VKHSKYX.js';
6
+ import { createPlugin, BaseGenerator } from '@kubb/core';
7
+ import transformers, { camelCase } from '@kubb/core/transformers';
8
+ import path from 'node:path';
9
+ import { createRoot, App } from '@kubb/react';
17
10
 
18
11
  // src/index.ts
19
12
  init_esm_shims();
20
13
 
21
- // src/plugin.ts
14
+ // src/OperationGenerator.ts
22
15
  init_esm_shims();
23
- import path from "path";
24
- import { createPlugin } from "@kubb/core";
25
- import { camelCase } from "@kubb/core/transformers";
26
- var pluginOasName = "plugin-oas";
27
- var pluginOas = createPlugin((options) => {
28
- const {
29
- output = { path: "schemas", export: false },
30
- experimentalFilter: filter,
31
- experimentalSort: sort,
32
- validate = true,
33
- serverIndex = 0,
34
- contentType,
35
- oasClass
36
- } = options;
37
- const getOas = async ({ config, logger, formatOptions }) => {
38
- try {
39
- const oas = await parseFromConfig(config, formatOptions, oasClass);
40
- if (validate) {
41
- await oas.valdiate();
16
+ var OperationGenerator = class extends BaseGenerator {
17
+ #operationsByMethod = {};
18
+ get operationsByMethod() {
19
+ return this.#operationsByMethod;
20
+ }
21
+ set operationsByMethod(paths) {
22
+ this.#operationsByMethod = paths;
23
+ }
24
+ #getOptions(operation, method) {
25
+ const { override = [] } = this.context;
26
+ return override.find(({ pattern, type }) => {
27
+ if (type === "tag") {
28
+ return !!operation.getTags()[0]?.name.match(pattern);
42
29
  }
43
- return oas;
44
- } catch (e) {
45
- const error = e;
46
- logger.emit("warning", error?.message);
47
- return parseFromConfig(config, {}, oasClass);
48
- }
49
- };
50
- return {
51
- name: pluginOasName,
52
- options,
53
- api() {
54
- const { config, logger } = this;
55
- return {
56
- getOas(formatOptions) {
57
- return getOas({ config, logger, formatOptions });
58
- },
59
- async getSchemas({ includes } = {}) {
60
- const oas = await this.getOas();
61
- return getSchemas({ oas, contentType, includes });
62
- },
63
- async getBaseURL() {
64
- const oasInstance = await this.getOas();
65
- const baseURL = oasInstance.api.servers?.at(serverIndex)?.url;
66
- return baseURL;
67
- },
68
- contentType
69
- };
70
- },
71
- resolvePath(baseName) {
72
- if (output === false) {
73
- return void 0;
30
+ if (type === "operationId") {
31
+ return !!operation.getOperationId().match(pattern);
74
32
  }
75
- const root = path.resolve(this.config.root, this.config.output.path);
76
- return path.resolve(root, output.path, baseName);
77
- },
78
- resolveName(name, type) {
79
- return camelCase(name, { isFile: type === "file" });
80
- },
81
- async writeFile(path2, source) {
82
- if (!path2.endsWith(".json") || !source) {
83
- return;
33
+ if (type === "path") {
34
+ return !!operation.path.match(pattern);
84
35
  }
85
- return this.fileManager.write(path2, source, { sanity: false });
86
- },
87
- async buildStart() {
88
- if (!output) {
89
- return;
36
+ if (type === "method") {
37
+ return !!method.match(pattern);
90
38
  }
91
- const oas = await getOas({
92
- config: this.config,
93
- logger: this.logger,
94
- formatOptions: {
95
- filterSet: filter,
96
- sortSet: sort
97
- }
98
- });
99
- await oas.dereference();
100
- const schemas = getSchemas({ oas, contentType });
101
- const mapSchema = async ([name, schema]) => {
102
- const resolvedPath = this.resolvePath({
103
- baseName: `${name}.json`,
104
- pluginKey: this.plugin.key
105
- });
106
- const resvoledFileName = this.resolveName({
107
- name: `${name}.json`,
108
- pluginKey: [pluginOasName],
109
- type: "file"
110
- });
111
- if (!resolvedPath) {
112
- return;
113
- }
114
- await this.addFile({
115
- path: resolvedPath,
116
- baseName: resvoledFileName,
117
- source: JSON.stringify(schema),
118
- meta: {
119
- pluginKey: this.plugin.key
120
- }
121
- });
122
- };
123
- const promises = Object.entries(schemas).map(mapSchema);
124
- await Promise.all(promises);
125
- }
126
- };
127
- });
128
-
129
- // src/OperationGenerator.ts
130
- init_esm_shims();
131
- import { Generator } from "@kubb/core";
132
- import transformers from "@kubb/core/transformers";
133
- var _operationsByMethod, _OperationGenerator_instances, getOptions_fn, isExcluded_fn, isIncluded_fn, methods_get;
134
- var OperationGenerator = class extends Generator {
135
- constructor() {
136
- super(...arguments);
137
- __privateAdd(this, _OperationGenerator_instances);
138
- __privateAdd(this, _operationsByMethod, {});
39
+ return false;
40
+ })?.options || {};
139
41
  }
140
- get operationsByMethod() {
141
- return __privateGet(this, _operationsByMethod);
42
+ /**
43
+ *
44
+ * @deprecated
45
+ */
46
+ #isExcluded(operation, method) {
47
+ const { exclude = [] } = this.context;
48
+ let matched = false;
49
+ exclude.forEach(({ pattern, type }) => {
50
+ if (type === "tag" && !matched) {
51
+ matched = !!operation.getTags()[0]?.name.match(pattern);
52
+ }
53
+ if (type === "operationId" && !matched) {
54
+ matched = !!operation.getOperationId().match(pattern);
55
+ }
56
+ if (type === "path" && !matched) {
57
+ matched = !!operation.path.match(pattern);
58
+ }
59
+ if (type === "method" && !matched) {
60
+ matched = !!method.match(pattern);
61
+ }
62
+ });
63
+ return matched;
142
64
  }
143
- set operationsByMethod(paths) {
144
- __privateSet(this, _operationsByMethod, paths);
65
+ /**
66
+ *
67
+ * @deprecated
68
+ */
69
+ #isIncluded(operation, method) {
70
+ const { include = [] } = this.context;
71
+ let matched = false;
72
+ include.forEach(({ pattern, type }) => {
73
+ if (type === "tag" && !matched) {
74
+ matched = !!operation.getTags()[0]?.name.match(pattern);
75
+ }
76
+ if (type === "operationId" && !matched) {
77
+ matched = !!operation.getOperationId().match(pattern);
78
+ }
79
+ if (type === "path" && !matched) {
80
+ matched = !!operation.path.match(pattern);
81
+ }
82
+ if (type === "method" && !matched) {
83
+ matched = !!method.match(pattern);
84
+ }
85
+ });
86
+ return matched;
145
87
  }
146
- getSchemas(operation, { forStatusCode, resolveName = (name) => name } = {}) {
88
+ getSchemas(operation, {
89
+ forStatusCode,
90
+ resolveName = (name) => name
91
+ } = {}) {
147
92
  const pathParamsSchema = this.context.oas.getParametersSchema(operation, "path");
148
93
  const queryParamsSchema = this.context.oas.getParametersSchema(operation, "query");
149
94
  const headerParamsSchema = this.context.oas.getParametersSchema(operation, "header");
@@ -217,16 +162,17 @@ var OperationGenerator = class extends Generator {
217
162
  statusCodes
218
163
  };
219
164
  }
220
- async build() {
165
+ #methods = ["get", "post", "patch", "put", "delete"];
166
+ async build(...generators) {
221
167
  const { oas } = this.context;
222
168
  const paths = oas.getPaths();
223
169
  this.operationsByMethod = Object.entries(paths).reduce((acc, [path2, method]) => {
224
170
  const methods = Object.keys(method);
225
171
  methods.forEach((method2) => {
226
172
  const operation = oas.operation(path2, method2);
227
- if (operation && __privateGet(this, _OperationGenerator_instances, methods_get)[method2]) {
228
- const isExcluded = __privateMethod(this, _OperationGenerator_instances, isExcluded_fn).call(this, operation, method2);
229
- const isIncluded = this.context.include ? __privateMethod(this, _OperationGenerator_instances, isIncluded_fn).call(this, operation, method2) : true;
173
+ if (operation && [this.#methods].some((methods2) => method2 === operation.method)) {
174
+ const isExcluded = this.#isExcluded(operation, method2);
175
+ const isIncluded = this.context.include ? this.#isIncluded(operation, method2) : true;
230
176
  if (isIncluded && !isExcluded) {
231
177
  if (!acc[path2]) {
232
178
  acc[path2] = {};
@@ -247,26 +193,53 @@ var OperationGenerator = class extends Generator {
247
193
  const methods = this.operationsByMethod[path2] ? Object.keys(this.operationsByMethod[path2]) : [];
248
194
  methods.forEach((method) => {
249
195
  const { operation } = this.operationsByMethod[path2]?.[method];
250
- const options = __privateMethod(this, _OperationGenerator_instances, getOptions_fn).call(this, operation, method);
251
- const promiseMethod = __privateGet(this, _OperationGenerator_instances, methods_get)[method]?.call(this, operation, {
252
- ...this.options,
253
- ...options
254
- });
196
+ const options = this.#getOptions(operation, method);
197
+ const methodToCall = this[method];
198
+ if (typeof methodToCall === "function") {
199
+ const promiseMethod = methodToCall?.call(this, operation, {
200
+ ...this.options,
201
+ ...options
202
+ });
203
+ if (promiseMethod) {
204
+ acc.push(promiseMethod);
205
+ }
206
+ }
255
207
  const promiseOperation = this.operation.call(this, operation, {
256
208
  ...this.options,
257
209
  ...options
258
210
  });
259
- if (promiseMethod) {
260
- acc.push(promiseMethod);
261
- }
262
211
  if (promiseOperation) {
263
212
  acc.push(promiseOperation);
264
213
  }
214
+ generators?.forEach((generator) => {
215
+ const promise = generator.operation?.({
216
+ instance: this,
217
+ operation,
218
+ options: {
219
+ ...this.options,
220
+ ...options
221
+ }
222
+ });
223
+ if (promise) {
224
+ acc.push(promise);
225
+ }
226
+ });
265
227
  });
266
228
  return acc;
267
229
  }, []);
268
230
  const operations = Object.values(this.operationsByMethod).map((item) => Object.values(item).map((item2) => item2.operation));
269
231
  promises.push(this.all(operations.flat().filter(Boolean), this.operationsByMethod));
232
+ generators?.forEach((generator) => {
233
+ const promise = generator.operations?.({
234
+ instance: this,
235
+ operations: operations.flat().filter(Boolean),
236
+ operationsByMethod: this.operationsByMethod,
237
+ options: this.options
238
+ });
239
+ if (promise) {
240
+ promises.push(promise);
241
+ }
242
+ });
270
243
  const files = await Promise.all(promises);
271
244
  return files.flat().filter(Boolean);
272
245
  }
@@ -274,134 +247,192 @@ var OperationGenerator = class extends Generator {
274
247
  * Operation
275
248
  */
276
249
  async operation(operation, options) {
277
- return null;
250
+ return [];
278
251
  }
279
252
  /**
280
253
  * GET
281
254
  */
282
255
  async get(operation, options) {
283
- return null;
256
+ return [];
284
257
  }
285
258
  /**
286
259
  * POST
287
260
  */
288
261
  async post(operation, options) {
289
- return null;
262
+ return [];
290
263
  }
291
264
  /**
292
265
  * PATCH
293
266
  */
294
267
  async patch(operation, options) {
295
- return null;
268
+ return [];
296
269
  }
297
270
  /**
298
271
  * PUT
299
272
  */
300
273
  async put(operation, options) {
301
- return null;
274
+ return [];
302
275
  }
303
276
  /**
304
277
  * DELETE
305
278
  */
306
279
  async delete(operation, options) {
307
- return null;
280
+ return [];
308
281
  }
309
282
  /**
310
283
  * Combination of GET, POST, PATCH, PUT, DELETE
311
284
  */
312
285
  async all(operations, paths) {
313
- return null;
286
+ return [];
314
287
  }
315
288
  };
316
- _operationsByMethod = new WeakMap();
317
- _OperationGenerator_instances = new WeakSet();
318
- getOptions_fn = function(operation, method) {
319
- const { override = [] } = this.context;
320
- return override.find(({ pattern, type }) => {
321
- if (type === "tag") {
322
- return !!operation.getTags()[0]?.name.match(pattern);
323
- }
324
- if (type === "operationId") {
325
- return !!operation.getOperationId().match(pattern);
326
- }
327
- if (type === "path") {
328
- return !!operation.path.match(pattern);
329
- }
330
- if (type === "method") {
331
- return !!method.match(pattern);
332
- }
333
- return false;
334
- })?.options || {};
335
- };
336
- /**
337
- *
338
- * @deprecated
339
- */
340
- isExcluded_fn = function(operation, method) {
341
- const { exclude = [] } = this.context;
342
- let matched = false;
343
- exclude.forEach(({ pattern, type }) => {
344
- if (type === "tag" && !matched) {
345
- matched = !!operation.getTags()[0]?.name.match(pattern);
346
- }
347
- if (type === "operationId" && !matched) {
348
- matched = !!operation.getOperationId().match(pattern);
349
- }
350
- if (type === "path" && !matched) {
351
- matched = !!operation.path.match(pattern);
352
- }
353
- if (type === "method" && !matched) {
354
- matched = !!method.match(pattern);
355
- }
356
- });
357
- return matched;
358
- };
359
- /**
360
- *
361
- * @deprecated
362
- */
363
- isIncluded_fn = function(operation, method) {
364
- const { include = [] } = this.context;
365
- let matched = false;
366
- include.forEach(({ pattern, type }) => {
367
- if (type === "tag" && !matched) {
368
- matched = !!operation.getTags()[0]?.name.match(pattern);
369
- }
370
- if (type === "operationId" && !matched) {
371
- matched = !!operation.getOperationId().match(pattern);
372
- }
373
- if (type === "path" && !matched) {
374
- matched = !!operation.path.match(pattern);
289
+
290
+ // src/plugin.ts
291
+ init_esm_shims();
292
+ var pluginOasName = "plugin-oas";
293
+ var pluginOas = createPlugin((options) => {
294
+ const {
295
+ output = { path: "schemas", export: false },
296
+ experimentalFilter: filter,
297
+ experimentalSort: sort,
298
+ validate = true,
299
+ serverIndex = 0,
300
+ contentType,
301
+ oasClass
302
+ } = options;
303
+ const getOas = async ({ config, logger, formatOptions }) => {
304
+ try {
305
+ const oas = await parseFromConfig(config, formatOptions, oasClass);
306
+ if (validate) {
307
+ await oas.valdiate();
308
+ }
309
+ return oas;
310
+ } catch (e) {
311
+ const error = e;
312
+ logger.emit("warning", error?.message);
313
+ return parseFromConfig(config, {}, oasClass);
375
314
  }
376
- if (type === "method" && !matched) {
377
- matched = !!method.match(pattern);
315
+ };
316
+ return {
317
+ name: pluginOasName,
318
+ output: output === false ? {
319
+ path: "",
320
+ exportType: false
321
+ } : {
322
+ exportType: "barrelNamed",
323
+ ...output
324
+ },
325
+ options,
326
+ context() {
327
+ const { config, logger } = this;
328
+ return {
329
+ getOas(formatOptions) {
330
+ return getOas({ config, logger, formatOptions });
331
+ },
332
+ async getSchemas({ includes } = {}) {
333
+ const oas = await this.getOas();
334
+ return getSchemas({ oas, contentType, includes });
335
+ },
336
+ async getBaseURL() {
337
+ const oasInstance = await this.getOas();
338
+ const baseURL = oasInstance.api.servers?.at(serverIndex)?.url;
339
+ return baseURL;
340
+ },
341
+ contentType
342
+ };
343
+ },
344
+ async buildStart() {
345
+ if (!output) {
346
+ return;
347
+ }
348
+ const oas = await getOas({
349
+ config: this.config,
350
+ logger: this.logger,
351
+ formatOptions: {
352
+ filterSet: filter,
353
+ sortSet: sort
354
+ }
355
+ });
356
+ await oas.dereference();
357
+ const root = path.resolve(this.config.root, this.config.output.path);
358
+ const schemas = getSchemas({ oas, contentType });
359
+ const mapSchema = async ([name, schema]) => {
360
+ const baseName = `${camelCase(name)}.json`;
361
+ const resolvedPath = path.resolve(root, output.path, baseName);
362
+ await this.addFile({
363
+ path: resolvedPath,
364
+ baseName,
365
+ meta: {
366
+ pluginKey: this.plugin.key
367
+ },
368
+ sources: [
369
+ {
370
+ name: camelCase(name),
371
+ isExportable: false,
372
+ isIndexable: false,
373
+ value: JSON.stringify(schema)
374
+ }
375
+ ]
376
+ });
377
+ };
378
+ const promises = Object.entries(schemas).map(mapSchema);
379
+ await Promise.all(promises);
378
380
  }
379
- });
380
- return matched;
381
- };
382
- methods_get = function() {
381
+ };
382
+ });
383
+
384
+ // src/generator.tsx
385
+ init_esm_shims();
386
+ var import_jsx_runtime = __toESM(require_jsx_runtime(), 1);
387
+ function createGenerator(parseOptions) {
388
+ return parseOptions;
389
+ }
390
+ function createReactGenerator(parseOptions) {
383
391
  return {
384
- get: this.get,
385
- post: this.post,
386
- patch: this.patch,
387
- put: this.put,
388
- delete: this.delete,
389
- head: void 0,
390
- options: void 0,
391
- trace: void 0
392
+ ...parseOptions,
393
+ async operations({ instance, options, operations, operationsByMethod }) {
394
+ if (!parseOptions.Operations) {
395
+ return [];
396
+ }
397
+ const { pluginManager, oas, plugin, mode } = instance.context;
398
+ const root = createRoot({
399
+ logger: pluginManager.logger
400
+ });
401
+ root.render(
402
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(App, { pluginManager, plugin, mode, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Oas, { oas, operations, generator: instance, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(parseOptions.Operations, { operations, instance, operationsByMethod, options }) }) })
403
+ );
404
+ return root.files;
405
+ },
406
+ async operation({ instance, operation, options }) {
407
+ if (!parseOptions.Operation) {
408
+ return [];
409
+ }
410
+ const { pluginManager, oas, plugin, mode } = instance.context;
411
+ const root = createRoot({
412
+ logger: pluginManager.logger
413
+ });
414
+ root.render(
415
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(App, { pluginManager, plugin: { ...plugin, options }, mode, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Oas, { oas, operations: [operation], generator: instance, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Oas.Operation, { operation, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(parseOptions.Operation, { operation, options, instance }) }) }) })
416
+ );
417
+ return root.files;
418
+ },
419
+ async schema({ instance, schema, name, options }) {
420
+ if (!parseOptions.Schema) {
421
+ return [];
422
+ }
423
+ const { pluginManager, oas, plugin, mode } = instance.context;
424
+ const root = createRoot({
425
+ logger: pluginManager.logger
426
+ });
427
+ const tree = instance.parse({ schema, name });
428
+ root.render(
429
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(App, { pluginManager, plugin: { ...plugin, options }, mode, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Oas, { oas, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Oas.Schema, { name, value: schema, tree, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(parseOptions.Schema, { schema, options, instance, name }) }) }) })
430
+ );
431
+ return root.files;
432
+ }
392
433
  };
393
- };
434
+ }
394
435
 
395
- // src/index.ts
396
- var definePluginDefault = pluginOas;
397
- var src_default = definePluginDefault;
398
- export {
399
- OperationGenerator,
400
- SchemaGenerator,
401
- src_default as default,
402
- isKeyword,
403
- pluginOas,
404
- pluginOasName,
405
- schemaKeywords
406
- };
436
+ export { OperationGenerator, createGenerator, createReactGenerator, pluginOas, pluginOasName };
437
+ //# sourceMappingURL=index.js.map
407
438
  //# sourceMappingURL=index.js.map