@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
package/dist/utils.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/utils/getComments.ts","../src/utils/getParams.ts"],"names":[],"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,IAAI,QAAQ,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,KAAA,YAAA,CAAa,IAAK,CAAA,IAAI,CAAC,CAAA;AAC1C;ACFO,SAAS,aACd,eACA,EAAA;AAAA,EACE,KAAQ,GAAA,KAAA;AAAA,EACR;AACF,CAAA,GAGI,EACiB,EAAA;AACrB,EAAI,IAAA,CAAC,mBAAmB,CAAC,eAAA,CAAgB,OAAO,UAAc,IAAA,CAAC,gBAAgB,IAAM,EAAA;AACnF,IAAA,OAAO,EAAC;AAAA;AAGV,EAAO,O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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"]}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"utils.js"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/plugin-oas",
3
- "version": "3.4.5",
3
+ "version": "3.5.1",
4
4
  "description": "Generator swagger",
5
5
  "keywords": [
6
6
  "typescript",
@@ -75,19 +75,19 @@
75
75
  ],
76
76
  "dependencies": {
77
77
  "@stoplight/yaml": "^4.3.0",
78
- "remeda": "^2.19.0",
79
- "@kubb/core": "3.4.5",
80
- "@kubb/fs": "3.4.5",
81
- "@kubb/oas": "3.4.5",
82
- "@kubb/react": "3.4.5"
78
+ "remeda": "^2.19.1",
79
+ "@kubb/core": "3.5.1",
80
+ "@kubb/fs": "3.5.1",
81
+ "@kubb/oas": "3.5.1",
82
+ "@kubb/react": "3.5.1"
83
83
  },
84
84
  "devDependencies": {
85
85
  "@types/react": "^18.3.18",
86
86
  "react": "^18.3.1",
87
87
  "tsup": "^8.3.5",
88
88
  "typescript": "^5.7.3",
89
- "@kubb/config-ts": "3.4.5",
90
- "@kubb/config-tsup": "3.4.5"
89
+ "@kubb/config-ts": "3.5.1",
90
+ "@kubb/config-tsup": "3.5.1"
91
91
  },
92
92
  "peerDependencies": {
93
93
  "@kubb/react": "^3.0.0"
@@ -235,7 +235,7 @@ export class OperationGenerator<
235
235
 
236
236
  methods.forEach((method) => {
237
237
  const operation = oas.operation(path, method)
238
- if (operation && [this.#methods].some((methods) => method === operation.method)) {
238
+ if (operation && method === operation.method) {
239
239
  const isExcluded = this.#isExcluded(operation, method)
240
240
  const isIncluded = this.context.include ? this.#isIncluded(operation, method) : true
241
241
 
@@ -1,4 +1,5 @@
1
1
  import { camelCase } from '@kubb/core/transformers'
2
+ import { getBanner, getFooter } from '@kubb/plugin-oas/utils'
2
3
  import { createGenerator } from '../generator.tsx'
3
4
  import type { PluginOas } from '../types.ts'
4
5
 
@@ -24,8 +25,8 @@ export const jsonGenerator = createGenerator<PluginOas>({
24
25
  value: JSON.stringify(schema.value),
25
26
  },
26
27
  ],
27
- banner: plugin.options.output?.banner,
28
- format: plugin.options.output?.footer,
28
+ banner: getBanner({ oas: instance.context.oas, output: plugin.options.output }),
29
+ format: getFooter({ oas: instance.context.oas, output: plugin.options.output }),
29
30
  },
30
31
  ]
31
32
  },
package/src/plugin.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { FileManager, createPlugin } from '@kubb/core'
1
+ import { FileManager, type Group, createPlugin } from '@kubb/core'
2
2
 
3
3
  import { getSchemas } from './utils/getSchemas.ts'
4
4
  import { parseFromConfig } from './utils/parseFromConfig.ts'
@@ -6,6 +6,7 @@ import { parseFromConfig } from './utils/parseFromConfig.ts'
6
6
  import path from 'node:path'
7
7
  import type { Config } from '@kubb/core'
8
8
  import type { Logger } from '@kubb/core/logger'
9
+ import { camelCase } from '@kubb/core/transformers'
9
10
  import type { Oas } from '@kubb/oas'
10
11
  import { OperationGenerator } from './OperationGenerator.ts'
11
12
  import { SchemaGenerator } from './SchemaGenerator.ts'
@@ -19,6 +20,7 @@ export const pluginOas = createPlugin<PluginOas>((options) => {
19
20
  output = {
20
21
  path: 'schemas',
21
22
  },
23
+ group,
22
24
  validate = true,
23
25
  generators = [jsonGenerator],
24
26
  serverIndex,
@@ -84,6 +86,26 @@ export const pluginOas = createPlugin<PluginOas>((options) => {
84
86
  return path.resolve(root, output.path)
85
87
  }
86
88
 
89
+ if (group && (options?.group?.path || options?.group?.tag)) {
90
+ const groupName: Group['name'] = group?.name
91
+ ? group.name
92
+ : (ctx) => {
93
+ if (group?.type === 'path') {
94
+ return `${ctx.group.split('/')[1]}`
95
+ }
96
+ return `${camelCase(ctx.group)}Controller`
97
+ }
98
+
99
+ return path.resolve(
100
+ root,
101
+ output.path,
102
+ groupName({
103
+ group: group.type === 'path' ? options.group.path! : options.group.tag!,
104
+ }),
105
+ baseName,
106
+ )
107
+ }
108
+
87
109
  return path.resolve(root, output.path, baseName)
88
110
  },
89
111
  async buildStart() {
package/src/types.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { Output, Plugin } from '@kubb/core'
1
+ import type { Group, Output, Plugin } from '@kubb/core'
2
2
  import type { PluginFactoryOptions, ResolveNameParams } from '@kubb/core'
3
3
  import type * as KubbFile from '@kubb/fs/types'
4
4
 
@@ -32,7 +32,11 @@ export type Options = {
32
32
  * Specify the export location for the files and define the behavior of the output
33
33
  * @default { path: 'schemas', barrelType: 'named' }
34
34
  */
35
- output?: Output
35
+ output?: Output<Oas>
36
+ /**
37
+ * Group the JSON files based on the provided name.
38
+ */
39
+ group?: Group
36
40
  /**
37
41
  * Which server to use from the array of `servers.url[serverIndex]`
38
42
  * @example
@@ -149,7 +153,7 @@ export type Override<TOptions> = (ByTag | ByOperationId | ByPath | ByMethod | By
149
153
  }
150
154
 
151
155
  type ResolvedOptions = Options & {
152
- output: Output
156
+ output: Output<Oas>
153
157
  }
154
158
 
155
- export type PluginOas = PluginFactoryOptions<'plugin-oas', Options, ResolvedOptions, API, never>
159
+ export type PluginOas = PluginFactoryOptions<'plugin-oas', Options, ResolvedOptions, API, ResolvePathOptions>
@@ -0,0 +1,20 @@
1
+ import type { Output } from '@kubb/core'
2
+ import type { Oas } from '@kubb/oas'
3
+ import { isFunction } from 'remeda'
4
+
5
+ type Props = {
6
+ oas: Oas
7
+ output: Output<Oas>
8
+ }
9
+
10
+ export function getBanner({ output, oas }: Props) {
11
+ if (!output.banner) {
12
+ return undefined
13
+ }
14
+
15
+ if (isFunction(output.banner)) {
16
+ return output.banner(oas)
17
+ }
18
+
19
+ return output.banner
20
+ }
@@ -0,0 +1,20 @@
1
+ import type { Output } from '@kubb/core'
2
+ import type { Oas } from '@kubb/oas'
3
+ import { isFunction } from 'remeda'
4
+
5
+ type Props = {
6
+ oas: Oas
7
+ output: Output<Oas>
8
+ }
9
+
10
+ export function getFooter({ output, oas }: Props) {
11
+ if (!output.footer) {
12
+ return undefined
13
+ }
14
+
15
+ if (isFunction(output.footer)) {
16
+ return output.footer(oas)
17
+ }
18
+
19
+ return output.footer
20
+ }
@@ -4,5 +4,7 @@ export { getSchemaFactory } from './getSchemaFactory.ts'
4
4
  export type { GetSchemasProps } from './getSchemas.ts'
5
5
  export { getSchemas } from './getSchemas.ts'
6
6
  export { parseFromConfig } from './parseFromConfig.ts'
7
+ export { getBanner } from './getBanner.ts'
8
+ export { getFooter } from './getFooter.ts'
7
9
 
8
10
  export { isOptional } from '@kubb/oas'
@@ -1,29 +0,0 @@
1
- import { resolve } from 'node:path';
2
- import { URLPath } from '@kubb/core/utils';
3
- import { parse, Oas } from '@kubb/oas';
4
- import yaml from '@stoplight/yaml';
5
-
6
- // src/utils/parseFromConfig.ts
7
- function parseFromConfig(config, oasClass = Oas) {
8
- if ("data" in config.input) {
9
- if (typeof config.input.data === "object") {
10
- const api2 = JSON.parse(JSON.stringify(config.input.data));
11
- return parse(api2, oasClass);
12
- }
13
- try {
14
- const api2 = yaml.parse(config.input.data);
15
- return parse(api2, oasClass);
16
- } catch (e) {
17
- }
18
- const api = JSON.parse(JSON.stringify(config.input.data));
19
- return parse(api, oasClass);
20
- }
21
- if (new URLPath(config.input.path).isURL) {
22
- return parse(config.input.path, oasClass);
23
- }
24
- return parse(resolve(config.root, config.input.path), oasClass);
25
- }
26
-
27
- export { parseFromConfig };
28
- //# sourceMappingURL=chunk-BZOI3PL5.js.map
29
- //# sourceMappingURL=chunk-BZOI3PL5.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/utils/parseFromConfig.ts"],"names":["api"],"mappings":";;;;;;AAUO,SAAS,eAAA,CAAgB,MAAgB,EAAA,QAAA,GAAuB,GAAmB,EAAA;AACxF,EAAI,IAAA,MAAA,IAAU,OAAO,KAAO,EAAA;AAC1B,IAAA,IAAI,OAAO,MAAA,CAAO,KAAM,CAAA,IAAA,KAAS,QAAU,EAAA;AACzC,MAAMA,MAAAA,IAAAA,GAA4B,KAAK,KAAM,CAAA,IAAA,CAAK,UAAU,MAAO,CAAA,KAAA,CAAM,IAAI,CAAC,CAAA;AAC9E,MAAO,OAAA,KAAA,CAAMA,MAAK,QAAQ,CAAA;AAAA;AAG5B,IAAI,IAAA;AACF,MAAA,MAAMA,IAAc,GAAA,IAAA,CAAK,KAAM,CAAA,MAAA,CAAO,MAAM,IAAc,CAAA;AAE1D,MAAO,OAAA,KAAA,CAAMA,MAAK,QAAQ,CAAA;AAAA,aACnB,CAAG,EAAA;AAAA;AAIZ,IAAM,MAAA,GAAA,GAA4B,KAAK,KAAM,CAAA,IAAA,CAAK,UAAU,MAAO,CAAA,KAAA,CAAM,IAAI,CAAC,CAAA;AAE9E,IAAO,OAAA,KAAA,CAAM,KAAK,QAAQ,CAAA;AAAA;AAG5B,EAAA,IAAI,IAAI,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","file":"chunk-BZOI3PL5.js","sourcesContent":["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"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/generator.tsx","../src/generators/jsonGenerator.ts"],"names":["createRoot","App","jsx","Oas","camelCase"],"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,EAAA;AAAA,OACF;AAEA,MAAA,OAAO,IAAK,CAAA,KAAA;AAAA,KACd;AAAA,IACA,MAAM,SAAU,CAAA,EAAE,QAAU,EAAA,SAAA,EAAW,SAAW,EAAA;AAChD,MAAI,IAAA,CAAC,aAAa,SAAW,EAAA;AAC3B,QAAA,OAAO,EAAC;AAAA;AAGV,MAAA,MAAM,EAAE,aAAe,EAAA,GAAA,EAAK,MAAQ,EA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,EAAA;AAAA;AACjC,KACF;AAAA;AAEJ,CAAC","file":"chunk-FSCYFGYN.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 { 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: plugin.options.output?.banner,\n format: plugin.options.output?.footer,\n },\n ]\n },\n})\n"]}
@@ -1,35 +0,0 @@
1
- 'use strict';
2
-
3
- var path = require('path');
4
- var utils = require('@kubb/core/utils');
5
- var oas = require('@kubb/oas');
6
- var yaml = require('@stoplight/yaml');
7
-
8
- function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
9
-
10
- var yaml__default = /*#__PURE__*/_interopDefault(yaml);
11
-
12
- // src/utils/parseFromConfig.ts
13
- function parseFromConfig(config, oasClass = oas.Oas) {
14
- if ("data" in config.input) {
15
- if (typeof config.input.data === "object") {
16
- const api2 = JSON.parse(JSON.stringify(config.input.data));
17
- return oas.parse(api2, oasClass);
18
- }
19
- try {
20
- const api2 = yaml__default.default.parse(config.input.data);
21
- return oas.parse(api2, oasClass);
22
- } catch (e) {
23
- }
24
- const api = JSON.parse(JSON.stringify(config.input.data));
25
- return oas.parse(api, oasClass);
26
- }
27
- if (new utils.URLPath(config.input.path).isURL) {
28
- return oas.parse(config.input.path, oasClass);
29
- }
30
- return oas.parse(path.resolve(config.root, config.input.path), oasClass);
31
- }
32
-
33
- exports.parseFromConfig = parseFromConfig;
34
- //# sourceMappingURL=chunk-QXUSUL7H.cjs.map
35
- //# sourceMappingURL=chunk-QXUSUL7H.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/utils/parseFromConfig.ts"],"names":["Oas","api","parse","yaml","URLPath","resolve"],"mappings":";;;;;;;;;;;;AAUO,SAAS,eAAA,CAAgB,MAAgB,EAAA,QAAA,GAAuBA,OAAmB,EAAA;AACxF,EAAI,IAAA,MAAA,IAAU,OAAO,KAAO,EAAA;AAC1B,IAAA,IAAI,OAAO,MAAA,CAAO,KAAM,CAAA,IAAA,KAAS,QAAU,EAAA;AACzC,MAAMC,MAAAA,IAAAA,GAA4B,KAAK,KAAM,CAAA,IAAA,CAAK,UAAU,MAAO,CAAA,KAAA,CAAM,IAAI,CAAC,CAAA;AAC9E,MAAO,OAAAC,SAAA,CAAMD,MAAK,QAAQ,CAAA;AAAA;AAG5B,IAAI,IAAA;AACF,MAAA,MAAMA,IAAc,GAAAE,qBAAA,CAAK,KAAM,CAAA,MAAA,CAAO,MAAM,IAAc,CAAA;AAE1D,MAAO,OAAAD,SAAA,CAAMD,MAAK,QAAQ,CAAA;AAAA,aACnB,CAAG,EAAA;AAAA;AAIZ,IAAM,MAAA,GAAA,GAA4B,KAAK,KAAM,CAAA,IAAA,CAAK,UAAU,MAAO,CAAA,KAAA,CAAM,IAAI,CAAC,CAAA;AAE9E,IAAO,OAAAC,SAAA,CAAM,KAAK,QAAQ,CAAA;AAAA;AAG5B,EAAA,IAAI,IAAIE,aAAQ,CAAA,MAAA,CAAO,KAAM,CAAA,IAAI,EAAE,KAAO,EAAA;AACxC,IAAA,OAAOF,SAAM,CAAA,MAAA,CAAO,KAAM,CAAA,IAAA,EAAM,QAAQ,CAAA;AAAA;AAG1C,EAAO,OAAAA,SAAA,CAAMG,aAAQ,MAAO,CAAA,IAAA,EAAM,OAAO,KAAM,CAAA,IAAI,GAAG,QAAQ,CAAA;AAChE","file":"chunk-QXUSUL7H.cjs","sourcesContent":["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"]}
@@ -1 +0,0 @@
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,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,OAAO,UAAW,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,4BACF,GAAI,EAAA,EAAA,aAAA,EAA8B,QAAgB,IACjD,EAAA,QAAA,kBAAA,GAAA,CAAC,OAAI,GAAU,EAAA,UAAA,EAAwB,SAAW,EAAA,QAAA,EAChD,8BAAC,SAAU,EAAA,EAAA,UAAA,EA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AA,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,MAAO,CAAA,OAAA,CAAQ,MAAQ,EAAA,MAAA;AAAA,QAC/B,MAAA,EAAQ,MAAO,CAAA,OAAA,CAAQ,MAAQ,EAAA;AAAA;AACjC,KACF;AAAA;AAEJ,CAAC","file":"chunk-WBHFV7C2.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 { 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: plugin.options.output?.banner,\n format: plugin.options.output?.footer,\n },\n ]\n },\n})\n"]}