@kubb/plugin-oas 3.4.5 → 3.5.1

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 (46) hide show
  1. package/dist/{OperationGenerator-zrV0FutY.d.cts → OperationGenerator-4qu2F0-Y.d.cts} +8 -4
  2. package/dist/{OperationGenerator-zrV0FutY.d.ts → OperationGenerator-4qu2F0-Y.d.ts} +8 -4
  3. package/dist/{Schema-CAK3gCXL.d.ts → Schema-BZZ5PnvL.d.ts} +1 -1
  4. package/dist/{Schema-CFpQnhg0.d.cts → Schema-hC9ySN2i.d.cts} +1 -1
  5. package/dist/chunk-6BM3CVIN.js +92 -0
  6. package/dist/chunk-6BM3CVIN.js.map +1 -0
  7. package/dist/{chunk-FSCYFGYN.cjs → chunk-W5N2APGH.cjs} +5 -4
  8. package/dist/chunk-W5N2APGH.cjs.map +1 -0
  9. package/dist/chunk-XXKSJDBY.cjs +107 -0
  10. package/dist/chunk-XXKSJDBY.cjs.map +1 -0
  11. package/dist/{chunk-WBHFV7C2.js → chunk-Y2G53DHK.js} +5 -4
  12. package/dist/chunk-Y2G53DHK.js.map +1 -0
  13. package/dist/components.d.cts +2 -2
  14. package/dist/components.d.ts +2 -2
  15. package/dist/generators.cjs +4 -2
  16. package/dist/generators.d.cts +1 -1
  17. package/dist/generators.d.ts +1 -1
  18. package/dist/generators.js +3 -1
  19. package/dist/hooks.d.cts +2 -2
  20. package/dist/hooks.d.ts +2 -2
  21. package/dist/index.cjs +25 -8
  22. package/dist/index.cjs.map +1 -1
  23. package/dist/index.d.cts +2 -2
  24. package/dist/index.d.ts +2 -2
  25. package/dist/index.js +22 -5
  26. package/dist/index.js.map +1 -1
  27. package/dist/utils.cjs +26 -57
  28. package/dist/utils.cjs.map +1 -1
  29. package/dist/utils.d.cts +16 -4
  30. package/dist/utils.d.ts +16 -4
  31. package/dist/utils.js +1 -50
  32. package/dist/utils.js.map +1 -1
  33. package/package.json +8 -8
  34. package/src/OperationGenerator.ts +1 -1
  35. package/src/generators/jsonGenerator.ts +3 -2
  36. package/src/plugin.ts +23 -1
  37. package/src/types.ts +8 -4
  38. package/src/utils/getBanner.ts +20 -0
  39. package/src/utils/getFooter.ts +20 -0
  40. package/src/utils/index.ts +2 -0
  41. package/dist/chunk-BZOI3PL5.js +0 -29
  42. package/dist/chunk-BZOI3PL5.js.map +0 -1
  43. package/dist/chunk-FSCYFGYN.cjs.map +0 -1
  44. package/dist/chunk-QXUSUL7H.cjs +0 -35
  45. package/dist/chunk-QXUSUL7H.cjs.map +0 -1
  46. package/dist/chunk-WBHFV7C2.js.map +0 -1
@@ -1,4 +1,4 @@
1
- import { Plugin, ResolveNameParams, Output, PluginFactoryOptions, FileMetaBase, BaseGenerator, PluginManager } from '@kubb/core';
1
+ import { Plugin, ResolveNameParams, Output, Group, PluginFactoryOptions, FileMetaBase, BaseGenerator, PluginManager } from '@kubb/core';
2
2
  import * as KubbFile from '@kubb/fs/types';
3
3
  import { Oas, contentType, OasTypes, SchemaObject, Operation, HttpMethod } from '@kubb/oas';
4
4
  import { KubbNode } from '@kubb/react/types';
@@ -296,7 +296,11 @@ type Options = {
296
296
  * Specify the export location for the files and define the behavior of the output
297
297
  * @default { path: 'schemas', barrelType: 'named' }
298
298
  */
299
- output?: Output;
299
+ output?: Output<Oas>;
300
+ /**
301
+ * Group the JSON files based on the provided name.
302
+ */
303
+ group?: Group;
300
304
  /**
301
305
  * Which server to use from the array of `servers.url[serverIndex]`
302
306
  * @example
@@ -405,9 +409,9 @@ type Override<TOptions> = (ByTag | ByOperationId | ByPath | ByMethod | BySchemaN
405
409
  options: Partial<TOptions>;
406
410
  };
407
411
  type ResolvedOptions = Options & {
408
- output: Output;
412
+ output: Output<Oas>;
409
413
  };
410
- type PluginOas = PluginFactoryOptions<'plugin-oas', Options, ResolvedOptions, API, never>;
414
+ type PluginOas = PluginFactoryOptions<'plugin-oas', Options, ResolvedOptions, API, ResolvePathOptions>;
411
415
 
412
416
  type GetSchemaGeneratorOptions<T extends SchemaGenerator<any, any, any>> = T extends SchemaGenerator<infer Options, any, any> ? Options : never;
413
417
  type SchemaMethodResult<TFileMeta extends FileMetaBase> = Promise<KubbFile.File<TFileMeta> | Array<KubbFile.File<TFileMeta>> | null>;
@@ -1,4 +1,4 @@
1
- import { Plugin, ResolveNameParams, Output, PluginFactoryOptions, FileMetaBase, BaseGenerator, PluginManager } from '@kubb/core';
1
+ import { Plugin, ResolveNameParams, Output, Group, PluginFactoryOptions, FileMetaBase, BaseGenerator, PluginManager } from '@kubb/core';
2
2
  import * as KubbFile from '@kubb/fs/types';
3
3
  import { Oas, contentType, OasTypes, SchemaObject, Operation, HttpMethod } from '@kubb/oas';
4
4
  import { KubbNode } from '@kubb/react/types';
@@ -296,7 +296,11 @@ type Options = {
296
296
  * Specify the export location for the files and define the behavior of the output
297
297
  * @default { path: 'schemas', barrelType: 'named' }
298
298
  */
299
- output?: Output;
299
+ output?: Output<Oas>;
300
+ /**
301
+ * Group the JSON files based on the provided name.
302
+ */
303
+ group?: Group;
300
304
  /**
301
305
  * Which server to use from the array of `servers.url[serverIndex]`
302
306
  * @example
@@ -405,9 +409,9 @@ type Override<TOptions> = (ByTag | ByOperationId | ByPath | ByMethod | BySchemaN
405
409
  options: Partial<TOptions>;
406
410
  };
407
411
  type ResolvedOptions = Options & {
408
- output: Output;
412
+ output: Output<Oas>;
409
413
  };
410
- type PluginOas = PluginFactoryOptions<'plugin-oas', Options, ResolvedOptions, API, never>;
414
+ type PluginOas = PluginFactoryOptions<'plugin-oas', Options, ResolvedOptions, API, ResolvePathOptions>;
411
415
 
412
416
  type GetSchemaGeneratorOptions<T extends SchemaGenerator<any, any, any>> = T extends SchemaGenerator<infer Options, any, any> ? Options : never;
413
417
  type SchemaMethodResult<TFileMeta extends FileMetaBase> = Promise<KubbFile.File<TFileMeta> | Array<KubbFile.File<TFileMeta>> | null>;
@@ -1,7 +1,7 @@
1
1
  import * as react from 'react';
2
2
  import { SchemaObject } from '@kubb/oas';
3
3
  import { Key, KubbNode } from '@kubb/react/types';
4
- import { f as Schema$1 } from './OperationGenerator-zrV0FutY.js';
4
+ import { f as Schema$1 } from './OperationGenerator-4qu2F0-Y.js';
5
5
 
6
6
  type SchemaContextProps = {
7
7
  name: string;
@@ -1,7 +1,7 @@
1
1
  import * as react from 'react';
2
2
  import { SchemaObject } from '@kubb/oas';
3
3
  import { Key, KubbNode } from '@kubb/react/types';
4
- import { f as Schema$1 } from './OperationGenerator-zrV0FutY.cjs';
4
+ import { f as Schema$1 } from './OperationGenerator-4qu2F0-Y.cjs';
5
5
 
6
6
  type SchemaContextProps = {
7
7
  name: string;
@@ -0,0 +1,92 @@
1
+ import transformers, { isValidVarName, camelCase } from '@kubb/core/transformers';
2
+ import { URLPath } from '@kubb/core/utils';
3
+ import { isParameterObject, parse, Oas } from '@kubb/oas';
4
+ export { isOptional } from '@kubb/oas';
5
+ import { resolve } from 'node:path';
6
+ import yaml from '@stoplight/yaml';
7
+ import { isFunction } from 'remeda';
8
+
9
+ // src/utils/getComments.ts
10
+ function getComments(operation) {
11
+ return [
12
+ operation.getDescription() && `@description ${operation.getDescription()}`,
13
+ operation.getSummary() && `@summary ${operation.getSummary()}`,
14
+ operation.path && `{@link ${new URLPath(operation.path).URL}}`,
15
+ operation.isDeprecated() && "@deprecated"
16
+ ].filter(Boolean).map((text) => transformers.trim(text));
17
+ }
18
+ function getASTParams(operationSchema, {
19
+ typed = false,
20
+ override
21
+ } = {}) {
22
+ if (!operationSchema || !operationSchema.schema.properties || !operationSchema.name) {
23
+ return [];
24
+ }
25
+ return Object.entries(operationSchema.schema.properties).map(([name, schema]) => {
26
+ const isParam = isParameterObject(schema);
27
+ const data = {
28
+ name,
29
+ enabled: !!name,
30
+ required: isParam ? schema.required : true,
31
+ type: typed ? `${operationSchema.name}["${name}"]` : void 0
32
+ };
33
+ return override ? override(data) : data;
34
+ });
35
+ }
36
+ function getPathParams(operationSchema, options = {}) {
37
+ return getASTParams(operationSchema, options).reduce((acc, curr) => {
38
+ if (curr.name && curr.enabled) {
39
+ let name = isValidVarName(curr.name) ? curr.name : camelCase(curr.name);
40
+ if (options.casing === "camelcase") {
41
+ name = camelCase(name);
42
+ }
43
+ acc[name] = {
44
+ default: curr.default,
45
+ type: curr.type,
46
+ optional: !curr.required
47
+ };
48
+ }
49
+ return acc;
50
+ }, {});
51
+ }
52
+ function parseFromConfig(config, oasClass = Oas) {
53
+ if ("data" in config.input) {
54
+ if (typeof config.input.data === "object") {
55
+ const api2 = JSON.parse(JSON.stringify(config.input.data));
56
+ return parse(api2, oasClass);
57
+ }
58
+ try {
59
+ const api2 = yaml.parse(config.input.data);
60
+ return parse(api2, oasClass);
61
+ } catch (e) {
62
+ }
63
+ const api = JSON.parse(JSON.stringify(config.input.data));
64
+ return parse(api, oasClass);
65
+ }
66
+ if (new URLPath(config.input.path).isURL) {
67
+ return parse(config.input.path, oasClass);
68
+ }
69
+ return parse(resolve(config.root, config.input.path), oasClass);
70
+ }
71
+ function getBanner({ output, oas }) {
72
+ if (!output.banner) {
73
+ return void 0;
74
+ }
75
+ if (isFunction(output.banner)) {
76
+ return output.banner(oas);
77
+ }
78
+ return output.banner;
79
+ }
80
+ function getFooter({ output, oas }) {
81
+ if (!output.footer) {
82
+ return void 0;
83
+ }
84
+ if (isFunction(output.footer)) {
85
+ return output.footer(oas);
86
+ }
87
+ return output.footer;
88
+ }
89
+
90
+ export { getASTParams, getBanner, getComments, getFooter, getPathParams, parseFromConfig };
91
+ //# sourceMappingURL=chunk-6BM3CVIN.js.map
92
+ //# sourceMappingURL=chunk-6BM3CVIN.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/utils/getComments.ts","../src/utils/getParams.ts","../src/utils/parseFromConfig.ts","../src/utils/getBanner.ts","../src/utils/getFooter.ts"],"names":["api","URLPath","isFunction"],"mappings":";;;;;;;;;AAKO,SAAS,YAAY,SAAgC,EAAA;AAC1D,EAAO,OAAA;AAAA,IACL,UAAU,cAA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A,IAAA,CAAK,UAAU,MAAO,CAAA,KAAA,CAAM,IAAI,CAAC,CAAA;AAE9E,IAAO,OAAA,KAAA,CAAM,KAAK,QAAQ,CAAA;AAAA;AAG5B,EAAA,IAAI,IAAIC,OAAQ,CAAA,MAAA,CAAO,KAAM,CAAA,IAAI,EAAE,KAAO,EAAA;AACxC,IAAA,OAAO,KAAM,CAAA,MAAA,CAAO,KAAM,CAAA,IAAA,EAAM,QAAQ,CAAA;AAAA;AAG1C,EAAO,OAAA,KAAA,CAAM,QAAQ,MAAO,CAAA,IAAA,EAAM,OAAO,KAAM,CAAA,IAAI,GAAG,QAAQ,CAAA;AAChE;AC1BO,SAAS,SAAU,CAAA,EAAE,MAAQ,EAAA,GAAA,EAAc,EAAA;AAChD,EAAI,IAAA,CAAC,OAAO,MAAQ,EAAA;AAClB,IAAO,OAAA,KAAA,CAAA;AAAA;AAGT,EAAI,IAAA,UAAA,CAAW,MAAO,CAAA,MAAM,CAAG,EAAA;AAC7B,IAAO,OAAA,MAAA,CAAO,OAAO,GAAG,CAAA;AAAA;AAG1B,EAAA,OAAO,MAAO,CAAA,MAAA;AAChB;ACVO,SAAS,SAAU,CAAA,EAAE,MAAQ,EAAA,GAAA,EAAc,EAAA;AAChD,EAAI,IAAA,CAAC,OAAO,MAAQ,EAAA;AAClB,IAAO,OAAA,KAAA,CAAA;AAAA;AAGT,EAAIC,IAAAA,UAAAA,CAAW,MAAO,CAAA,MAAM,CAAG,EAAA;AAC7B,IAAO,OAAA,MAAA,CAAO,OAAO,GAAG,CAAA;AAAA;AAG1B,EAAA,OAAO,MAAO,CAAA,MAAA;AAChB","file":"chunk-6BM3CVIN.js","sourcesContent":["import transformers from '@kubb/core/transformers'\nimport { URLPath } from '@kubb/core/utils'\n\nimport type { Operation } from '@kubb/oas'\n\nexport function getComments(operation: Operation): string[] {\n return [\n operation.getDescription() && `@description ${operation.getDescription()}`,\n operation.getSummary() && `@summary ${operation.getSummary()}`,\n operation.path && `{@link ${new URLPath(operation.path).URL}}`,\n operation.isDeprecated() && '@deprecated',\n ]\n .filter(Boolean)\n .map((text) => transformers.trim(text))\n}\n","import { isParameterObject } from '@kubb/oas'\n\nimport { camelCase, isValidVarName } from '@kubb/core/transformers'\nimport type { FunctionParamsAST } from '@kubb/core/utils'\nimport type { OasTypes } from '@kubb/oas'\nimport type { Params } from '@kubb/react/types'\nimport type { OperationSchema } from '../types.ts'\n/**\n *\n * @deprecated\n * TODO move to operationManager hook\n */\nexport function getASTParams(\n operationSchema: OperationSchema | undefined,\n {\n typed = false,\n override,\n }: {\n typed?: boolean\n override?: (data: FunctionParamsAST) => FunctionParamsAST\n } = {},\n): FunctionParamsAST[] {\n if (!operationSchema || !operationSchema.schema.properties || !operationSchema.name) {\n return []\n }\n\n return Object.entries(operationSchema.schema.properties).map(([name, schema]: [string, OasTypes.SchemaObject]) => {\n const isParam = isParameterObject(schema)\n const data: FunctionParamsAST = {\n name,\n enabled: !!name,\n required: isParam ? schema.required : true,\n type: typed ? `${operationSchema.name}[\"${name}\"]` : undefined,\n }\n\n return override ? override(data) : data\n })\n}\n\nexport function getPathParams(\n operationSchema: OperationSchema | undefined,\n options: {\n typed?: boolean\n casing?: 'camelcase'\n override?: (data: FunctionParamsAST) => FunctionParamsAST\n } = {},\n) {\n return getASTParams(operationSchema, options).reduce((acc, curr) => {\n if (curr.name && curr.enabled) {\n let name = isValidVarName(curr.name) ? curr.name : camelCase(curr.name)\n\n if (options.casing === 'camelcase') {\n name = camelCase(name)\n }\n\n acc[name] = {\n default: curr.default,\n type: curr.type,\n optional: !curr.required,\n }\n }\n\n return acc\n }, {} as Params)\n}\n","import { resolve } from 'node:path'\n\nimport { URLPath } from '@kubb/core/utils'\n\nimport { parse } from '@kubb/oas'\n\nimport type { Config } from '@kubb/core'\nimport { Oas, type OasTypes } from '@kubb/oas'\nimport yaml from '@stoplight/yaml'\n\nexport function parseFromConfig(config: Config, oasClass: typeof Oas = Oas): Promise<Oas> {\n if ('data' in config.input) {\n if (typeof config.input.data === 'object') {\n const api: OasTypes.OASDocument = JSON.parse(JSON.stringify(config.input.data)) as OasTypes.OASDocument\n return parse(api, oasClass)\n }\n\n try {\n const api: string = yaml.parse(config.input.data as string) as string\n\n return parse(api, oasClass)\n } catch (e) {\n /* empty */\n }\n\n const api: OasTypes.OASDocument = JSON.parse(JSON.stringify(config.input.data)) as OasTypes.OASDocument\n\n return parse(api, oasClass)\n }\n\n if (new URLPath(config.input.path).isURL) {\n return parse(config.input.path, oasClass)\n }\n\n return parse(resolve(config.root, config.input.path), oasClass)\n}\n","import type { Output } from '@kubb/core'\nimport type { Oas } from '@kubb/oas'\nimport { isFunction } from 'remeda'\n\ntype Props = {\n oas: Oas\n output: Output<Oas>\n}\n\nexport function getBanner({ output, oas }: Props) {\n if (!output.banner) {\n return undefined\n }\n\n if (isFunction(output.banner)) {\n return output.banner(oas)\n }\n\n return output.banner\n}\n","import type { Output } from '@kubb/core'\nimport type { Oas } from '@kubb/oas'\nimport { isFunction } from 'remeda'\n\ntype Props = {\n oas: Oas\n output: Output<Oas>\n}\n\nexport function getFooter({ output, oas }: Props) {\n if (!output.footer) {\n return undefined\n }\n\n if (isFunction(output.footer)) {\n return output.footer(oas)\n }\n\n return output.footer\n}\n"]}
@@ -1,5 +1,6 @@
1
1
  'use strict';
2
2
 
3
+ var chunkXXKSJDBY_cjs = require('./chunk-XXKSJDBY.cjs');
3
4
  var chunkKXB5DUFD_cjs = require('./chunk-KXB5DUFD.cjs');
4
5
  var transformers = require('@kubb/core/transformers');
5
6
  var react = require('@kubb/react');
@@ -78,8 +79,8 @@ var jsonGenerator = createGenerator({
78
79
  value: JSON.stringify(schema.value)
79
80
  }
80
81
  ],
81
- banner: plugin.options.output?.banner,
82
- format: plugin.options.output?.footer
82
+ banner: chunkXXKSJDBY_cjs.getBanner({ oas: instance.context.oas, output: plugin.options.output }),
83
+ format: chunkXXKSJDBY_cjs.getFooter({ oas: instance.context.oas, output: plugin.options.output })
83
84
  }
84
85
  ];
85
86
  }
@@ -88,5 +89,5 @@ var jsonGenerator = createGenerator({
88
89
  exports.createGenerator = createGenerator;
89
90
  exports.createReactGenerator = createReactGenerator;
90
91
  exports.jsonGenerator = jsonGenerator;
91
- //# sourceMappingURL=chunk-FSCYFGYN.cjs.map
92
- //# sourceMappingURL=chunk-FSCYFGYN.cjs.map
92
+ //# sourceMappingURL=chunk-W5N2APGH.cjs.map
93
+ //# sourceMappingURL=chunk-W5N2APGH.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/generator.tsx","../src/generators/jsonGenerator.ts"],"names":["createRoot","App","jsx","Oas","camelCase","getBanner","getFooter"],"mappings":";;;;;;;;AA2CO,SAAS,gBAAuD,YAA+D,EAAA;AACpI,EAAO,OAAA,YAAA;AACT;AASO,SAAS,qBAA4D,YAAoE,EAAA;AAC9I,EAAO,OAAA;AAAA,IACL,GAAG,YAAA;AAAA,IACH,MAAM,UAAW,CAAA,EAAE,UAAU,OAAS,EAAA,UAAA,EAAY,oBAAsB,EAAA;AACtE,MAAI,IAAA,CAAC,aAAa,UAAY,EAAA;AAC5B,QAAA,OAAO,EAAC;AAAA;AAGV,MAAA,MAAM,EAAE,aAAe,EAAA,GAAA,EAAK,MAAQ,EAAA,IAAA,KAAS,QAAS,CAAA,OAAA;AACtD,MAAA,MAAM,OAAOA,gBAAW,CAAA;AAAA,QACtB,QAAQ,aAAc,CAAA;AAAA,OACvB,CAAA;AAED,MAAA,MAAM,SAAY,GAAA,YAAA,CAAa,UAAW,CAAA,IAAA,CAAK,IAAI,CAAA;AAEnD,MAAK,IAAA,CAAA,MAAA;AAAA,uCACFC,SAAI,EAAA,EAAA,aAAA,EAA8B,QAAgB,IACjD,EAAA,QAAA,kBAAAC,cAAA,CAACC,yBAAI,GAAU,EAAA,UAAA,EAAwB,SAAW,EAAA,QAAA,EAChD,yCAAC,SAAU,EAAA,EAAA,UAAA,EAAwB,UAAoB,kBAAwC,EAAA,OAAA,EAAkB,GACnH,CACF,EAA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YAC3B,YAAc,EAAA,KAAA;AAAA,YACd,WAAa,EAAA,KAAA;AAAA,YACb,KAAO,EAAA,IAAA,CAAK,SAAU,CAAA,MAAA,CAAO,KAAK;AAAA;AACpC,SACF;AAAA,QACA,MAAA,EAAQC,2BAAU,CAAA,EAAE,GAAK,EAAA,QAAA,CAAS,OAAQ,CAAA,GAAA,EAAK,MAAQ,EAAA,MAAA,CAAO,OAAQ,CAAA,MAAA,EAAQ,CAAA;AAAA,QAC9E,MAAA,EAAQC,2BAAU,CAAA,EAAE,GAAK,EAAA,QAAA,CAAS,OAAQ,CAAA,GAAA,EAAK,MAAQ,EAAA,MAAA,CAAO,OAAQ,CAAA,MAAA,EAAQ;AAAA;AAChF,KACF;AAAA;AAEJ,CAAC","file":"chunk-W5N2APGH.cjs","sourcesContent":["import type { PluginFactoryOptions } from '@kubb/core'\nimport type * as KubbFile from '@kubb/fs/types'\nimport type { Operation, SchemaObject } from '@kubb/oas'\nimport { Oas } from '@kubb/plugin-oas/components'\nimport { App, createRoot } from '@kubb/react'\nimport type { KubbNode } from '@kubb/react/types'\nimport type { OperationGenerator } from './OperationGenerator.ts'\nimport type { SchemaGenerator, SchemaGeneratorOptions } from './SchemaGenerator.ts'\nimport type { Schema } from './SchemaMapper.ts'\nimport type { OperationsByMethod } from './types.ts'\n\ntype OperationsProps<TOptions extends PluginFactoryOptions> = {\n instance: Omit<OperationGenerator<TOptions>, 'build'>\n options: TOptions['resolvedOptions']\n operations: Array<Operation>\n operationsByMethod: OperationsByMethod\n}\n\ntype OperationProps<TOptions extends PluginFactoryOptions> = {\n instance: Omit<OperationGenerator<TOptions>, 'build'>\n options: TOptions['resolvedOptions']\n operation: Operation\n}\n\ntype SchemaProps<TOptions extends PluginFactoryOptions> = {\n instance: Omit<SchemaGenerator<SchemaGeneratorOptions, TOptions>, 'build'>\n options: TOptions['resolvedOptions']\n schema: {\n name: string\n tree: Array<Schema>\n value: SchemaObject\n }\n}\n\nexport type GeneratorOptions<TOptions extends PluginFactoryOptions> = {\n name: string\n operations?: (this: GeneratorOptions<TOptions>, props: OperationsProps<TOptions>) => Promise<KubbFile.File[]>\n operation?: (this: GeneratorOptions<TOptions>, props: OperationProps<TOptions>) => Promise<KubbFile.File[]>\n schema?: (this: GeneratorOptions<TOptions>, props: SchemaProps<TOptions>) => Promise<KubbFile.File[]>\n}\n\nexport type Generator<TOptions extends PluginFactoryOptions> = GeneratorOptions<TOptions>\n\nexport function createGenerator<TOptions extends PluginFactoryOptions>(parseOptions: GeneratorOptions<TOptions>): Generator<TOptions> {\n return parseOptions\n}\n\nexport type ReactGeneratorOptions<TOptions extends PluginFactoryOptions> = {\n name: string\n Operations?: (this: ReactGeneratorOptions<TOptions>, props: OperationsProps<TOptions>) => KubbNode\n Operation?: (this: ReactGeneratorOptions<TOptions>, props: OperationProps<TOptions>) => KubbNode\n Schema?: (this: ReactGeneratorOptions<TOptions>, props: SchemaProps<TOptions>) => KubbNode\n}\n\nexport function createReactGenerator<TOptions extends PluginFactoryOptions>(parseOptions: ReactGeneratorOptions<TOptions>): Generator<TOptions> {\n return {\n ...parseOptions,\n async operations({ instance, options, operations, operationsByMethod }) {\n if (!parseOptions.Operations) {\n return []\n }\n\n const { pluginManager, oas, plugin, mode } = instance.context\n const root = createRoot({\n logger: pluginManager.logger,\n })\n\n const Component = parseOptions.Operations.bind(this)\n\n root.render(\n <App pluginManager={pluginManager} plugin={plugin} mode={mode}>\n <Oas oas={oas} operations={operations} generator={instance}>\n <Component operations={operations} instance={instance} operationsByMethod={operationsByMethod} options={options} />\n </Oas>\n </App>,\n )\n\n return root.files\n },\n async operation({ instance, operation, options }) {\n if (!parseOptions.Operation) {\n return []\n }\n\n const { pluginManager, oas, plugin, mode } = instance.context\n const root = createRoot({\n logger: pluginManager.logger,\n })\n\n const Component = parseOptions.Operation.bind(this)\n\n root.render(\n <App pluginManager={pluginManager} plugin={{ ...plugin, options }} mode={mode}>\n <Oas oas={oas} operations={[operation]} generator={instance}>\n <Oas.Operation operation={operation}>\n <Component operation={operation} options={options} instance={instance} />\n </Oas.Operation>\n </Oas>\n </App>,\n )\n\n return root.files\n },\n async schema({ instance, schema, options }) {\n if (!parseOptions.Schema) {\n return []\n }\n\n const { pluginManager, oas, plugin, mode } = instance.context\n const root = createRoot({\n logger: pluginManager.logger,\n })\n\n const Component = parseOptions.Schema.bind(this)\n\n root.render(\n <App pluginManager={pluginManager} plugin={{ ...plugin, options }} mode={mode}>\n <Oas oas={oas}>\n <Oas.Schema name={schema.name} value={schema.value} tree={schema.tree}>\n <Component schema={schema} options={options} instance={instance} />\n </Oas.Schema>\n </Oas>\n </App>,\n )\n\n return root.files\n },\n }\n}\n","import { camelCase } from '@kubb/core/transformers'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { createGenerator } from '../generator.tsx'\nimport type { PluginOas } from '../types.ts'\n\nexport const jsonGenerator = createGenerator<PluginOas>({\n name: 'plugin-oas',\n async schema({ schema, instance }) {\n const { pluginManager, plugin } = instance.context\n const file = pluginManager.getFile({\n name: camelCase(schema.name),\n extname: '.json',\n mode: 'split',\n pluginKey: plugin.key,\n })\n\n return [\n {\n ...file,\n sources: [\n {\n name: camelCase(schema.name),\n isExportable: false,\n isIndexable: false,\n value: JSON.stringify(schema.value),\n },\n ],\n banner: getBanner({ oas: instance.context.oas, output: plugin.options.output }),\n format: getFooter({ oas: instance.context.oas, output: plugin.options.output }),\n },\n ]\n },\n})\n"]}
@@ -0,0 +1,107 @@
1
+ 'use strict';
2
+
3
+ var transformers = require('@kubb/core/transformers');
4
+ var utils = require('@kubb/core/utils');
5
+ var oas = require('@kubb/oas');
6
+ var path = require('path');
7
+ var yaml = require('@stoplight/yaml');
8
+ var remeda = require('remeda');
9
+
10
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
11
+
12
+ var transformers__default = /*#__PURE__*/_interopDefault(transformers);
13
+ var yaml__default = /*#__PURE__*/_interopDefault(yaml);
14
+
15
+ // src/utils/getComments.ts
16
+ function getComments(operation) {
17
+ return [
18
+ operation.getDescription() && `@description ${operation.getDescription()}`,
19
+ operation.getSummary() && `@summary ${operation.getSummary()}`,
20
+ operation.path && `{@link ${new utils.URLPath(operation.path).URL}}`,
21
+ operation.isDeprecated() && "@deprecated"
22
+ ].filter(Boolean).map((text) => transformers__default.default.trim(text));
23
+ }
24
+ function getASTParams(operationSchema, {
25
+ typed = false,
26
+ override
27
+ } = {}) {
28
+ if (!operationSchema || !operationSchema.schema.properties || !operationSchema.name) {
29
+ return [];
30
+ }
31
+ return Object.entries(operationSchema.schema.properties).map(([name, schema]) => {
32
+ const isParam = oas.isParameterObject(schema);
33
+ const data = {
34
+ name,
35
+ enabled: !!name,
36
+ required: isParam ? schema.required : true,
37
+ type: typed ? `${operationSchema.name}["${name}"]` : void 0
38
+ };
39
+ return override ? override(data) : data;
40
+ });
41
+ }
42
+ function getPathParams(operationSchema, options = {}) {
43
+ return getASTParams(operationSchema, options).reduce((acc, curr) => {
44
+ if (curr.name && curr.enabled) {
45
+ let name = transformers.isValidVarName(curr.name) ? curr.name : transformers.camelCase(curr.name);
46
+ if (options.casing === "camelcase") {
47
+ name = transformers.camelCase(name);
48
+ }
49
+ acc[name] = {
50
+ default: curr.default,
51
+ type: curr.type,
52
+ optional: !curr.required
53
+ };
54
+ }
55
+ return acc;
56
+ }, {});
57
+ }
58
+ function parseFromConfig(config, oasClass = oas.Oas) {
59
+ if ("data" in config.input) {
60
+ if (typeof config.input.data === "object") {
61
+ const api2 = JSON.parse(JSON.stringify(config.input.data));
62
+ return oas.parse(api2, oasClass);
63
+ }
64
+ try {
65
+ const api2 = yaml__default.default.parse(config.input.data);
66
+ return oas.parse(api2, oasClass);
67
+ } catch (e) {
68
+ }
69
+ const api = JSON.parse(JSON.stringify(config.input.data));
70
+ return oas.parse(api, oasClass);
71
+ }
72
+ if (new utils.URLPath(config.input.path).isURL) {
73
+ return oas.parse(config.input.path, oasClass);
74
+ }
75
+ return oas.parse(path.resolve(config.root, config.input.path), oasClass);
76
+ }
77
+ function getBanner({ output, oas }) {
78
+ if (!output.banner) {
79
+ return void 0;
80
+ }
81
+ if (remeda.isFunction(output.banner)) {
82
+ return output.banner(oas);
83
+ }
84
+ return output.banner;
85
+ }
86
+ function getFooter({ output, oas }) {
87
+ if (!output.footer) {
88
+ return void 0;
89
+ }
90
+ if (remeda.isFunction(output.footer)) {
91
+ return output.footer(oas);
92
+ }
93
+ return output.footer;
94
+ }
95
+
96
+ Object.defineProperty(exports, "isOptional", {
97
+ enumerable: true,
98
+ get: function () { return oas.isOptional; }
99
+ });
100
+ exports.getASTParams = getASTParams;
101
+ exports.getBanner = getBanner;
102
+ exports.getComments = getComments;
103
+ exports.getFooter = getFooter;
104
+ exports.getPathParams = getPathParams;
105
+ exports.parseFromConfig = parseFromConfig;
106
+ //# sourceMappingURL=chunk-XXKSJDBY.cjs.map
107
+ //# sourceMappingURL=chunk-XXKSJDBY.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/utils/getComments.ts","../src/utils/getParams.ts","../src/utils/parseFromConfig.ts","../src/utils/getBanner.ts","../src/utils/getFooter.ts"],"names":["URLPath","transformers","isParameterObject","isValidVarName","camelCase","Oas","api","parse","yaml","resolve","isFunction"],"mappings":";;;;;;;;;;;;;;;AAKO,SAAS,YAAY,SAAgC,EAAA;AAC1D,EAAO,OAAA;AAAA,IACL,UAAU,cAAe,EAAA,IAAK,CAAgB,aAAA,EAAA,SAAA,CAAU,gBAAgB,CAAA,CAAA;AAAA,IACxE,UAAU,UAAW,EAAA,IAAK,CAAY,SAAA,EAAA,SAAA,CAAU,YAAY,CAAA,CAAA;AAAA,IAC5D,SAAA,CAAU,QAAQ,CAAU,OAAA,EAAA,IAAIA,cAAQ,SAAU,CAAA,IAAI,EAAE,GAAG,CAAA,CAAA,CAAA;AAAA,IAC3D,SAAA,CAAU,cAAkB,IAAA;AAAA,GAC9B,CACG,MAAO,CAAA,OAAO,CACd,CAAA,GAAA,CAAI,CAAC,IAAS,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AM,OAAO,KAAM,CAAA,IAAI,GAAG,QAAQ,CAAA;AAChE;AC1BO,SAAS,SAAU,CAAA,EAAE,MAAQ,EAAA,GAAA,EAAc,EAAA;AAChD,EAAI,IAAA,CAAC,OAAO,MAAQ,EAAA;AAClB,IAAO,OAAA,KAAA,CAAA;AAAA;AAGT,EAAI,IAAAC,iBAAA,CAAW,MAAO,CAAA,MAAM,CAAG,EAAA;AAC7B,IAAO,OAAA,MAAA,CAAO,OAAO,GAAG,CAAA;AAAA;AAG1B,EAAA,OAAO,MAAO,CAAA,MAAA;AAChB;ACVO,SAAS,SAAU,CAAA,EAAE,MAAQ,EAAA,GAAA,EAAc,EAAA;AAChD,EAAI,IAAA,CAAC,OAAO,MAAQ,EAAA;AAClB,IAAO,OAAA,KAAA,CAAA;AAAA;AAGT,EAAIA,IAAAA,iBAAAA,CAAW,MAAO,CAAA,MAAM,CAAG,EAAA;AAC7B,IAAO,OAAA,MAAA,CAAO,OAAO,GAAG,CAAA;AAAA;AAG1B,EAAA,OAAO,MAAO,CAAA,MAAA;AAChB","file":"chunk-XXKSJDBY.cjs","sourcesContent":["import transformers from '@kubb/core/transformers'\nimport { URLPath } from '@kubb/core/utils'\n\nimport type { Operation } from '@kubb/oas'\n\nexport function getComments(operation: Operation): string[] {\n return [\n operation.getDescription() && `@description ${operation.getDescription()}`,\n operation.getSummary() && `@summary ${operation.getSummary()}`,\n operation.path && `{@link ${new URLPath(operation.path).URL}}`,\n operation.isDeprecated() && '@deprecated',\n ]\n .filter(Boolean)\n .map((text) => transformers.trim(text))\n}\n","import { isParameterObject } from '@kubb/oas'\n\nimport { camelCase, isValidVarName } from '@kubb/core/transformers'\nimport type { FunctionParamsAST } from '@kubb/core/utils'\nimport type { OasTypes } from '@kubb/oas'\nimport type { Params } from '@kubb/react/types'\nimport type { OperationSchema } from '../types.ts'\n/**\n *\n * @deprecated\n * TODO move to operationManager hook\n */\nexport function getASTParams(\n operationSchema: OperationSchema | undefined,\n {\n typed = false,\n override,\n }: {\n typed?: boolean\n override?: (data: FunctionParamsAST) => FunctionParamsAST\n } = {},\n): FunctionParamsAST[] {\n if (!operationSchema || !operationSchema.schema.properties || !operationSchema.name) {\n return []\n }\n\n return Object.entries(operationSchema.schema.properties).map(([name, schema]: [string, OasTypes.SchemaObject]) => {\n const isParam = isParameterObject(schema)\n const data: FunctionParamsAST = {\n name,\n enabled: !!name,\n required: isParam ? schema.required : true,\n type: typed ? `${operationSchema.name}[\"${name}\"]` : undefined,\n }\n\n return override ? override(data) : data\n })\n}\n\nexport function getPathParams(\n operationSchema: OperationSchema | undefined,\n options: {\n typed?: boolean\n casing?: 'camelcase'\n override?: (data: FunctionParamsAST) => FunctionParamsAST\n } = {},\n) {\n return getASTParams(operationSchema, options).reduce((acc, curr) => {\n if (curr.name && curr.enabled) {\n let name = isValidVarName(curr.name) ? curr.name : camelCase(curr.name)\n\n if (options.casing === 'camelcase') {\n name = camelCase(name)\n }\n\n acc[name] = {\n default: curr.default,\n type: curr.type,\n optional: !curr.required,\n }\n }\n\n return acc\n }, {} as Params)\n}\n","import { resolve } from 'node:path'\n\nimport { URLPath } from '@kubb/core/utils'\n\nimport { parse } from '@kubb/oas'\n\nimport type { Config } from '@kubb/core'\nimport { Oas, type OasTypes } from '@kubb/oas'\nimport yaml from '@stoplight/yaml'\n\nexport function parseFromConfig(config: Config, oasClass: typeof Oas = Oas): Promise<Oas> {\n if ('data' in config.input) {\n if (typeof config.input.data === 'object') {\n const api: OasTypes.OASDocument = JSON.parse(JSON.stringify(config.input.data)) as OasTypes.OASDocument\n return parse(api, oasClass)\n }\n\n try {\n const api: string = yaml.parse(config.input.data as string) as string\n\n return parse(api, oasClass)\n } catch (e) {\n /* empty */\n }\n\n const api: OasTypes.OASDocument = JSON.parse(JSON.stringify(config.input.data)) as OasTypes.OASDocument\n\n return parse(api, oasClass)\n }\n\n if (new URLPath(config.input.path).isURL) {\n return parse(config.input.path, oasClass)\n }\n\n return parse(resolve(config.root, config.input.path), oasClass)\n}\n","import type { Output } from '@kubb/core'\nimport type { Oas } from '@kubb/oas'\nimport { isFunction } from 'remeda'\n\ntype Props = {\n oas: Oas\n output: Output<Oas>\n}\n\nexport function getBanner({ output, oas }: Props) {\n if (!output.banner) {\n return undefined\n }\n\n if (isFunction(output.banner)) {\n return output.banner(oas)\n }\n\n return output.banner\n}\n","import type { Output } from '@kubb/core'\nimport type { Oas } from '@kubb/oas'\nimport { isFunction } from 'remeda'\n\ntype Props = {\n oas: Oas\n output: Output<Oas>\n}\n\nexport function getFooter({ output, oas }: Props) {\n if (!output.footer) {\n return undefined\n }\n\n if (isFunction(output.footer)) {\n return output.footer(oas)\n }\n\n return output.footer\n}\n"]}
@@ -1,3 +1,4 @@
1
+ import { getBanner, getFooter } from './chunk-6BM3CVIN.js';
1
2
  import { Oas } from './chunk-BAU7PO7T.js';
2
3
  import { camelCase } from '@kubb/core/transformers';
3
4
  import { createRoot, App } from '@kubb/react';
@@ -76,13 +77,13 @@ var jsonGenerator = createGenerator({
76
77
  value: JSON.stringify(schema.value)
77
78
  }
78
79
  ],
79
- banner: plugin.options.output?.banner,
80
- format: plugin.options.output?.footer
80
+ banner: getBanner({ oas: instance.context.oas, output: plugin.options.output }),
81
+ format: getFooter({ oas: instance.context.oas, output: plugin.options.output })
81
82
  }
82
83
  ];
83
84
  }
84
85
  });
85
86
 
86
87
  export { createGenerator, createReactGenerator, jsonGenerator };
87
- //# sourceMappingURL=chunk-WBHFV7C2.js.map
88
- //# sourceMappingURL=chunk-WBHFV7C2.js.map
88
+ //# sourceMappingURL=chunk-Y2G53DHK.js.map
89
+ //# sourceMappingURL=chunk-Y2G53DHK.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/generator.tsx","../src/generators/jsonGenerator.ts"],"names":[],"mappings":";;;;;;AA2CO,SAAS,gBAAuD,YAA+D,EAAA;AACpI,EAAO,OAAA,YAAA;AACT;AASO,SAAS,qBAA4D,YAAoE,EAAA;AAC9I,EAAO,OAAA;AAAA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AAA,EACnE,GACF,CACF,EAAA;AAAA,OACF;AAEA,MAAA,OAAO,IAAK,CAAA,KAAA;AAAA;AACd,GACF;AACF;;;AC3HO,IAAM,gBAAgB,eAA2B,CAAA;AAAA,EACtD,IAAM,EAAA,YAAA;AAAA,EACN,MAAM,MAAA,CAAO,EAAE,MAAA,EAAQ,UAAY,EAAA;AACjC,IAAA,MAAM,EAAE,aAAA,EAAe,MAAO,EAAA,GAAI,QAAS,CAAA,OAAA;AAC3C,IAAM,MAAA,IAAA,GAAO,cAAc,OAAQ,CAAA;AAAA,MACjC,IAAA,EAAM,SAAU,CAAA,MAAA,CAAO,IAAI,CAAA;AAAA,MAC3B,OAAS,EAAA,OAAA;AAAA,MACT,IAAM,EAAA,OAAA;AAAA,MACN,WAAW,MAAO,CAAA;AAAA,KACnB,CAAA;AAED,IAAO,OAAA;AAAA,MACL;AAAA,QACE,GAAG,IAAA;AAAA,QACH,OAAS,EAAA;AAAA,UACP;AAAA,YACE,IAAA,EAAM,SAAU,CAAA,MAAA,CAAO,IAAI,CAAA;AAAA,YAC3B,YAAc,EAAA,KAAA;AAAA,YACd,WAAa,EAAA,KAAA;AAAA,YACb,KAAO,EAAA,IAAA,CAAK,SAAU,CAAA,MAAA,CAAO,KAAK;AAAA;AACpC,SACF;AAAA,QACA,MAAA,EAAQ,SAAU,CAAA,EAAE,GAAK,EAAA,QAAA,CAAS,OAAQ,CAAA,GAAA,EAAK,MAAQ,EAAA,MAAA,CAAO,OAAQ,CAAA,MAAA,EAAQ,CAAA;AAAA,QAC9E,MAAA,EAAQ,SAAU,CAAA,EAAE,GAAK,EAAA,QAAA,CAAS,OAAQ,CAAA,GAAA,EAAK,MAAQ,EAAA,MAAA,CAAO,OAAQ,CAAA,MAAA,EAAQ;AAAA;AAChF,KACF;AAAA;AAEJ,CAAC","file":"chunk-Y2G53DHK.js","sourcesContent":["import type { PluginFactoryOptions } from '@kubb/core'\nimport type * as KubbFile from '@kubb/fs/types'\nimport type { Operation, SchemaObject } from '@kubb/oas'\nimport { Oas } from '@kubb/plugin-oas/components'\nimport { App, createRoot } from '@kubb/react'\nimport type { KubbNode } from '@kubb/react/types'\nimport type { OperationGenerator } from './OperationGenerator.ts'\nimport type { SchemaGenerator, SchemaGeneratorOptions } from './SchemaGenerator.ts'\nimport type { Schema } from './SchemaMapper.ts'\nimport type { OperationsByMethod } from './types.ts'\n\ntype OperationsProps<TOptions extends PluginFactoryOptions> = {\n instance: Omit<OperationGenerator<TOptions>, 'build'>\n options: TOptions['resolvedOptions']\n operations: Array<Operation>\n operationsByMethod: OperationsByMethod\n}\n\ntype OperationProps<TOptions extends PluginFactoryOptions> = {\n instance: Omit<OperationGenerator<TOptions>, 'build'>\n options: TOptions['resolvedOptions']\n operation: Operation\n}\n\ntype SchemaProps<TOptions extends PluginFactoryOptions> = {\n instance: Omit<SchemaGenerator<SchemaGeneratorOptions, TOptions>, 'build'>\n options: TOptions['resolvedOptions']\n schema: {\n name: string\n tree: Array<Schema>\n value: SchemaObject\n }\n}\n\nexport type GeneratorOptions<TOptions extends PluginFactoryOptions> = {\n name: string\n operations?: (this: GeneratorOptions<TOptions>, props: OperationsProps<TOptions>) => Promise<KubbFile.File[]>\n operation?: (this: GeneratorOptions<TOptions>, props: OperationProps<TOptions>) => Promise<KubbFile.File[]>\n schema?: (this: GeneratorOptions<TOptions>, props: SchemaProps<TOptions>) => Promise<KubbFile.File[]>\n}\n\nexport type Generator<TOptions extends PluginFactoryOptions> = GeneratorOptions<TOptions>\n\nexport function createGenerator<TOptions extends PluginFactoryOptions>(parseOptions: GeneratorOptions<TOptions>): Generator<TOptions> {\n return parseOptions\n}\n\nexport type ReactGeneratorOptions<TOptions extends PluginFactoryOptions> = {\n name: string\n Operations?: (this: ReactGeneratorOptions<TOptions>, props: OperationsProps<TOptions>) => KubbNode\n Operation?: (this: ReactGeneratorOptions<TOptions>, props: OperationProps<TOptions>) => KubbNode\n Schema?: (this: ReactGeneratorOptions<TOptions>, props: SchemaProps<TOptions>) => KubbNode\n}\n\nexport function createReactGenerator<TOptions extends PluginFactoryOptions>(parseOptions: ReactGeneratorOptions<TOptions>): Generator<TOptions> {\n return {\n ...parseOptions,\n async operations({ instance, options, operations, operationsByMethod }) {\n if (!parseOptions.Operations) {\n return []\n }\n\n const { pluginManager, oas, plugin, mode } = instance.context\n const root = createRoot({\n logger: pluginManager.logger,\n })\n\n const Component = parseOptions.Operations.bind(this)\n\n root.render(\n <App pluginManager={pluginManager} plugin={plugin} mode={mode}>\n <Oas oas={oas} operations={operations} generator={instance}>\n <Component operations={operations} instance={instance} operationsByMethod={operationsByMethod} options={options} />\n </Oas>\n </App>,\n )\n\n return root.files\n },\n async operation({ instance, operation, options }) {\n if (!parseOptions.Operation) {\n return []\n }\n\n const { pluginManager, oas, plugin, mode } = instance.context\n const root = createRoot({\n logger: pluginManager.logger,\n })\n\n const Component = parseOptions.Operation.bind(this)\n\n root.render(\n <App pluginManager={pluginManager} plugin={{ ...plugin, options }} mode={mode}>\n <Oas oas={oas} operations={[operation]} generator={instance}>\n <Oas.Operation operation={operation}>\n <Component operation={operation} options={options} instance={instance} />\n </Oas.Operation>\n </Oas>\n </App>,\n )\n\n return root.files\n },\n async schema({ instance, schema, options }) {\n if (!parseOptions.Schema) {\n return []\n }\n\n const { pluginManager, oas, plugin, mode } = instance.context\n const root = createRoot({\n logger: pluginManager.logger,\n })\n\n const Component = parseOptions.Schema.bind(this)\n\n root.render(\n <App pluginManager={pluginManager} plugin={{ ...plugin, options }} mode={mode}>\n <Oas oas={oas}>\n <Oas.Schema name={schema.name} value={schema.value} tree={schema.tree}>\n <Component schema={schema} options={options} instance={instance} />\n </Oas.Schema>\n </Oas>\n </App>,\n )\n\n return root.files\n },\n }\n}\n","import { camelCase } from '@kubb/core/transformers'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { createGenerator } from '../generator.tsx'\nimport type { PluginOas } from '../types.ts'\n\nexport const jsonGenerator = createGenerator<PluginOas>({\n name: 'plugin-oas',\n async schema({ schema, instance }) {\n const { pluginManager, plugin } = instance.context\n const file = pluginManager.getFile({\n name: camelCase(schema.name),\n extname: '.json',\n mode: 'split',\n pluginKey: plugin.key,\n })\n\n return [\n {\n ...file,\n sources: [\n {\n name: camelCase(schema.name),\n isExportable: false,\n isIndexable: false,\n value: JSON.stringify(schema.value),\n },\n ],\n banner: getBanner({ oas: instance.context.oas, output: plugin.options.output }),\n format: getFooter({ oas: instance.context.oas, output: plugin.options.output }),\n },\n ]\n },\n})\n"]}
@@ -1,8 +1,8 @@
1
- import { S as Schema } from './Schema-CFpQnhg0.cjs';
1
+ import { S as Schema } from './Schema-hC9ySN2i.cjs';
2
2
  import * as react from 'react';
3
3
  import { Operation as Operation$1, Oas as Oas$1 } from '@kubb/oas';
4
4
  import { KubbNode } from '@kubb/react/types';
5
- import { b as OperationGenerator } from './OperationGenerator-zrV0FutY.cjs';
5
+ import { b as OperationGenerator } from './OperationGenerator-4qu2F0-Y.cjs';
6
6
  import '@kubb/core';
7
7
  import '@kubb/fs/types';
8
8
 
@@ -1,8 +1,8 @@
1
- import { S as Schema } from './Schema-CAK3gCXL.js';
1
+ import { S as Schema } from './Schema-BZZ5PnvL.js';
2
2
  import * as react from 'react';
3
3
  import { Operation as Operation$1, Oas as Oas$1 } from '@kubb/oas';
4
4
  import { KubbNode } from '@kubb/react/types';
5
- import { b as OperationGenerator } from './OperationGenerator-zrV0FutY.js';
5
+ import { b as OperationGenerator } from './OperationGenerator-4qu2F0-Y.js';
6
6
  import '@kubb/core';
7
7
  import '@kubb/fs/types';
8
8
 
@@ -1,14 +1,16 @@
1
1
  'use strict';
2
2
 
3
- var chunkFSCYFGYN_cjs = require('./chunk-FSCYFGYN.cjs');
3
+ var chunkW5N2APGH_cjs = require('./chunk-W5N2APGH.cjs');
4
+ require('./chunk-XXKSJDBY.cjs');
4
5
  require('./chunk-PADR76WZ.cjs');
6
+ require('./chunk-QAFBZLJA.cjs');
5
7
  require('./chunk-KXB5DUFD.cjs');
6
8
 
7
9
 
8
10
 
9
11
  Object.defineProperty(exports, "jsonGenerator", {
10
12
  enumerable: true,
11
- get: function () { return chunkFSCYFGYN_cjs.jsonGenerator; }
13
+ get: function () { return chunkW5N2APGH_cjs.jsonGenerator; }
12
14
  });
13
15
  //# sourceMappingURL=generators.cjs.map
14
16
  //# sourceMappingURL=generators.cjs.map
@@ -1,4 +1,4 @@
1
- import { o as Generator, P as PluginOas } from './OperationGenerator-zrV0FutY.cjs';
1
+ import { o as Generator, P as PluginOas } from './OperationGenerator-4qu2F0-Y.cjs';
2
2
  import '@kubb/core';
3
3
  import '@kubb/fs/types';
4
4
  import '@kubb/oas';
@@ -1,4 +1,4 @@
1
- import { o as Generator, P as PluginOas } from './OperationGenerator-zrV0FutY.js';
1
+ import { o as Generator, P as PluginOas } from './OperationGenerator-4qu2F0-Y.js';
2
2
  import '@kubb/core';
3
3
  import '@kubb/fs/types';
4
4
  import '@kubb/oas';
@@ -1,5 +1,7 @@
1
- export { jsonGenerator } from './chunk-WBHFV7C2.js';
1
+ export { jsonGenerator } from './chunk-Y2G53DHK.js';
2
+ import './chunk-6BM3CVIN.js';
2
3
  import './chunk-R47XMJ32.js';
4
+ import './chunk-XNCEFOE6.js';
3
5
  import './chunk-BAU7PO7T.js';
4
6
  //# sourceMappingURL=generators.js.map
5
7
  //# sourceMappingURL=generators.js.map
package/dist/hooks.d.cts CHANGED
@@ -2,8 +2,8 @@ import { Oas, Operation, HttpMethod } from '@kubb/oas';
2
2
  import { Plugin, ResolveNameParams, FileMetaBase } from '@kubb/core';
3
3
  import * as KubbFile from '@kubb/fs/types';
4
4
  import { Mode } from '@kubb/fs/types';
5
- import { w as OperationSchemas, f as Schema } from './OperationGenerator-zrV0FutY.cjs';
6
- import { a as SchemaContextProps } from './Schema-CFpQnhg0.cjs';
5
+ import { w as OperationSchemas, f as Schema } from './OperationGenerator-4qu2F0-Y.cjs';
6
+ import { a as SchemaContextProps } from './Schema-hC9ySN2i.cjs';
7
7
  import '@kubb/react/types';
8
8
  import 'react';
9
9
 
package/dist/hooks.d.ts CHANGED
@@ -2,8 +2,8 @@ import { Oas, Operation, HttpMethod } from '@kubb/oas';
2
2
  import { Plugin, ResolveNameParams, FileMetaBase } from '@kubb/core';
3
3
  import * as KubbFile from '@kubb/fs/types';
4
4
  import { Mode } from '@kubb/fs/types';
5
- import { w as OperationSchemas, f as Schema } from './OperationGenerator-zrV0FutY.js';
6
- import { a as SchemaContextProps } from './Schema-CAK3gCXL.js';
5
+ import { w as OperationSchemas, f as Schema } from './OperationGenerator-4qu2F0-Y.js';
6
+ import { a as SchemaContextProps } from './Schema-BZZ5PnvL.js';
7
7
  import '@kubb/react/types';
8
8
  import 'react';
9
9
 
package/dist/index.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var chunkQXUSUL7H_cjs = require('./chunk-QXUSUL7H.cjs');
4
- var chunkFSCYFGYN_cjs = require('./chunk-FSCYFGYN.cjs');
3
+ var chunkW5N2APGH_cjs = require('./chunk-W5N2APGH.cjs');
4
+ var chunkXXKSJDBY_cjs = require('./chunk-XXKSJDBY.cjs');
5
5
  require('./chunk-PADR76WZ.cjs');
6
6
  var chunkTYJKFH6V_cjs = require('./chunk-TYJKFH6V.cjs');
7
7
  var chunkQAFBZLJA_cjs = require('./chunk-QAFBZLJA.cjs');
@@ -171,7 +171,7 @@ var OperationGenerator = class extends core.BaseGenerator {
171
171
  const methods = Object.keys(method);
172
172
  methods.forEach((method2) => {
173
173
  const operation = oas.operation(path2, method2);
174
- if (operation && [this.#methods].some((methods2) => method2 === operation.method)) {
174
+ if (operation && method2 === operation.method) {
175
175
  const isExcluded = this.#isExcluded(operation, method2);
176
176
  const isIncluded = this.context.include ? this.#isIncluded(operation, method2) : true;
177
177
  if (isIncluded && !isExcluded) {
@@ -263,15 +263,16 @@ var pluginOas = core.createPlugin((options) => {
263
263
  output = {
264
264
  path: "schemas"
265
265
  },
266
+ group,
266
267
  validate = true,
267
- generators = [chunkFSCYFGYN_cjs.jsonGenerator],
268
+ generators = [chunkW5N2APGH_cjs.jsonGenerator],
268
269
  serverIndex,
269
270
  contentType,
270
271
  oasClass
271
272
  } = options;
272
273
  const getOas = async ({ config, logger }) => {
273
274
  try {
274
- const oas = await chunkQXUSUL7H_cjs.parseFromConfig(config, oasClass);
275
+ const oas = await chunkXXKSJDBY_cjs.parseFromConfig(config, oasClass);
275
276
  if (validate) {
276
277
  await oas.valdiate();
277
278
  }
@@ -279,7 +280,7 @@ var pluginOas = core.createPlugin((options) => {
279
280
  } catch (e) {
280
281
  const error = e;
281
282
  logger.emit("warning", error?.message);
282
- return chunkQXUSUL7H_cjs.parseFromConfig(config, oasClass);
283
+ return chunkXXKSJDBY_cjs.parseFromConfig(config, oasClass);
283
284
  }
284
285
  };
285
286
  return {
@@ -314,6 +315,22 @@ var pluginOas = core.createPlugin((options) => {
314
315
  if (mode === "single") {
315
316
  return path__default.default.resolve(root, output.path);
316
317
  }
318
+ if (group && (options2?.group?.path || options2?.group?.tag)) {
319
+ const groupName = group?.name ? group.name : (ctx) => {
320
+ if (group?.type === "path") {
321
+ return `${ctx.group.split("/")[1]}`;
322
+ }
323
+ return `${transformers.camelCase(ctx.group)}Controller`;
324
+ };
325
+ return path__default.default.resolve(
326
+ root,
327
+ output.path,
328
+ groupName({
329
+ group: group.type === "path" ? options2.group.path : options2.group.tag
330
+ }),
331
+ baseName
332
+ );
333
+ }
317
334
  return path__default.default.resolve(root, output.path, baseName);
318
335
  },
319
336
  async buildStart() {
@@ -363,11 +380,11 @@ var pluginOas = core.createPlugin((options) => {
363
380
 
364
381
  Object.defineProperty(exports, "createGenerator", {
365
382
  enumerable: true,
366
- get: function () { return chunkFSCYFGYN_cjs.createGenerator; }
383
+ get: function () { return chunkW5N2APGH_cjs.createGenerator; }
367
384
  });
368
385
  Object.defineProperty(exports, "createReactGenerator", {
369
386
  enumerable: true,
370
- get: function () { return chunkFSCYFGYN_cjs.createReactGenerator; }
387
+ get: function () { return chunkW5N2APGH_cjs.createReactGenerator; }
371
388
  });
372
389
  Object.defineProperty(exports, "SchemaGenerator", {
373
390
  enumerable: true,