@kubb/plugin-oas 4.4.0 → 4.5.0

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 (109) hide show
  1. package/dist/{SchemaGenerator-7wBwdv8G.js → SchemaGenerator-BwYbrh7a.js} +93 -36
  2. package/dist/SchemaGenerator-BwYbrh7a.js.map +1 -0
  3. package/dist/{SchemaGenerator-DzVHk6OP.cjs → SchemaGenerator-C81yEgKY.cjs} +114 -37
  4. package/dist/SchemaGenerator-C81yEgKY.cjs.map +1 -0
  5. package/dist/{SchemaMapper-DoL-a6qq.cjs → SchemaMapper-BUV8vhg0.cjs} +1 -1
  6. package/dist/SchemaMapper-BUV8vhg0.cjs.map +1 -0
  7. package/dist/{SchemaMapper-CqBW0VOy.d.ts → SchemaMapper-CgGWx6jF.d.cts} +15 -116
  8. package/dist/{SchemaMapper-MiRB5_Zp.d.cts → SchemaMapper-Cj3vjPGs.d.ts} +15 -116
  9. package/dist/{SchemaMapper-Cx4X1al6.js → SchemaMapper-D30tqRoX.js} +1 -1
  10. package/dist/SchemaMapper-D30tqRoX.js.map +1 -0
  11. package/dist/{OperationGenerator-BZPWkxw4.d.ts → createGenerator-BvCDyuKS.d.ts} +128 -191
  12. package/dist/{OperationGenerator-CJTAer7l.d.cts → createGenerator-CPNglV1d.d.cts} +129 -192
  13. package/dist/{generators-C61FxVIj.js → generators-CJDEf8Kn.js} +6 -6
  14. package/dist/generators-CJDEf8Kn.js.map +1 -0
  15. package/dist/{generators-B27La9Vd.cjs → generators-udGOxdUV.cjs} +6 -6
  16. package/dist/generators-udGOxdUV.cjs.map +1 -0
  17. package/dist/generators.cjs +2 -7
  18. package/dist/generators.d.cts +8 -3
  19. package/dist/generators.d.ts +8 -3
  20. package/dist/generators.js +3 -5
  21. package/dist/{getFooter-D5MdeUVv.js → getFooter-CV73pVXj.js} +2 -2
  22. package/dist/{getFooter-D5MdeUVv.js.map → getFooter-CV73pVXj.js.map} +1 -1
  23. package/dist/{getFooter-CwjCW4h5.cjs → getFooter-DPh4lxBH.cjs} +3 -3
  24. package/dist/{getFooter-CwjCW4h5.cjs.map → getFooter-DPh4lxBH.cjs.map} +1 -1
  25. package/dist/getSchemas-32BHoMO-.js +100 -0
  26. package/dist/getSchemas-32BHoMO-.js.map +1 -0
  27. package/dist/getSchemas-Cl0TZ4XY.cjs +113 -0
  28. package/dist/getSchemas-Cl0TZ4XY.cjs.map +1 -0
  29. package/dist/hooks.cjs +6 -47
  30. package/dist/hooks.cjs.map +1 -1
  31. package/dist/hooks.d.cts +11 -45
  32. package/dist/hooks.d.ts +11 -45
  33. package/dist/hooks.js +8 -46
  34. package/dist/hooks.js.map +1 -1
  35. package/dist/index.cjs +37 -32
  36. package/dist/index.cjs.map +1 -1
  37. package/dist/index.d.cts +58 -3
  38. package/dist/index.d.ts +58 -3
  39. package/dist/index.js +32 -24
  40. package/dist/index.js.map +1 -1
  41. package/dist/mocks.cjs +1 -1
  42. package/dist/mocks.d.cts +1 -1
  43. package/dist/mocks.d.ts +1 -1
  44. package/dist/mocks.js +1 -1
  45. package/dist/{parseFromConfig-CqiiLCPe.js → parseFromConfig-BkUoWC2U.js} +1 -1
  46. package/dist/parseFromConfig-BkUoWC2U.js.map +1 -0
  47. package/dist/{parseFromConfig-RR31a98-.cjs → parseFromConfig-EjsCZ0-8.cjs} +1 -1
  48. package/dist/parseFromConfig-EjsCZ0-8.cjs.map +1 -0
  49. package/dist/utils.cjs +3 -3
  50. package/dist/utils.cjs.map +1 -1
  51. package/dist/utils.d.cts +28 -24
  52. package/dist/utils.d.ts +28 -24
  53. package/dist/utils.js +3 -3
  54. package/dist/utils.js.map +1 -1
  55. package/package.json +14 -17
  56. package/src/OperationGenerator.ts +27 -14
  57. package/src/SchemaGenerator.ts +25 -47
  58. package/src/SchemaMapper.ts +3 -1
  59. package/src/generators/createGenerator.ts +1 -1
  60. package/src/generators/index.ts +0 -1
  61. package/src/generators/jsonGenerator.ts +4 -4
  62. package/src/generators/types.ts +13 -14
  63. package/src/hooks/index.ts +1 -4
  64. package/src/hooks/useOas.ts +5 -11
  65. package/src/hooks/useOperationManager.ts +3 -5
  66. package/src/hooks/useSchemaManager.ts +1 -1
  67. package/src/index.ts +1 -1
  68. package/src/types.ts +1 -1
  69. package/src/utils/getBanner.ts +1 -1
  70. package/src/utils/getParams.ts +1 -2
  71. package/src/utils/getSchemaFactory.ts +1 -2
  72. package/src/utils/getSchemas.ts +89 -15
  73. package/src/utils/index.ts +3 -4
  74. package/src/utils/parseFromConfig.ts +2 -6
  75. package/src/utils.tsx +101 -0
  76. package/dist/Oas-BzrQ6RGC.cjs +0 -80
  77. package/dist/Oas-BzrQ6RGC.cjs.map +0 -1
  78. package/dist/Oas-CIeHKOo0.js +0 -60
  79. package/dist/Oas-CIeHKOo0.js.map +0 -1
  80. package/dist/Schema-CjraJhJi.d.ts +0 -38
  81. package/dist/Schema-zcZF0UIp.d.cts +0 -38
  82. package/dist/SchemaGenerator-7wBwdv8G.js.map +0 -1
  83. package/dist/SchemaGenerator-DzVHk6OP.cjs.map +0 -1
  84. package/dist/SchemaMapper-Cx4X1al6.js.map +0 -1
  85. package/dist/SchemaMapper-DoL-a6qq.cjs.map +0 -1
  86. package/dist/components.cjs +0 -5
  87. package/dist/components.d.cts +0 -42
  88. package/dist/components.d.ts +0 -42
  89. package/dist/components.js +0 -3
  90. package/dist/generators-B27La9Vd.cjs.map +0 -1
  91. package/dist/generators-C61FxVIj.js.map +0 -1
  92. package/dist/getSchemas-Bdg6n9Qk.js +0 -55
  93. package/dist/getSchemas-Bdg6n9Qk.js.map +0 -1
  94. package/dist/getSchemas-DY8s2CSl.cjs +0 -68
  95. package/dist/getSchemas-DY8s2CSl.cjs.map +0 -1
  96. package/dist/parseFromConfig-CqiiLCPe.js.map +0 -1
  97. package/dist/parseFromConfig-RR31a98-.cjs.map +0 -1
  98. package/dist/utils-BnkB1ikY.js +0 -99
  99. package/dist/utils-BnkB1ikY.js.map +0 -1
  100. package/dist/utils-nzdccPlU.cjs +0 -119
  101. package/dist/utils-nzdccPlU.cjs.map +0 -1
  102. package/src/components/Oas.tsx +0 -35
  103. package/src/components/Operation.tsx +0 -20
  104. package/src/components/Schema.tsx +0 -38
  105. package/src/components/index.ts +0 -3
  106. package/src/generators/utils.tsx +0 -114
  107. package/src/hooks/useOperation.ts +0 -18
  108. package/src/hooks/useOperations.ts +0 -40
  109. package/src/hooks/useSchema.ts +0 -16
@@ -1,42 +0,0 @@
1
- import { P as Oas$1, t as OperationGenerator, z as Operation$1 } from "./OperationGenerator-CJTAer7l.cjs";
2
- import "./SchemaMapper-MiRB5_Zp.cjs";
3
- import { t as Schema } from "./Schema-zcZF0UIp.cjs";
4
- import { KubbNode } from "@kubb/react-fabric/types";
5
-
6
- //#region src/components/Operation.d.ts
7
- type Props$1 = {
8
- operation: Operation$1;
9
- children?: KubbNode;
10
- };
11
- declare function Operation({
12
- operation,
13
- children
14
- }: Props$1): KubbNode;
15
- declare namespace Operation {
16
- var Context;
17
- }
18
- //#endregion
19
- //#region src/components/Oas.d.ts
20
- type Props = {
21
- oas: Oas$1;
22
- operations?: Operation$1[];
23
- /**
24
- * @deprecated
25
- */
26
- generator?: Omit<OperationGenerator, 'build'>;
27
- children?: KubbNode;
28
- };
29
- declare function Oas({
30
- oas,
31
- children,
32
- operations,
33
- generator
34
- }: Props): KubbNode;
35
- declare namespace Oas {
36
- var Context;
37
- var Operation: typeof Operation;
38
- var Schema: typeof Schema;
39
- }
40
- //#endregion
41
- export { Oas, Operation, Schema };
42
- //# sourceMappingURL=components.d.cts.map
@@ -1,42 +0,0 @@
1
- import { P as Oas$1, t as OperationGenerator, z as Operation$1 } from "./OperationGenerator-BZPWkxw4.js";
2
- import "./SchemaMapper-CqBW0VOy.js";
3
- import { t as Schema } from "./Schema-CjraJhJi.js";
4
- import { KubbNode } from "@kubb/react-fabric/types";
5
-
6
- //#region src/components/Operation.d.ts
7
- type Props$1 = {
8
- operation: Operation$1;
9
- children?: KubbNode;
10
- };
11
- declare function Operation({
12
- operation,
13
- children
14
- }: Props$1): KubbNode;
15
- declare namespace Operation {
16
- var Context;
17
- }
18
- //#endregion
19
- //#region src/components/Oas.d.ts
20
- type Props = {
21
- oas: Oas$1;
22
- operations?: Operation$1[];
23
- /**
24
- * @deprecated
25
- */
26
- generator?: Omit<OperationGenerator, 'build'>;
27
- children?: KubbNode;
28
- };
29
- declare function Oas({
30
- oas,
31
- children,
32
- operations,
33
- generator
34
- }: Props): KubbNode;
35
- declare namespace Oas {
36
- var Context;
37
- var Operation: typeof Operation;
38
- var Schema: typeof Schema;
39
- }
40
- //#endregion
41
- export { Oas, Operation, Schema };
42
- //# sourceMappingURL=components.d.ts.map
@@ -1,3 +0,0 @@
1
- import { n as Schema, r as Operation, t as Oas } from "./Oas-CIeHKOo0.js";
2
-
3
- export { Oas, Operation, Schema };
@@ -1 +0,0 @@
1
- {"version":3,"file":"generators-B27La9Vd.cjs","names":["getBanner","getFooter"],"sources":["../src/generators/createGenerator.ts","../src/generators/createReactGenerator.ts","../src/generators/jsonGenerator.ts"],"sourcesContent":["import type { PluginFactoryOptions } from '@kubb/core'\nimport type { KubbFile } from '@kubb/core/fs'\nimport type { OperationProps, OperationsProps, SchemaProps } from './types.ts'\n\ntype UserGenerator<TOptions extends PluginFactoryOptions> = {\n name: string\n operations?: (props: OperationsProps<TOptions>) => Promise<KubbFile.File[]>\n operation?: (props: OperationProps<TOptions>) => Promise<KubbFile.File[]>\n schema?: (props: SchemaProps<TOptions>) => Promise<KubbFile.File[]>\n}\n\nexport type CoreGenerator<TOptions extends PluginFactoryOptions> = {\n name: string\n type: 'core'\n operations: (props: OperationsProps<TOptions>) => Promise<KubbFile.File[]>\n operation: (props: OperationProps<TOptions>) => Promise<KubbFile.File[]>\n schema: (props: SchemaProps<TOptions>) => Promise<KubbFile.File[]>\n}\n\nexport function createGenerator<TOptions extends PluginFactoryOptions>(generator: UserGenerator<TOptions>): CoreGenerator<TOptions> {\n return {\n type: 'core',\n async operations() {\n return []\n },\n async operation() {\n return []\n },\n async schema() {\n return []\n },\n ...generator,\n }\n}\n","import type { PluginFactoryOptions } from '@kubb/core'\nimport type { KubbNode } from '@kubb/react-fabric/types'\nimport type { OperationProps, OperationsProps, SchemaProps } from './types.ts'\n\ntype UserGenerator<TOptions extends PluginFactoryOptions> = {\n name: string\n Operations?: (props: OperationsProps<TOptions>) => KubbNode\n Operation?: (props: OperationProps<TOptions>) => KubbNode\n Schema?: (props: SchemaProps<TOptions>) => KubbNode\n}\n\nexport type ReactGenerator<TOptions extends PluginFactoryOptions> = {\n name: string\n type: 'react'\n Operations: (props: OperationsProps<TOptions>) => KubbNode\n Operation: (props: OperationProps<TOptions>) => KubbNode\n Schema: (props: SchemaProps<TOptions>) => KubbNode\n}\n\n/****\n * Creates a generator that uses React component functions to generate files for OpenAPI operations and schemas.\n *\n * The returned generator exposes async methods for generating files from operations, a single operation, or a schema, using the corresponding React components if provided. If a component is not defined, the method returns an empty array.\n *\n * @returns A generator object with async methods for operations, operation, and schema file generation.\n */\nexport function createReactGenerator<TOptions extends PluginFactoryOptions>(generator: UserGenerator<TOptions>): ReactGenerator<TOptions> {\n return {\n type: 'react',\n Operations() {\n return null\n },\n Operation() {\n return null\n },\n Schema() {\n return null\n },\n ...generator,\n }\n}\n","import { camelCase } from '@kubb/core/transformers'\nimport type { PluginOas } from '../types.ts'\nimport { getBanner } from '../utils/getBanner.ts'\nimport { getFooter } from '../utils/getFooter.ts'\nimport { createGenerator } from './createGenerator.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({\n oas: instance.context.oas,\n output: plugin.options.output,\n config: pluginManager.config,\n }),\n format: getFooter({ oas: instance.context.oas, output: plugin.options.output }),\n },\n ]\n },\n})\n"],"mappings":";;;;;;AAmBA,SAAgB,gBAAuD,WAA6D;AAClI,QAAO;EACL,MAAM;EACN,MAAM,aAAa;AACjB,UAAO,EAAE;;EAEX,MAAM,YAAY;AAChB,UAAO,EAAE;;EAEX,MAAM,SAAS;AACb,UAAO,EAAE;;EAEX,GAAG;EACJ;;;;;;;;;;;;ACNH,SAAgB,qBAA4D,WAA8D;AACxI,QAAO;EACL,MAAM;EACN,aAAa;AACX,UAAO;;EAET,YAAY;AACV,UAAO;;EAET,SAAS;AACP,UAAO;;EAET,GAAG;EACJ;;;;;ACjCH,MAAa,gBAAgB,gBAA2B;CACtD,MAAM;CACN,MAAM,OAAO,EAAE,QAAQ,YAAY;EACjC,MAAM,EAAE,eAAe,WAAW,SAAS;AAQ3C,SAAO,CACL;GACE,GATS,cAAc,QAAQ;IACjC,8CAAgB,OAAO,KAAK;IAC5B,SAAS;IACT,MAAM;IACN,WAAW,OAAO;IACnB,CAAC;GAKE,SAAS,CACP;IACE,8CAAgB,OAAO,KAAK;IAC5B,cAAc;IACd,aAAa;IACb,OAAO,KAAK,UAAU,OAAO,MAAM;IACpC,CACF;GACD,QAAQA,4BAAU;IAChB,KAAK,SAAS,QAAQ;IACtB,QAAQ,OAAO,QAAQ;IACvB,QAAQ,cAAc;IACvB,CAAC;GACF,QAAQC,4BAAU;IAAE,KAAK,SAAS,QAAQ;IAAK,QAAQ,OAAO,QAAQ;IAAQ,CAAC;GAChF,CACF;;CAEJ,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"generators-C61FxVIj.js","names":[],"sources":["../src/generators/createGenerator.ts","../src/generators/createReactGenerator.ts","../src/generators/jsonGenerator.ts"],"sourcesContent":["import type { PluginFactoryOptions } from '@kubb/core'\nimport type { KubbFile } from '@kubb/core/fs'\nimport type { OperationProps, OperationsProps, SchemaProps } from './types.ts'\n\ntype UserGenerator<TOptions extends PluginFactoryOptions> = {\n name: string\n operations?: (props: OperationsProps<TOptions>) => Promise<KubbFile.File[]>\n operation?: (props: OperationProps<TOptions>) => Promise<KubbFile.File[]>\n schema?: (props: SchemaProps<TOptions>) => Promise<KubbFile.File[]>\n}\n\nexport type CoreGenerator<TOptions extends PluginFactoryOptions> = {\n name: string\n type: 'core'\n operations: (props: OperationsProps<TOptions>) => Promise<KubbFile.File[]>\n operation: (props: OperationProps<TOptions>) => Promise<KubbFile.File[]>\n schema: (props: SchemaProps<TOptions>) => Promise<KubbFile.File[]>\n}\n\nexport function createGenerator<TOptions extends PluginFactoryOptions>(generator: UserGenerator<TOptions>): CoreGenerator<TOptions> {\n return {\n type: 'core',\n async operations() {\n return []\n },\n async operation() {\n return []\n },\n async schema() {\n return []\n },\n ...generator,\n }\n}\n","import type { PluginFactoryOptions } from '@kubb/core'\nimport type { KubbNode } from '@kubb/react-fabric/types'\nimport type { OperationProps, OperationsProps, SchemaProps } from './types.ts'\n\ntype UserGenerator<TOptions extends PluginFactoryOptions> = {\n name: string\n Operations?: (props: OperationsProps<TOptions>) => KubbNode\n Operation?: (props: OperationProps<TOptions>) => KubbNode\n Schema?: (props: SchemaProps<TOptions>) => KubbNode\n}\n\nexport type ReactGenerator<TOptions extends PluginFactoryOptions> = {\n name: string\n type: 'react'\n Operations: (props: OperationsProps<TOptions>) => KubbNode\n Operation: (props: OperationProps<TOptions>) => KubbNode\n Schema: (props: SchemaProps<TOptions>) => KubbNode\n}\n\n/****\n * Creates a generator that uses React component functions to generate files for OpenAPI operations and schemas.\n *\n * The returned generator exposes async methods for generating files from operations, a single operation, or a schema, using the corresponding React components if provided. If a component is not defined, the method returns an empty array.\n *\n * @returns A generator object with async methods for operations, operation, and schema file generation.\n */\nexport function createReactGenerator<TOptions extends PluginFactoryOptions>(generator: UserGenerator<TOptions>): ReactGenerator<TOptions> {\n return {\n type: 'react',\n Operations() {\n return null\n },\n Operation() {\n return null\n },\n Schema() {\n return null\n },\n ...generator,\n }\n}\n","import { camelCase } from '@kubb/core/transformers'\nimport type { PluginOas } from '../types.ts'\nimport { getBanner } from '../utils/getBanner.ts'\nimport { getFooter } from '../utils/getFooter.ts'\nimport { createGenerator } from './createGenerator.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({\n oas: instance.context.oas,\n output: plugin.options.output,\n config: pluginManager.config,\n }),\n format: getFooter({ oas: instance.context.oas, output: plugin.options.output }),\n },\n ]\n },\n})\n"],"mappings":";;;;AAmBA,SAAgB,gBAAuD,WAA6D;AAClI,QAAO;EACL,MAAM;EACN,MAAM,aAAa;AACjB,UAAO,EAAE;;EAEX,MAAM,YAAY;AAChB,UAAO,EAAE;;EAEX,MAAM,SAAS;AACb,UAAO,EAAE;;EAEX,GAAG;EACJ;;;;;;;;;;;;ACNH,SAAgB,qBAA4D,WAA8D;AACxI,QAAO;EACL,MAAM;EACN,aAAa;AACX,UAAO;;EAET,YAAY;AACV,UAAO;;EAET,SAAS;AACP,UAAO;;EAET,GAAG;EACJ;;;;;ACjCH,MAAa,gBAAgB,gBAA2B;CACtD,MAAM;CACN,MAAM,OAAO,EAAE,QAAQ,YAAY;EACjC,MAAM,EAAE,eAAe,WAAW,SAAS;AAQ3C,SAAO,CACL;GACE,GATS,cAAc,QAAQ;IACjC,MAAM,UAAU,OAAO,KAAK;IAC5B,SAAS;IACT,MAAM;IACN,WAAW,OAAO;IACnB,CAAC;GAKE,SAAS,CACP;IACE,MAAM,UAAU,OAAO,KAAK;IAC5B,cAAc;IACd,aAAa;IACb,OAAO,KAAK,UAAU,OAAO,MAAM;IACpC,CACF;GACD,QAAQ,UAAU;IAChB,KAAK,SAAS,QAAQ;IACtB,QAAQ,OAAO,QAAQ;IACvB,QAAQ,cAAc;IACvB,CAAC;GACF,QAAQ,UAAU;IAAE,KAAK,SAAS,QAAQ;IAAK,QAAQ,OAAO,QAAQ;IAAQ,CAAC;GAChF,CACF;;CAEJ,CAAC"}
@@ -1,55 +0,0 @@
1
- import { isOpenApiV3_1Document } from "@kubb/oas";
2
-
3
- //#region src/utils/getSchemaFactory.ts
4
- /**
5
- * Creates a factory function that generates a versioned OpenAPI schema result.
6
- *
7
- * The returned function accepts an optional schema object and produces a {@link SchemaResult} containing the dereferenced schema and the OpenAPI version ('3.0' or '3.1').
8
- *
9
- * @returns A function that takes an optional schema and returns a versioned schema result.
10
- */
11
- function getSchemaFactory(oas) {
12
- return (schema) => {
13
- const version = isOpenApiV3_1Document(oas.api) ? "3.1" : "3.0";
14
- return {
15
- schemaObject: oas.dereferenceWithRef(schema),
16
- version
17
- };
18
- };
19
- }
20
-
21
- //#endregion
22
- //#region src/utils/getSchemas.ts
23
- function getSchemas({ oas, contentType, includes = [
24
- "schemas",
25
- "requestBodies",
26
- "responses"
27
- ] }) {
28
- const components = oas.getDefinition().components;
29
- let schemas = {};
30
- if (includes.includes("schemas")) schemas = {
31
- ...schemas,
32
- ...components?.schemas || {}
33
- };
34
- const requestBodies = components?.requestBodies || {};
35
- if (includes.includes("responses")) {
36
- const responses = components?.responses || {};
37
- Object.entries(responses).forEach(([name, response]) => {
38
- if (response.content && !schemas[name]) {
39
- const firstContentType = Object.keys(response.content)[0] || "application/json";
40
- schemas[name] = response.content?.[contentType || firstContentType]?.schema;
41
- }
42
- });
43
- }
44
- if (includes.includes("requestBodies")) Object.entries(requestBodies).forEach(([name, request]) => {
45
- if (request.content && !schemas[name]) {
46
- const firstContentType = Object.keys(request.content)[0] || "application/json";
47
- schemas[name] = request.content?.[contentType || firstContentType]?.schema;
48
- }
49
- });
50
- return schemas;
51
- }
52
-
53
- //#endregion
54
- export { getSchemaFactory as n, getSchemas as t };
55
- //# sourceMappingURL=getSchemas-Bdg6n9Qk.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getSchemas-Bdg6n9Qk.js","names":["schemas: Record<string, OasTypes.SchemaObject>"],"sources":["../src/utils/getSchemaFactory.ts","../src/utils/getSchemas.ts"],"sourcesContent":["import { isOpenApiV3_1Document } from '@kubb/oas'\n\nimport type { Oas, OpenAPIV3, OpenAPIV3_1, SchemaObject } from '@kubb/oas'\n\n/**\n * Make it possible to narrow down the schema based on a specific version(3 or 3.1)\n */\ntype SchemaResult<TWithRef extends boolean = false> =\n | {\n schemaObject?: (TWithRef extends true ? OpenAPIV3.SchemaObject | OpenAPIV3.ReferenceObject : OpenAPIV3.SchemaObject) & {\n nullable?: boolean\n 'x-nullable'?: boolean\n }\n version: '3.0'\n }\n | {\n schemaObject?: (TWithRef extends true ? OpenAPIV3_1.SchemaObject | OpenAPIV3_1.ReferenceObject : OpenAPIV3_1.SchemaObject) & {\n nullable?: boolean\n 'x-nullable'?: boolean\n }\n version: '3.1'\n }\n\n/**\n * Creates a factory function that generates a versioned OpenAPI schema result.\n *\n * The returned function accepts an optional schema object and produces a {@link SchemaResult} containing the dereferenced schema and the OpenAPI version ('3.0' or '3.1').\n *\n * @returns A function that takes an optional schema and returns a versioned schema result.\n */\nexport function getSchemaFactory<TWithRef extends boolean = false>(oas: Oas): (schema?: SchemaObject) => SchemaResult<TWithRef> {\n return (schema?: SchemaObject) => {\n const version = isOpenApiV3_1Document(oas.api) ? '3.1' : '3.0'\n\n return {\n schemaObject: oas.dereferenceWithRef(schema),\n version,\n } as SchemaResult<TWithRef>\n }\n}\n","import type { Oas, OasTypes, contentType } from '@kubb/oas'\n\ntype Mode = 'schemas' | 'responses' | 'requestBodies'\n\ntype GetSchemasProps = {\n oas: Oas\n contentType?: contentType\n includes?: Mode[]\n}\n\nexport function getSchemas({ oas, contentType, includes = ['schemas', 'requestBodies', 'responses'] }: GetSchemasProps): Record<string, OasTypes.SchemaObject> {\n const components = oas.getDefinition().components\n\n let schemas: Record<string, OasTypes.SchemaObject> = {}\n\n if (includes.includes('schemas')) {\n schemas = {\n ...schemas,\n ...((components?.schemas as Record<string, OasTypes.SchemaObject>) || {}),\n }\n }\n\n const requestBodies = components?.requestBodies || {}\n if (includes.includes('responses')) {\n const responses = components?.responses || {}\n\n Object.entries(responses).forEach(([name, response]: [string, OasTypes.ResponseObject]) => {\n if (response.content && !schemas[name]) {\n const firstContentType = Object.keys(response.content)[0] || 'application/json'\n schemas[name] = response.content?.[contentType || firstContentType]?.schema as OasTypes.SchemaObject\n }\n })\n }\n\n if (includes.includes('requestBodies')) {\n Object.entries(requestBodies).forEach(([name, request]: [string, OasTypes.RequestBodyObject]) => {\n if (request.content && !schemas[name]) {\n const firstContentType = Object.keys(request.content)[0] || 'application/json'\n schemas[name] = request.content?.[contentType || firstContentType]?.schema as OasTypes.SchemaObject\n }\n })\n }\n\n return schemas\n}\n"],"mappings":";;;;;;;;;;AA8BA,SAAgB,iBAAmD,KAA6D;AAC9H,SAAQ,WAA0B;EAChC,MAAM,UAAU,sBAAsB,IAAI,IAAI,GAAG,QAAQ;AAEzD,SAAO;GACL,cAAc,IAAI,mBAAmB,OAAO;GAC5C;GACD;;;;;;AC3BL,SAAgB,WAAW,EAAE,KAAK,aAAa,WAAW;CAAC;CAAW;CAAiB;CAAY,IAA4D;CAC7J,MAAM,aAAa,IAAI,eAAe,CAAC;CAEvC,IAAIA,UAAiD,EAAE;AAEvD,KAAI,SAAS,SAAS,UAAU,CAC9B,WAAU;EACR,GAAG;EACH,GAAK,YAAY,WAAqD,EAAE;EACzE;CAGH,MAAM,gBAAgB,YAAY,iBAAiB,EAAE;AACrD,KAAI,SAAS,SAAS,YAAY,EAAE;EAClC,MAAM,YAAY,YAAY,aAAa,EAAE;AAE7C,SAAO,QAAQ,UAAU,CAAC,SAAS,CAAC,MAAM,cAAiD;AACzF,OAAI,SAAS,WAAW,CAAC,QAAQ,OAAO;IACtC,MAAM,mBAAmB,OAAO,KAAK,SAAS,QAAQ,CAAC,MAAM;AAC7D,YAAQ,QAAQ,SAAS,UAAU,eAAe,mBAAmB;;IAEvE;;AAGJ,KAAI,SAAS,SAAS,gBAAgB,CACpC,QAAO,QAAQ,cAAc,CAAC,SAAS,CAAC,MAAM,aAAmD;AAC/F,MAAI,QAAQ,WAAW,CAAC,QAAQ,OAAO;GACrC,MAAM,mBAAmB,OAAO,KAAK,QAAQ,QAAQ,CAAC,MAAM;AAC5D,WAAQ,QAAQ,QAAQ,UAAU,eAAe,mBAAmB;;GAEtE;AAGJ,QAAO"}
@@ -1,68 +0,0 @@
1
- const require_chunk = require('./chunk-CUT6urMc.cjs');
2
- let __kubb_oas = require("@kubb/oas");
3
- __kubb_oas = require_chunk.__toESM(__kubb_oas);
4
-
5
- //#region src/utils/getSchemaFactory.ts
6
- /**
7
- * Creates a factory function that generates a versioned OpenAPI schema result.
8
- *
9
- * The returned function accepts an optional schema object and produces a {@link SchemaResult} containing the dereferenced schema and the OpenAPI version ('3.0' or '3.1').
10
- *
11
- * @returns A function that takes an optional schema and returns a versioned schema result.
12
- */
13
- function getSchemaFactory(oas) {
14
- return (schema) => {
15
- const version = (0, __kubb_oas.isOpenApiV3_1Document)(oas.api) ? "3.1" : "3.0";
16
- return {
17
- schemaObject: oas.dereferenceWithRef(schema),
18
- version
19
- };
20
- };
21
- }
22
-
23
- //#endregion
24
- //#region src/utils/getSchemas.ts
25
- function getSchemas({ oas, contentType, includes = [
26
- "schemas",
27
- "requestBodies",
28
- "responses"
29
- ] }) {
30
- const components = oas.getDefinition().components;
31
- let schemas = {};
32
- if (includes.includes("schemas")) schemas = {
33
- ...schemas,
34
- ...components?.schemas || {}
35
- };
36
- const requestBodies = components?.requestBodies || {};
37
- if (includes.includes("responses")) {
38
- const responses = components?.responses || {};
39
- Object.entries(responses).forEach(([name, response]) => {
40
- if (response.content && !schemas[name]) {
41
- const firstContentType = Object.keys(response.content)[0] || "application/json";
42
- schemas[name] = response.content?.[contentType || firstContentType]?.schema;
43
- }
44
- });
45
- }
46
- if (includes.includes("requestBodies")) Object.entries(requestBodies).forEach(([name, request]) => {
47
- if (request.content && !schemas[name]) {
48
- const firstContentType = Object.keys(request.content)[0] || "application/json";
49
- schemas[name] = request.content?.[contentType || firstContentType]?.schema;
50
- }
51
- });
52
- return schemas;
53
- }
54
-
55
- //#endregion
56
- Object.defineProperty(exports, 'getSchemaFactory', {
57
- enumerable: true,
58
- get: function () {
59
- return getSchemaFactory;
60
- }
61
- });
62
- Object.defineProperty(exports, 'getSchemas', {
63
- enumerable: true,
64
- get: function () {
65
- return getSchemas;
66
- }
67
- });
68
- //# sourceMappingURL=getSchemas-DY8s2CSl.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getSchemas-DY8s2CSl.cjs","names":["schemas: Record<string, OasTypes.SchemaObject>"],"sources":["../src/utils/getSchemaFactory.ts","../src/utils/getSchemas.ts"],"sourcesContent":["import { isOpenApiV3_1Document } from '@kubb/oas'\n\nimport type { Oas, OpenAPIV3, OpenAPIV3_1, SchemaObject } from '@kubb/oas'\n\n/**\n * Make it possible to narrow down the schema based on a specific version(3 or 3.1)\n */\ntype SchemaResult<TWithRef extends boolean = false> =\n | {\n schemaObject?: (TWithRef extends true ? OpenAPIV3.SchemaObject | OpenAPIV3.ReferenceObject : OpenAPIV3.SchemaObject) & {\n nullable?: boolean\n 'x-nullable'?: boolean\n }\n version: '3.0'\n }\n | {\n schemaObject?: (TWithRef extends true ? OpenAPIV3_1.SchemaObject | OpenAPIV3_1.ReferenceObject : OpenAPIV3_1.SchemaObject) & {\n nullable?: boolean\n 'x-nullable'?: boolean\n }\n version: '3.1'\n }\n\n/**\n * Creates a factory function that generates a versioned OpenAPI schema result.\n *\n * The returned function accepts an optional schema object and produces a {@link SchemaResult} containing the dereferenced schema and the OpenAPI version ('3.0' or '3.1').\n *\n * @returns A function that takes an optional schema and returns a versioned schema result.\n */\nexport function getSchemaFactory<TWithRef extends boolean = false>(oas: Oas): (schema?: SchemaObject) => SchemaResult<TWithRef> {\n return (schema?: SchemaObject) => {\n const version = isOpenApiV3_1Document(oas.api) ? '3.1' : '3.0'\n\n return {\n schemaObject: oas.dereferenceWithRef(schema),\n version,\n } as SchemaResult<TWithRef>\n }\n}\n","import type { Oas, OasTypes, contentType } from '@kubb/oas'\n\ntype Mode = 'schemas' | 'responses' | 'requestBodies'\n\ntype GetSchemasProps = {\n oas: Oas\n contentType?: contentType\n includes?: Mode[]\n}\n\nexport function getSchemas({ oas, contentType, includes = ['schemas', 'requestBodies', 'responses'] }: GetSchemasProps): Record<string, OasTypes.SchemaObject> {\n const components = oas.getDefinition().components\n\n let schemas: Record<string, OasTypes.SchemaObject> = {}\n\n if (includes.includes('schemas')) {\n schemas = {\n ...schemas,\n ...((components?.schemas as Record<string, OasTypes.SchemaObject>) || {}),\n }\n }\n\n const requestBodies = components?.requestBodies || {}\n if (includes.includes('responses')) {\n const responses = components?.responses || {}\n\n Object.entries(responses).forEach(([name, response]: [string, OasTypes.ResponseObject]) => {\n if (response.content && !schemas[name]) {\n const firstContentType = Object.keys(response.content)[0] || 'application/json'\n schemas[name] = response.content?.[contentType || firstContentType]?.schema as OasTypes.SchemaObject\n }\n })\n }\n\n if (includes.includes('requestBodies')) {\n Object.entries(requestBodies).forEach(([name, request]: [string, OasTypes.RequestBodyObject]) => {\n if (request.content && !schemas[name]) {\n const firstContentType = Object.keys(request.content)[0] || 'application/json'\n schemas[name] = request.content?.[contentType || firstContentType]?.schema as OasTypes.SchemaObject\n }\n })\n }\n\n return schemas\n}\n"],"mappings":";;;;;;;;;;;;AA8BA,SAAgB,iBAAmD,KAA6D;AAC9H,SAAQ,WAA0B;EAChC,MAAM,gDAAgC,IAAI,IAAI,GAAG,QAAQ;AAEzD,SAAO;GACL,cAAc,IAAI,mBAAmB,OAAO;GAC5C;GACD;;;;;;AC3BL,SAAgB,WAAW,EAAE,KAAK,aAAa,WAAW;CAAC;CAAW;CAAiB;CAAY,IAA4D;CAC7J,MAAM,aAAa,IAAI,eAAe,CAAC;CAEvC,IAAIA,UAAiD,EAAE;AAEvD,KAAI,SAAS,SAAS,UAAU,CAC9B,WAAU;EACR,GAAG;EACH,GAAK,YAAY,WAAqD,EAAE;EACzE;CAGH,MAAM,gBAAgB,YAAY,iBAAiB,EAAE;AACrD,KAAI,SAAS,SAAS,YAAY,EAAE;EAClC,MAAM,YAAY,YAAY,aAAa,EAAE;AAE7C,SAAO,QAAQ,UAAU,CAAC,SAAS,CAAC,MAAM,cAAiD;AACzF,OAAI,SAAS,WAAW,CAAC,QAAQ,OAAO;IACtC,MAAM,mBAAmB,OAAO,KAAK,SAAS,QAAQ,CAAC,MAAM;AAC7D,YAAQ,QAAQ,SAAS,UAAU,eAAe,mBAAmB;;IAEvE;;AAGJ,KAAI,SAAS,SAAS,gBAAgB,CACpC,QAAO,QAAQ,cAAc,CAAC,SAAS,CAAC,MAAM,aAAmD;AAC/F,MAAI,QAAQ,WAAW,CAAC,QAAQ,OAAO;GACrC,MAAM,mBAAmB,OAAO,KAAK,QAAQ,QAAQ,CAAC,MAAM;AAC5D,WAAQ,QAAQ,QAAQ,UAAU,eAAe,mBAAmB;;GAEtE;AAGJ,QAAO"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"parseFromConfig-CqiiLCPe.js","names":[],"sources":["../src/utils/parseFromConfig.ts"],"sourcesContent":["import { resolve } from 'node:path'\n\nimport { URLPath } from '@kubb/core/utils'\n\nimport { merge, 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 (Array.isArray(config.input)) {\n return merge(\n config.input.map((input) => input.path),\n { oasClass },\n )\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"],"mappings":";;;;;;AAUA,SAAgB,gBAAgB,QAAgB,WAAuB,KAAmB;AACxF,KAAI,UAAU,OAAO,OAAO;AAC1B,MAAI,OAAO,OAAO,MAAM,SAAS,SAE/B,QAAO,MAD2B,KAAK,MAAM,KAAK,UAAU,OAAO,MAAM,KAAK,CAAC,EAC7D,EAAE,UAAU,CAAC;AAGjC,MAAI;AAGF,UAAO,MAFa,KAAK,MAAM,OAAO,MAAM,KAAe,EAEzC,EAAE,UAAU,CAAC;WACxB,IAAI;AAMb,SAAO,MAF2B,KAAK,MAAM,KAAK,UAAU,OAAO,MAAM,KAAK,CAAC,EAE7D,EAAE,UAAU,CAAC;;AAGjC,KAAI,MAAM,QAAQ,OAAO,MAAM,CAC7B,QAAO,MACL,OAAO,MAAM,KAAK,UAAU,MAAM,KAAK,EACvC,EAAE,UAAU,CACb;AAGH,KAAI,IAAI,QAAQ,OAAO,MAAM,KAAK,CAAC,MACjC,QAAO,MAAM,OAAO,MAAM,MAAM,EAAE,UAAU,CAAC;AAG/C,QAAO,MAAM,QAAQ,OAAO,MAAM,OAAO,MAAM,KAAK,EAAE,EAAE,UAAU,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"parseFromConfig-RR31a98-.cjs","names":["Oas","yaml","URLPath"],"sources":["../src/utils/parseFromConfig.ts"],"sourcesContent":["import { resolve } from 'node:path'\n\nimport { URLPath } from '@kubb/core/utils'\n\nimport { merge, 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 (Array.isArray(config.input)) {\n return merge(\n config.input.map((input) => input.path),\n { oasClass },\n )\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"],"mappings":";;;;;;;;;;;AAUA,SAAgB,gBAAgB,QAAgB,WAAuBA,gBAAmB;AACxF,KAAI,UAAU,OAAO,OAAO;AAC1B,MAAI,OAAO,OAAO,MAAM,SAAS,SAE/B,8BADkC,KAAK,MAAM,KAAK,UAAU,OAAO,MAAM,KAAK,CAAC,EAC7D,EAAE,UAAU,CAAC;AAGjC,MAAI;AAGF,gCAFoBC,yBAAK,MAAM,OAAO,MAAM,KAAe,EAEzC,EAAE,UAAU,CAAC;WACxB,IAAI;AAMb,+BAFkC,KAAK,MAAM,KAAK,UAAU,OAAO,MAAM,KAAK,CAAC,EAE7D,EAAE,UAAU,CAAC;;AAGjC,KAAI,MAAM,QAAQ,OAAO,MAAM,CAC7B,8BACE,OAAO,MAAM,KAAK,UAAU,MAAM,KAAK,EACvC,EAAE,UAAU,CACb;AAGH,KAAI,IAAIC,0BAAQ,OAAO,MAAM,KAAK,CAAC,MACjC,8BAAa,OAAO,MAAM,MAAM,EAAE,UAAU,CAAC;AAG/C,qDAAqB,OAAO,MAAM,OAAO,MAAM,KAAK,EAAE,EAAE,UAAU,CAAC"}
@@ -1,99 +0,0 @@
1
- import { t as Oas } from "./Oas-CIeHKOo0.js";
2
- import { App, createReactFabric } from "@kubb/react-fabric";
3
- import { jsx } from "@kubb/react-fabric/jsx-runtime";
4
-
5
- //#region src/generators/utils.tsx
6
- async function buildOperations(operations, { fabric, options, instance, generator }) {
7
- if (!generator.Operations) return;
8
- const { pluginManager, oas, plugin, mode } = instance.context;
9
- function Component() {
10
- return /* @__PURE__ */ jsx(App, {
11
- meta: {
12
- pluginManager,
13
- plugin,
14
- mode
15
- },
16
- children: /* @__PURE__ */ jsx(Oas, {
17
- oas,
18
- operations,
19
- generator: instance,
20
- children: /* @__PURE__ */ jsx(generator.Operations, {
21
- operations,
22
- instance,
23
- options
24
- })
25
- })
26
- });
27
- }
28
- const fabricChild = createReactFabric();
29
- fabricChild.render(Component);
30
- await fabric.context.fileManager.add(...fabricChild.files);
31
- }
32
- async function buildOperation(operation, { fabric, options, instance, generator }) {
33
- if (!generator.Operation) return;
34
- const { pluginManager, oas, plugin, mode } = instance.context;
35
- function Component() {
36
- return /* @__PURE__ */ jsx(App, {
37
- meta: {
38
- pluginManager,
39
- plugin: {
40
- ...plugin,
41
- options
42
- },
43
- mode
44
- },
45
- children: /* @__PURE__ */ jsx(Oas, {
46
- oas,
47
- operations: [operation],
48
- generator: instance,
49
- children: /* @__PURE__ */ jsx(Oas.Operation, {
50
- operation,
51
- children: /* @__PURE__ */ jsx(generator.Operation, {
52
- operation,
53
- options,
54
- instance
55
- })
56
- })
57
- })
58
- });
59
- }
60
- const fabricChild = createReactFabric();
61
- fabricChild.render(Component);
62
- await fabric.context.fileManager.add(...fabricChild.files);
63
- }
64
- async function buildSchema(schema, { fabric, options, instance, generator }) {
65
- if (!generator.Schema) return;
66
- const { pluginManager, oas, plugin, mode } = instance.context;
67
- function Component() {
68
- return /* @__PURE__ */ jsx(App, {
69
- meta: {
70
- pluginManager,
71
- plugin: {
72
- ...plugin,
73
- options
74
- },
75
- mode
76
- },
77
- children: /* @__PURE__ */ jsx(Oas, {
78
- oas,
79
- children: /* @__PURE__ */ jsx(Oas.Schema, {
80
- name: schema.name,
81
- schemaObject: schema.value,
82
- tree: schema.tree,
83
- children: /* @__PURE__ */ jsx(generator.Schema, {
84
- schema,
85
- options,
86
- instance
87
- })
88
- })
89
- })
90
- });
91
- }
92
- const fabricChild = createReactFabric();
93
- fabricChild.render(Component);
94
- await fabric.context.fileManager.add(...fabricChild.files);
95
- }
96
-
97
- //#endregion
98
- export { buildOperations as n, buildSchema as r, buildOperation as t };
99
- //# sourceMappingURL=utils-BnkB1ikY.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils-BnkB1ikY.js","names":[],"sources":["../src/generators/utils.tsx"],"sourcesContent":["import type { PluginFactoryOptions } from '@kubb/core'\nimport type { Operation, SchemaObject } from '@kubb/oas'\nimport { App, createReactFabric, type Fabric } from '@kubb/react-fabric'\nimport { Oas } from '../components/Oas.tsx'\nimport type { OperationGenerator } from '../OperationGenerator.ts'\nimport type { SchemaGenerator, SchemaGeneratorOptions } from '../SchemaGenerator.ts'\nimport type { Schema } from '../SchemaMapper.ts'\nimport type { ReactGenerator } from './/createReactGenerator.ts'\n\ntype BuildOperationsOptions<TOptions extends PluginFactoryOptions> = {\n fabric: Fabric\n generator: ReactGenerator<any>\n /**\n * @deprecated\n */\n instance: Omit<OperationGenerator<TOptions>, 'build'>\n options: TOptions['resolvedOptions']\n}\n\nexport async function buildOperations<TOptions extends PluginFactoryOptions>(\n operations: Array<Operation>,\n { fabric, options, instance, generator }: BuildOperationsOptions<TOptions>,\n): Promise<void> {\n if (!generator.Operations) {\n return undefined\n }\n\n const { pluginManager, oas, plugin, mode } = instance.context\n\n function Component() {\n return (\n <App meta={{ pluginManager, plugin, mode }}>\n <Oas oas={oas} operations={operations} generator={instance}>\n <generator.Operations operations={operations} instance={instance} options={options} />\n </Oas>\n </App>\n )\n }\n\n const fabricChild = createReactFabric()\n fabricChild.render(Component)\n\n await fabric.context.fileManager.add(...fabricChild.files)\n}\n\ntype BuildOperationOptions<TOptions extends PluginFactoryOptions> = BuildOperationsOptions<TOptions>\n\nexport async function buildOperation<TOptions extends PluginFactoryOptions>(\n operation: Operation,\n { fabric, options, instance, generator }: BuildOperationOptions<TOptions>,\n): Promise<void> {\n if (!generator.Operation) {\n return undefined\n }\n\n const { pluginManager, oas, plugin, mode } = instance.context\n\n function Component() {\n return (\n <App meta={{ pluginManager, plugin: { ...plugin, options }, mode }}>\n <Oas oas={oas} operations={[operation]} generator={instance}>\n <Oas.Operation operation={operation}>\n <generator.Operation operation={operation} options={options} instance={instance} />\n </Oas.Operation>\n </Oas>\n </App>\n )\n }\n const fabricChild = createReactFabric()\n fabricChild.render(Component)\n\n await fabric.context.fileManager.add(...fabricChild.files)\n}\n\ntype BuildSchemaOptions<TOptions extends PluginFactoryOptions> = {\n fabric: Fabric\n generator: ReactGenerator<any>\n /**\n * @deprecated\n */\n instance: Omit<SchemaGenerator<SchemaGeneratorOptions, TOptions>, 'build'>\n options: TOptions['resolvedOptions']\n}\n\nexport async function buildSchema<TOptions extends PluginFactoryOptions>(\n schema: {\n name: string\n tree: Array<Schema>\n value: SchemaObject\n },\n { fabric, options, instance, generator }: BuildSchemaOptions<TOptions>,\n): Promise<void> {\n if (!generator.Schema) {\n return undefined\n }\n\n const { pluginManager, oas, plugin, mode } = instance.context\n\n function Component() {\n return (\n <App meta={{ pluginManager, plugin: { ...plugin, options }, mode }}>\n <Oas oas={oas}>\n <Oas.Schema name={schema.name} schemaObject={schema.value} tree={schema.tree}>\n <generator.Schema schema={schema} options={options} instance={instance} />\n </Oas.Schema>\n </Oas>\n </App>\n )\n }\n const fabricChild = createReactFabric()\n fabricChild.render(Component)\n\n await fabric.context.fileManager.add(...fabricChild.files)\n}\n"],"mappings":";;;;;AAmBA,eAAsB,gBACpB,YACA,EAAE,QAAQ,SAAS,UAAU,aACd;AACf,KAAI,CAAC,UAAU,WACb;CAGF,MAAM,EAAE,eAAe,KAAK,QAAQ,SAAS,SAAS;CAEtD,SAAS,YAAY;AACnB,SACE,oBAAC;GAAI,MAAM;IAAE;IAAe;IAAQ;IAAM;aACxC,oBAAC;IAAS;IAAiB;IAAY,WAAW;cAChD,oBAAC,UAAU;KAAuB;KAAsB;KAAmB;MAAW;KAClF;IACF;;CAIV,MAAM,cAAc,mBAAmB;AACvC,aAAY,OAAO,UAAU;AAE7B,OAAM,OAAO,QAAQ,YAAY,IAAI,GAAG,YAAY,MAAM;;AAK5D,eAAsB,eACpB,WACA,EAAE,QAAQ,SAAS,UAAU,aACd;AACf,KAAI,CAAC,UAAU,UACb;CAGF,MAAM,EAAE,eAAe,KAAK,QAAQ,SAAS,SAAS;CAEtD,SAAS,YAAY;AACnB,SACE,oBAAC;GAAI,MAAM;IAAE;IAAe,QAAQ;KAAE,GAAG;KAAQ;KAAS;IAAE;IAAM;aAChE,oBAAC;IAAS;IAAK,YAAY,CAAC,UAAU;IAAE,WAAW;cACjD,oBAAC,IAAI;KAAqB;eACxB,oBAAC,UAAU;MAAqB;MAAoB;MAAmB;OAAY;MACrE;KACZ;IACF;;CAGV,MAAM,cAAc,mBAAmB;AACvC,aAAY,OAAO,UAAU;AAE7B,OAAM,OAAO,QAAQ,YAAY,IAAI,GAAG,YAAY,MAAM;;AAa5D,eAAsB,YACpB,QAKA,EAAE,QAAQ,SAAS,UAAU,aACd;AACf,KAAI,CAAC,UAAU,OACb;CAGF,MAAM,EAAE,eAAe,KAAK,QAAQ,SAAS,SAAS;CAEtD,SAAS,YAAY;AACnB,SACE,oBAAC;GAAI,MAAM;IAAE;IAAe,QAAQ;KAAE,GAAG;KAAQ;KAAS;IAAE;IAAM;aAChE,oBAAC;IAAS;cACR,oBAAC,IAAI;KAAO,MAAM,OAAO;KAAM,cAAc,OAAO;KAAO,MAAM,OAAO;eACtE,oBAAC,UAAU;MAAe;MAAiB;MAAmB;OAAY;MAC/D;KACT;IACF;;CAGV,MAAM,cAAc,mBAAmB;AACvC,aAAY,OAAO,UAAU;AAE7B,OAAM,OAAO,QAAQ,YAAY,IAAI,GAAG,YAAY,MAAM"}
@@ -1,119 +0,0 @@
1
- const require_chunk = require('./chunk-CUT6urMc.cjs');
2
- const require_Oas = require('./Oas-BzrQ6RGC.cjs');
3
- let __kubb_react_fabric = require("@kubb/react-fabric");
4
- __kubb_react_fabric = require_chunk.__toESM(__kubb_react_fabric);
5
- let __kubb_react_fabric_jsx_runtime = require("@kubb/react-fabric/jsx-runtime");
6
- __kubb_react_fabric_jsx_runtime = require_chunk.__toESM(__kubb_react_fabric_jsx_runtime);
7
-
8
- //#region src/generators/utils.tsx
9
- async function buildOperations(operations, { fabric, options, instance, generator }) {
10
- if (!generator.Operations) return;
11
- const { pluginManager, oas, plugin, mode } = instance.context;
12
- function Component() {
13
- return /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.App, {
14
- meta: {
15
- pluginManager,
16
- plugin,
17
- mode
18
- },
19
- children: /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(require_Oas.Oas, {
20
- oas,
21
- operations,
22
- generator: instance,
23
- children: /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(generator.Operations, {
24
- operations,
25
- instance,
26
- options
27
- })
28
- })
29
- });
30
- }
31
- const fabricChild = (0, __kubb_react_fabric.createReactFabric)();
32
- fabricChild.render(Component);
33
- await fabric.context.fileManager.add(...fabricChild.files);
34
- }
35
- async function buildOperation(operation, { fabric, options, instance, generator }) {
36
- if (!generator.Operation) return;
37
- const { pluginManager, oas, plugin, mode } = instance.context;
38
- function Component() {
39
- return /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.App, {
40
- meta: {
41
- pluginManager,
42
- plugin: {
43
- ...plugin,
44
- options
45
- },
46
- mode
47
- },
48
- children: /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(require_Oas.Oas, {
49
- oas,
50
- operations: [operation],
51
- generator: instance,
52
- children: /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(require_Oas.Oas.Operation, {
53
- operation,
54
- children: /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(generator.Operation, {
55
- operation,
56
- options,
57
- instance
58
- })
59
- })
60
- })
61
- });
62
- }
63
- const fabricChild = (0, __kubb_react_fabric.createReactFabric)();
64
- fabricChild.render(Component);
65
- await fabric.context.fileManager.add(...fabricChild.files);
66
- }
67
- async function buildSchema(schema, { fabric, options, instance, generator }) {
68
- if (!generator.Schema) return;
69
- const { pluginManager, oas, plugin, mode } = instance.context;
70
- function Component() {
71
- return /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.App, {
72
- meta: {
73
- pluginManager,
74
- plugin: {
75
- ...plugin,
76
- options
77
- },
78
- mode
79
- },
80
- children: /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(require_Oas.Oas, {
81
- oas,
82
- children: /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(require_Oas.Oas.Schema, {
83
- name: schema.name,
84
- schemaObject: schema.value,
85
- tree: schema.tree,
86
- children: /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(generator.Schema, {
87
- schema,
88
- options,
89
- instance
90
- })
91
- })
92
- })
93
- });
94
- }
95
- const fabricChild = (0, __kubb_react_fabric.createReactFabric)();
96
- fabricChild.render(Component);
97
- await fabric.context.fileManager.add(...fabricChild.files);
98
- }
99
-
100
- //#endregion
101
- Object.defineProperty(exports, 'buildOperation', {
102
- enumerable: true,
103
- get: function () {
104
- return buildOperation;
105
- }
106
- });
107
- Object.defineProperty(exports, 'buildOperations', {
108
- enumerable: true,
109
- get: function () {
110
- return buildOperations;
111
- }
112
- });
113
- Object.defineProperty(exports, 'buildSchema', {
114
- enumerable: true,
115
- get: function () {
116
- return buildSchema;
117
- }
118
- });
119
- //# sourceMappingURL=utils-nzdccPlU.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils-nzdccPlU.cjs","names":["App","Oas"],"sources":["../src/generators/utils.tsx"],"sourcesContent":["import type { PluginFactoryOptions } from '@kubb/core'\nimport type { Operation, SchemaObject } from '@kubb/oas'\nimport { App, createReactFabric, type Fabric } from '@kubb/react-fabric'\nimport { Oas } from '../components/Oas.tsx'\nimport type { OperationGenerator } from '../OperationGenerator.ts'\nimport type { SchemaGenerator, SchemaGeneratorOptions } from '../SchemaGenerator.ts'\nimport type { Schema } from '../SchemaMapper.ts'\nimport type { ReactGenerator } from './/createReactGenerator.ts'\n\ntype BuildOperationsOptions<TOptions extends PluginFactoryOptions> = {\n fabric: Fabric\n generator: ReactGenerator<any>\n /**\n * @deprecated\n */\n instance: Omit<OperationGenerator<TOptions>, 'build'>\n options: TOptions['resolvedOptions']\n}\n\nexport async function buildOperations<TOptions extends PluginFactoryOptions>(\n operations: Array<Operation>,\n { fabric, options, instance, generator }: BuildOperationsOptions<TOptions>,\n): Promise<void> {\n if (!generator.Operations) {\n return undefined\n }\n\n const { pluginManager, oas, plugin, mode } = instance.context\n\n function Component() {\n return (\n <App meta={{ pluginManager, plugin, mode }}>\n <Oas oas={oas} operations={operations} generator={instance}>\n <generator.Operations operations={operations} instance={instance} options={options} />\n </Oas>\n </App>\n )\n }\n\n const fabricChild = createReactFabric()\n fabricChild.render(Component)\n\n await fabric.context.fileManager.add(...fabricChild.files)\n}\n\ntype BuildOperationOptions<TOptions extends PluginFactoryOptions> = BuildOperationsOptions<TOptions>\n\nexport async function buildOperation<TOptions extends PluginFactoryOptions>(\n operation: Operation,\n { fabric, options, instance, generator }: BuildOperationOptions<TOptions>,\n): Promise<void> {\n if (!generator.Operation) {\n return undefined\n }\n\n const { pluginManager, oas, plugin, mode } = instance.context\n\n function Component() {\n return (\n <App meta={{ pluginManager, plugin: { ...plugin, options }, mode }}>\n <Oas oas={oas} operations={[operation]} generator={instance}>\n <Oas.Operation operation={operation}>\n <generator.Operation operation={operation} options={options} instance={instance} />\n </Oas.Operation>\n </Oas>\n </App>\n )\n }\n const fabricChild = createReactFabric()\n fabricChild.render(Component)\n\n await fabric.context.fileManager.add(...fabricChild.files)\n}\n\ntype BuildSchemaOptions<TOptions extends PluginFactoryOptions> = {\n fabric: Fabric\n generator: ReactGenerator<any>\n /**\n * @deprecated\n */\n instance: Omit<SchemaGenerator<SchemaGeneratorOptions, TOptions>, 'build'>\n options: TOptions['resolvedOptions']\n}\n\nexport async function buildSchema<TOptions extends PluginFactoryOptions>(\n schema: {\n name: string\n tree: Array<Schema>\n value: SchemaObject\n },\n { fabric, options, instance, generator }: BuildSchemaOptions<TOptions>,\n): Promise<void> {\n if (!generator.Schema) {\n return undefined\n }\n\n const { pluginManager, oas, plugin, mode } = instance.context\n\n function Component() {\n return (\n <App meta={{ pluginManager, plugin: { ...plugin, options }, mode }}>\n <Oas oas={oas}>\n <Oas.Schema name={schema.name} schemaObject={schema.value} tree={schema.tree}>\n <generator.Schema schema={schema} options={options} instance={instance} />\n </Oas.Schema>\n </Oas>\n </App>\n )\n }\n const fabricChild = createReactFabric()\n fabricChild.render(Component)\n\n await fabric.context.fileManager.add(...fabricChild.files)\n}\n"],"mappings":";;;;;;;;AAmBA,eAAsB,gBACpB,YACA,EAAE,QAAQ,SAAS,UAAU,aACd;AACf,KAAI,CAAC,UAAU,WACb;CAGF,MAAM,EAAE,eAAe,KAAK,QAAQ,SAAS,SAAS;CAEtD,SAAS,YAAY;AACnB,SACE,yDAACA;GAAI,MAAM;IAAE;IAAe;IAAQ;IAAM;aACxC,yDAACC;IAAS;IAAiB;IAAY,WAAW;cAChD,yDAAC,UAAU;KAAuB;KAAsB;KAAmB;MAAW;KAClF;IACF;;CAIV,MAAM,0DAAiC;AACvC,aAAY,OAAO,UAAU;AAE7B,OAAM,OAAO,QAAQ,YAAY,IAAI,GAAG,YAAY,MAAM;;AAK5D,eAAsB,eACpB,WACA,EAAE,QAAQ,SAAS,UAAU,aACd;AACf,KAAI,CAAC,UAAU,UACb;CAGF,MAAM,EAAE,eAAe,KAAK,QAAQ,SAAS,SAAS;CAEtD,SAAS,YAAY;AACnB,SACE,yDAACD;GAAI,MAAM;IAAE;IAAe,QAAQ;KAAE,GAAG;KAAQ;KAAS;IAAE;IAAM;aAChE,yDAACC;IAAS;IAAK,YAAY,CAAC,UAAU;IAAE,WAAW;cACjD,yDAACA,gBAAI;KAAqB;eACxB,yDAAC,UAAU;MAAqB;MAAoB;MAAmB;OAAY;MACrE;KACZ;IACF;;CAGV,MAAM,0DAAiC;AACvC,aAAY,OAAO,UAAU;AAE7B,OAAM,OAAO,QAAQ,YAAY,IAAI,GAAG,YAAY,MAAM;;AAa5D,eAAsB,YACpB,QAKA,EAAE,QAAQ,SAAS,UAAU,aACd;AACf,KAAI,CAAC,UAAU,OACb;CAGF,MAAM,EAAE,eAAe,KAAK,QAAQ,SAAS,SAAS;CAEtD,SAAS,YAAY;AACnB,SACE,yDAACD;GAAI,MAAM;IAAE;IAAe,QAAQ;KAAE,GAAG;KAAQ;KAAS;IAAE;IAAM;aAChE,yDAACC;IAAS;cACR,yDAACA,gBAAI;KAAO,MAAM,OAAO;KAAM,cAAc,OAAO;KAAO,MAAM,OAAO;eACtE,yDAAC,UAAU;MAAe;MAAiB;MAAmB;OAAY;MAC/D;KACT;IACF;;CAGV,MAAM,0DAAiC;AACvC,aAAY,OAAO,UAAU;AAE7B,OAAM,OAAO,QAAQ,YAAY,IAAI,GAAG,YAAY,MAAM"}
@@ -1,35 +0,0 @@
1
- import type { Oas as OasType, Operation as OperationType } from '@kubb/oas'
2
- import { createContext } from '@kubb/react-fabric'
3
- import type { KubbNode } from '@kubb/react-fabric/types'
4
- import type { OperationGenerator } from '../OperationGenerator.ts'
5
- import { Operation } from './Operation.tsx'
6
- import { Schema } from './Schema.tsx'
7
-
8
- type Props = {
9
- oas: OasType
10
- operations?: OperationType[]
11
- /**
12
- * @deprecated
13
- */
14
- generator?: Omit<OperationGenerator, 'build'>
15
- children?: KubbNode
16
- }
17
-
18
- type OasContextProps = {
19
- oas?: OasType
20
- operations?: OperationType[]
21
- /**
22
- * @deprecated
23
- */
24
- generator?: Omit<OperationGenerator, 'build'>
25
- }
26
-
27
- const OasContext = createContext<OasContextProps>({})
28
-
29
- export function Oas({ oas, children, operations, generator }: Props): KubbNode {
30
- return <OasContext.Provider value={{ oas, generator, operations }}>{children}</OasContext.Provider>
31
- }
32
-
33
- Oas.Context = OasContext
34
- Oas.Operation = Operation
35
- Oas.Schema = Schema
@@ -1,20 +0,0 @@
1
- import type { Operation as OperationType } from '@kubb/oas'
2
- import { createContext } from '@kubb/react-fabric'
3
- import type { KubbNode } from '@kubb/react-fabric/types'
4
-
5
- type Props = {
6
- operation: OperationType
7
- children?: KubbNode
8
- }
9
-
10
- type OperationContextProps = {
11
- operation?: OperationType
12
- }
13
-
14
- const OperationContext = createContext<OperationContextProps>({})
15
-
16
- export function Operation({ operation, children }: Props): KubbNode {
17
- return <OperationContext.Provider value={{ operation }}>{children}</OperationContext.Provider>
18
- }
19
-
20
- Operation.Context = OperationContext
@@ -1,38 +0,0 @@
1
- import type { SchemaObject } from '@kubb/oas'
2
- import { createContext } from '@kubb/react-fabric'
3
- import type { Key, KubbNode } from '@kubb/react-fabric/types'
4
- import type { Schema as SchemaType } from '../SchemaMapper.ts'
5
-
6
- export type SchemaContextProps = {
7
- name: string
8
- schemaObject?: SchemaObject
9
- tree: Array<SchemaType>
10
- }
11
-
12
- type Props = {
13
- key?: Key
14
- name: string
15
- schemaObject?: SchemaObject
16
- tree?: Array<SchemaType>
17
- children?: KubbNode
18
- }
19
-
20
- const SchemaContext = createContext<SchemaContextProps>({
21
- name: 'unknown',
22
- tree: [],
23
- })
24
-
25
- /**
26
- * Provides schema-related context to descendant components.
27
- *
28
- * Wraps its children with a context containing the schema name, optional schema object, and an optional schema type tree.
29
- *
30
- * @param name - The name of the schema.
31
- * @param schemaObject - The schema object to provide in context, if available.
32
- * @param tree - An array representing the schema type hierarchy.
33
- */
34
- export function Schema({ name, schemaObject, tree = [], children }: Props): KubbNode {
35
- return <SchemaContext.Provider value={{ name, schemaObject, tree }}>{children}</SchemaContext.Provider>
36
- }
37
-
38
- Schema.Context = SchemaContext
@@ -1,3 +0,0 @@
1
- export { Oas } from './Oas.tsx'
2
- export { Operation } from './Operation.tsx'
3
- export { Schema } from './Schema.tsx'