@kubb/plugin-oas 4.4.1 → 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 (102) hide show
  1. package/dist/{SchemaGenerator-b7XixzRv.js → SchemaGenerator-BwYbrh7a.js} +93 -36
  2. package/dist/SchemaGenerator-BwYbrh7a.js.map +1 -0
  3. package/dist/{SchemaGenerator-DWj6buY0.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-CtfTw3hq.d.ts → SchemaMapper-CgGWx6jF.d.cts} +14 -2
  8. package/dist/{SchemaMapper-CX7sIIuZ.d.cts → SchemaMapper-Cj3vjPGs.d.ts} +14 -2
  9. package/dist/{SchemaMapper-Cx4X1al6.js → SchemaMapper-D30tqRoX.js} +1 -1
  10. package/dist/SchemaMapper-D30tqRoX.js.map +1 -0
  11. package/dist/{OperationGenerator-CRZpkIpZ.d.ts → createGenerator-BvCDyuKS.d.ts} +112 -176
  12. package/dist/{OperationGenerator-S_1PevQN.d.cts → createGenerator-CPNglV1d.d.cts} +113 -177
  13. package/dist/{generators-C61FxVIj.js → generators-CJDEf8Kn.js} +6 -6
  14. package/dist/{generators-C61FxVIj.js.map → generators-CJDEf8Kn.js.map} +1 -1
  15. package/dist/{generators-B27La9Vd.cjs → generators-udGOxdUV.cjs} +6 -6
  16. package/dist/{generators-B27La9Vd.cjs.map → generators-udGOxdUV.cjs.map} +1 -1
  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 +4 -29
  30. package/dist/hooks.cjs.map +1 -1
  31. package/dist/hooks.d.cts +4 -18
  32. package/dist/hooks.d.ts +4 -18
  33. package/dist/hooks.js +6 -29
  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 +5 -12
  56. package/src/OperationGenerator.ts +26 -13
  57. package/src/SchemaGenerator.ts +24 -46
  58. package/src/SchemaMapper.ts +2 -0
  59. package/src/generators/index.ts +0 -1
  60. package/src/generators/jsonGenerator.ts +4 -4
  61. package/src/generators/types.ts +13 -14
  62. package/src/hooks/index.ts +0 -2
  63. package/src/hooks/useOperationManager.ts +2 -4
  64. package/src/index.ts +1 -1
  65. package/src/utils/getBanner.ts +1 -1
  66. package/src/utils/getParams.ts +1 -2
  67. package/src/utils/getSchemaFactory.ts +1 -2
  68. package/src/utils/getSchemas.ts +89 -15
  69. package/src/utils/index.ts +3 -4
  70. package/src/utils/parseFromConfig.ts +2 -6
  71. package/src/utils.tsx +101 -0
  72. package/dist/Oas-CHC1IC5D.js +0 -56
  73. package/dist/Oas-CHC1IC5D.js.map +0 -1
  74. package/dist/Oas-CQrRP_NH.cjs +0 -76
  75. package/dist/Oas-CQrRP_NH.cjs.map +0 -1
  76. package/dist/Schema-CZsDEhET.d.cts +0 -38
  77. package/dist/Schema-DBvtiLS7.d.ts +0 -38
  78. package/dist/SchemaGenerator-DWj6buY0.cjs.map +0 -1
  79. package/dist/SchemaGenerator-b7XixzRv.js.map +0 -1
  80. package/dist/SchemaMapper-Cx4X1al6.js.map +0 -1
  81. package/dist/SchemaMapper-DoL-a6qq.cjs.map +0 -1
  82. package/dist/components.cjs +0 -5
  83. package/dist/components.d.cts +0 -38
  84. package/dist/components.d.ts +0 -38
  85. package/dist/components.js +0 -3
  86. package/dist/getSchemas-Bdg6n9Qk.js +0 -55
  87. package/dist/getSchemas-Bdg6n9Qk.js.map +0 -1
  88. package/dist/getSchemas-DY8s2CSl.cjs +0 -68
  89. package/dist/getSchemas-DY8s2CSl.cjs.map +0 -1
  90. package/dist/parseFromConfig-CqiiLCPe.js.map +0 -1
  91. package/dist/parseFromConfig-RR31a98-.cjs.map +0 -1
  92. package/dist/utils-DYf-j63H.cjs +0 -115
  93. package/dist/utils-DYf-j63H.cjs.map +0 -1
  94. package/dist/utils-DaV25sy8.js +0 -95
  95. package/dist/utils-DaV25sy8.js.map +0 -1
  96. package/src/components/Oas.tsx +0 -30
  97. package/src/components/Operation.tsx +0 -20
  98. package/src/components/Schema.tsx +0 -38
  99. package/src/components/index.ts +0 -3
  100. package/src/generators/utils.tsx +0 -114
  101. package/src/hooks/useOperation.ts +0 -18
  102. package/src/hooks/useSchema.ts +0 -16
package/dist/utils.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  const require_chunk = require('./chunk-CUT6urMc.cjs');
2
- const require_getFooter = require('./getFooter-CwjCW4h5.cjs');
3
- const require_getSchemas = require('./getSchemas-DY8s2CSl.cjs');
4
- const require_parseFromConfig = require('./parseFromConfig-RR31a98-.cjs');
2
+ const require_getFooter = require('./getFooter-DPh4lxBH.cjs');
3
+ const require_getSchemas = require('./getSchemas-Cl0TZ4XY.cjs');
4
+ const require_parseFromConfig = require('./parseFromConfig-EjsCZ0-8.cjs');
5
5
  let __kubb_core_transformers = require("@kubb/core/transformers");
6
6
  __kubb_core_transformers = require_chunk.__toESM(__kubb_core_transformers);
7
7
  let __kubb_core_utils = require("@kubb/core/utils");
@@ -1 +1 @@
1
- {"version":3,"file":"utils.cjs","names":["URLPath","transformers","data: FunctionParamsAST"],"sources":["../src/utils/getComments.ts","../src/utils/getParams.ts"],"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-fabric/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"],"mappings":";;;;;;;;;;;;AAKA,SAAgB,YAAY,WAAgC;AAC1D,QAAO;EACL,UAAU,gBAAgB,IAAI,gBAAgB,UAAU,gBAAgB;EACxE,UAAU,YAAY,IAAI,YAAY,UAAU,YAAY;EAC5D,UAAU,QAAQ,UAAU,IAAIA,0BAAQ,UAAU,KAAK,CAAC,IAAI;EAC5D,UAAU,cAAc,IAAI;EAC7B,CACE,OAAO,QAAQ,CACf,KAAK,SAASC,iCAAa,KAAK,KAAK,CAAC;;;;;;;;;;ACD3C,SAAgB,aACd,iBACA,EACE,QAAQ,OACR,aAIE,EAAE,EACe;AACrB,KAAI,CAAC,mBAAmB,CAAC,gBAAgB,OAAO,cAAc,CAAC,gBAAgB,KAC7E,QAAO,EAAE;AAGX,QAAO,OAAO,QAAQ,gBAAgB,OAAO,WAAW,CAAC,KAAK,CAAC,MAAM,YAA6C;EAChH,MAAM,4CAA4B,OAAO;EACzC,MAAMC,OAA0B;GAC9B;GACA,SAAS,CAAC,CAAC;GACX,UAAU,UAAU,OAAO,WAAW;GACtC,MAAM,QAAQ,GAAG,gBAAgB,KAAK,IAAI,KAAK,MAAM;GACtD;AAED,SAAO,WAAW,SAAS,KAAK,GAAG;GACnC;;AAGJ,SAAgB,cACd,iBACA,UAII,EAAE,EACN;AACA,QAAO,aAAa,iBAAiB,QAAQ,CAAC,QAAQ,KAAK,SAAS;AAClE,MAAI,KAAK,QAAQ,KAAK,SAAS;GAC7B,IAAI,oDAAsB,KAAK,KAAK,GAAG,KAAK,+CAAiB,KAAK,KAAK;AAEvE,OAAI,QAAQ,WAAW,YACrB,gDAAiB,KAAK;AAGxB,OAAI,QAAQ;IACV,SAAS,KAAK;IACd,MAAM,KAAK;IACX,UAAU,CAAC,KAAK;IACjB;;AAGH,SAAO;IACN,EAAE,CAAW"}
1
+ {"version":3,"file":"utils.cjs","names":["URLPath","transformers","data: FunctionParamsAST"],"sources":["../src/utils/getComments.ts","../src/utils/getParams.ts"],"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 { camelCase, isValidVarName } from '@kubb/core/transformers'\nimport type { FunctionParamsAST } from '@kubb/core/utils'\nimport type { OasTypes } from '@kubb/oas'\nimport { isParameterObject } from '@kubb/oas'\nimport type { Params } from '@kubb/react-fabric/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"],"mappings":";;;;;;;;;;;;AAKA,SAAgB,YAAY,WAAgC;AAC1D,QAAO;EACL,UAAU,gBAAgB,IAAI,gBAAgB,UAAU,gBAAgB;EACxE,UAAU,YAAY,IAAI,YAAY,UAAU,YAAY;EAC5D,UAAU,QAAQ,UAAU,IAAIA,0BAAQ,UAAU,KAAK,CAAC,IAAI;EAC5D,UAAU,cAAc,IAAI;EAC7B,CACE,OAAO,QAAQ,CACf,KAAK,SAASC,iCAAa,KAAK,KAAK,CAAC;;;;;;;;;;ACF3C,SAAgB,aACd,iBACA,EACE,QAAQ,OACR,aAIE,EAAE,EACe;AACrB,KAAI,CAAC,mBAAmB,CAAC,gBAAgB,OAAO,cAAc,CAAC,gBAAgB,KAC7E,QAAO,EAAE;AAGX,QAAO,OAAO,QAAQ,gBAAgB,OAAO,WAAW,CAAC,KAAK,CAAC,MAAM,YAA6C;EAChH,MAAM,4CAA4B,OAAO;EACzC,MAAMC,OAA0B;GAC9B;GACA,SAAS,CAAC,CAAC;GACX,UAAU,UAAU,OAAO,WAAW;GACtC,MAAM,QAAQ,GAAG,gBAAgB,KAAK,IAAI,KAAK,MAAM;GACtD;AAED,SAAO,WAAW,SAAS,KAAK,GAAG;GACnC;;AAGJ,SAAgB,cACd,iBACA,UAII,EAAE,EACN;AACA,QAAO,aAAa,iBAAiB,QAAQ,CAAC,QAAQ,KAAK,SAAS;AAClE,MAAI,KAAK,QAAQ,KAAK,SAAS;GAC7B,IAAI,oDAAsB,KAAK,KAAK,GAAG,KAAK,+CAAiB,KAAK,KAAK;AAEvE,OAAI,QAAQ,WAAW,YACrB,gDAAiB,KAAK;AAGxB,OAAI,QAAQ;IACV,SAAS,KAAK;IACd,MAAM,KAAK;IACX,UAAU,CAAC,KAAK;IACjB;;AAGH,SAAO;IACN,EAAE,CAAW"}
package/dist/utils.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { A as Config, B as contentType, F as OasTypes, I as OpenAPIV3$1, L as OpenAPIV3_1, P as Oas, R as Operation, j as Output, v as OperationSchema, z as SchemaObject$1 } from "./OperationGenerator-S_1PevQN.cjs";
2
- import "./SchemaMapper-CX7sIIuZ.cjs";
1
+ import { D as Config, O as Output, T as Oas, g as OperationSchema } from "./createGenerator-CPNglV1d.cjs";
2
+ import { d as OpenAPIV3$1, f as OpenAPIV3_1, h as contentType, m as SchemaObject$1, p as Operation, u as OasTypes } from "./SchemaMapper-CgGWx6jF.cjs";
3
3
  import { OASDocument, SchemaObject } from "oas/types";
4
4
  import { OpenAPIV3 } from "openapi-types";
5
5
  import { Params } from "@kubb/react-fabric/types";
@@ -8,9 +8,31 @@ import { Params } from "@kubb/react-fabric/types";
8
8
 
9
9
  declare function isOptional(schema?: SchemaObject): boolean;
10
10
  //#endregion
11
+ //#region src/utils/getBanner.d.ts
12
+ type Props$1<TOas extends Oas> = {
13
+ oas: TOas;
14
+ output: Output<any>;
15
+ config?: Config;
16
+ };
17
+ declare function getBanner<TOas extends Oas>({
18
+ output,
19
+ oas,
20
+ config
21
+ }: Props$1<TOas>): string;
22
+ //#endregion
11
23
  //#region src/utils/getComments.d.ts
12
24
  declare function getComments(operation: Operation): string[];
13
25
  //#endregion
26
+ //#region src/utils/getFooter.d.ts
27
+ type Props<TOas extends Oas> = {
28
+ oas: TOas;
29
+ output: Output<any>;
30
+ };
31
+ declare function getFooter<TOas extends Oas>({
32
+ output,
33
+ oas
34
+ }: Props<TOas>): string | undefined;
35
+ //#endregion
14
36
  //#region ../core/src/utils/FunctionParams.d.ts
15
37
  type FunctionParamsASTWithoutType = {
16
38
  name?: string;
@@ -83,6 +105,10 @@ type GetSchemasProps = {
83
105
  contentType?: contentType;
84
106
  includes?: Mode[];
85
107
  };
108
+ /**
109
+ * Collect schemas from OpenAPI components (schemas, responses, requestBodies)
110
+ * and return them in dependency order.
111
+ */
86
112
  declare function getSchemas({
87
113
  oas,
88
114
  contentType,
@@ -92,27 +118,5 @@ declare function getSchemas({
92
118
  //#region src/utils/parseFromConfig.d.ts
93
119
  declare function parseFromConfig(config: Config, oasClass?: typeof Oas): Promise<Oas>;
94
120
  //#endregion
95
- //#region src/utils/getBanner.d.ts
96
- type Props$1<TOas extends Oas> = {
97
- oas: TOas;
98
- output: Output<any>;
99
- config?: Config;
100
- };
101
- declare function getBanner<TOas extends Oas>({
102
- output,
103
- oas,
104
- config
105
- }: Props$1<TOas>): string;
106
- //#endregion
107
- //#region src/utils/getFooter.d.ts
108
- type Props<TOas extends Oas> = {
109
- oas: TOas;
110
- output: Output<any>;
111
- };
112
- declare function getFooter<TOas extends Oas>({
113
- output,
114
- oas
115
- }: Props<TOas>): string | undefined;
116
- //#endregion
117
121
  export { getBanner, getComments, getFooter, getPathParams, getSchemaFactory, getSchemas, isOptional, parseFromConfig };
118
122
  //# sourceMappingURL=utils.d.cts.map
package/dist/utils.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { A as Config, B as contentType, F as OasTypes, I as OpenAPIV3$1, L as OpenAPIV3_1, P as Oas, R as Operation, j as Output, v as OperationSchema, z as SchemaObject$1 } from "./OperationGenerator-CRZpkIpZ.js";
2
- import "./SchemaMapper-CtfTw3hq.js";
1
+ import { D as Config, O as Output, T as Oas, g as OperationSchema } from "./createGenerator-BvCDyuKS.js";
2
+ import { d as OpenAPIV3$1, f as OpenAPIV3_1, h as contentType, m as SchemaObject$1, p as Operation, u as OasTypes } from "./SchemaMapper-Cj3vjPGs.js";
3
3
  import { OASDocument, SchemaObject } from "oas/types";
4
4
  import { OpenAPIV3 } from "openapi-types";
5
5
  import { Params } from "@kubb/react-fabric/types";
@@ -8,9 +8,31 @@ import { Params } from "@kubb/react-fabric/types";
8
8
 
9
9
  declare function isOptional(schema?: SchemaObject): boolean;
10
10
  //#endregion
11
+ //#region src/utils/getBanner.d.ts
12
+ type Props$1<TOas extends Oas> = {
13
+ oas: TOas;
14
+ output: Output<any>;
15
+ config?: Config;
16
+ };
17
+ declare function getBanner<TOas extends Oas>({
18
+ output,
19
+ oas,
20
+ config
21
+ }: Props$1<TOas>): string;
22
+ //#endregion
11
23
  //#region src/utils/getComments.d.ts
12
24
  declare function getComments(operation: Operation): string[];
13
25
  //#endregion
26
+ //#region src/utils/getFooter.d.ts
27
+ type Props<TOas extends Oas> = {
28
+ oas: TOas;
29
+ output: Output<any>;
30
+ };
31
+ declare function getFooter<TOas extends Oas>({
32
+ output,
33
+ oas
34
+ }: Props<TOas>): string | undefined;
35
+ //#endregion
14
36
  //#region ../core/src/utils/FunctionParams.d.ts
15
37
  type FunctionParamsASTWithoutType = {
16
38
  name?: string;
@@ -83,6 +105,10 @@ type GetSchemasProps = {
83
105
  contentType?: contentType;
84
106
  includes?: Mode[];
85
107
  };
108
+ /**
109
+ * Collect schemas from OpenAPI components (schemas, responses, requestBodies)
110
+ * and return them in dependency order.
111
+ */
86
112
  declare function getSchemas({
87
113
  oas,
88
114
  contentType,
@@ -92,27 +118,5 @@ declare function getSchemas({
92
118
  //#region src/utils/parseFromConfig.d.ts
93
119
  declare function parseFromConfig(config: Config, oasClass?: typeof Oas): Promise<Oas>;
94
120
  //#endregion
95
- //#region src/utils/getBanner.d.ts
96
- type Props$1<TOas extends Oas> = {
97
- oas: TOas;
98
- output: Output<any>;
99
- config?: Config;
100
- };
101
- declare function getBanner<TOas extends Oas>({
102
- output,
103
- oas,
104
- config
105
- }: Props$1<TOas>): string;
106
- //#endregion
107
- //#region src/utils/getFooter.d.ts
108
- type Props<TOas extends Oas> = {
109
- oas: TOas;
110
- output: Output<any>;
111
- };
112
- declare function getFooter<TOas extends Oas>({
113
- output,
114
- oas
115
- }: Props<TOas>): string | undefined;
116
- //#endregion
117
121
  export { getBanner, getComments, getFooter, getPathParams, getSchemaFactory, getSchemas, isOptional, parseFromConfig };
118
122
  //# sourceMappingURL=utils.d.ts.map
package/dist/utils.js CHANGED
@@ -1,6 +1,6 @@
1
- import { n as getBanner, t as getFooter } from "./getFooter-D5MdeUVv.js";
2
- import { n as getSchemaFactory, t as getSchemas } from "./getSchemas-Bdg6n9Qk.js";
3
- import { t as parseFromConfig } from "./parseFromConfig-CqiiLCPe.js";
1
+ import { n as getBanner, t as getFooter } from "./getFooter-CV73pVXj.js";
2
+ import { n as getSchemaFactory, t as getSchemas } from "./getSchemas-32BHoMO-.js";
3
+ import { t as parseFromConfig } from "./parseFromConfig-BkUoWC2U.js";
4
4
  import transformers, { camelCase, isValidVarName } from "@kubb/core/transformers";
5
5
  import { URLPath } from "@kubb/core/utils";
6
6
  import { isOptional, isParameterObject } from "@kubb/oas";
package/dist/utils.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","names":["data: FunctionParamsAST"],"sources":["../src/utils/getComments.ts","../src/utils/getParams.ts"],"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-fabric/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"],"mappings":";;;;;;;;AAKA,SAAgB,YAAY,WAAgC;AAC1D,QAAO;EACL,UAAU,gBAAgB,IAAI,gBAAgB,UAAU,gBAAgB;EACxE,UAAU,YAAY,IAAI,YAAY,UAAU,YAAY;EAC5D,UAAU,QAAQ,UAAU,IAAI,QAAQ,UAAU,KAAK,CAAC,IAAI;EAC5D,UAAU,cAAc,IAAI;EAC7B,CACE,OAAO,QAAQ,CACf,KAAK,SAAS,aAAa,KAAK,KAAK,CAAC;;;;;;;;;;ACD3C,SAAgB,aACd,iBACA,EACE,QAAQ,OACR,aAIE,EAAE,EACe;AACrB,KAAI,CAAC,mBAAmB,CAAC,gBAAgB,OAAO,cAAc,CAAC,gBAAgB,KAC7E,QAAO,EAAE;AAGX,QAAO,OAAO,QAAQ,gBAAgB,OAAO,WAAW,CAAC,KAAK,CAAC,MAAM,YAA6C;EAChH,MAAM,UAAU,kBAAkB,OAAO;EACzC,MAAMA,OAA0B;GAC9B;GACA,SAAS,CAAC,CAAC;GACX,UAAU,UAAU,OAAO,WAAW;GACtC,MAAM,QAAQ,GAAG,gBAAgB,KAAK,IAAI,KAAK,MAAM;GACtD;AAED,SAAO,WAAW,SAAS,KAAK,GAAG;GACnC;;AAGJ,SAAgB,cACd,iBACA,UAII,EAAE,EACN;AACA,QAAO,aAAa,iBAAiB,QAAQ,CAAC,QAAQ,KAAK,SAAS;AAClE,MAAI,KAAK,QAAQ,KAAK,SAAS;GAC7B,IAAI,OAAO,eAAe,KAAK,KAAK,GAAG,KAAK,OAAO,UAAU,KAAK,KAAK;AAEvE,OAAI,QAAQ,WAAW,YACrB,QAAO,UAAU,KAAK;AAGxB,OAAI,QAAQ;IACV,SAAS,KAAK;IACd,MAAM,KAAK;IACX,UAAU,CAAC,KAAK;IACjB;;AAGH,SAAO;IACN,EAAE,CAAW"}
1
+ {"version":3,"file":"utils.js","names":["data: FunctionParamsAST"],"sources":["../src/utils/getComments.ts","../src/utils/getParams.ts"],"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 { camelCase, isValidVarName } from '@kubb/core/transformers'\nimport type { FunctionParamsAST } from '@kubb/core/utils'\nimport type { OasTypes } from '@kubb/oas'\nimport { isParameterObject } from '@kubb/oas'\nimport type { Params } from '@kubb/react-fabric/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"],"mappings":";;;;;;;;AAKA,SAAgB,YAAY,WAAgC;AAC1D,QAAO;EACL,UAAU,gBAAgB,IAAI,gBAAgB,UAAU,gBAAgB;EACxE,UAAU,YAAY,IAAI,YAAY,UAAU,YAAY;EAC5D,UAAU,QAAQ,UAAU,IAAI,QAAQ,UAAU,KAAK,CAAC,IAAI;EAC5D,UAAU,cAAc,IAAI;EAC7B,CACE,OAAO,QAAQ,CACf,KAAK,SAAS,aAAa,KAAK,KAAK,CAAC;;;;;;;;;;ACF3C,SAAgB,aACd,iBACA,EACE,QAAQ,OACR,aAIE,EAAE,EACe;AACrB,KAAI,CAAC,mBAAmB,CAAC,gBAAgB,OAAO,cAAc,CAAC,gBAAgB,KAC7E,QAAO,EAAE;AAGX,QAAO,OAAO,QAAQ,gBAAgB,OAAO,WAAW,CAAC,KAAK,CAAC,MAAM,YAA6C;EAChH,MAAM,UAAU,kBAAkB,OAAO;EACzC,MAAMA,OAA0B;GAC9B;GACA,SAAS,CAAC,CAAC;GACX,UAAU,UAAU,OAAO,WAAW;GACtC,MAAM,QAAQ,GAAG,gBAAgB,KAAK,IAAI,KAAK,MAAM;GACtD;AAED,SAAO,WAAW,SAAS,KAAK,GAAG;GACnC;;AAGJ,SAAgB,cACd,iBACA,UAII,EAAE,EACN;AACA,QAAO,aAAa,iBAAiB,QAAQ,CAAC,QAAQ,KAAK,SAAS;AAClE,MAAI,KAAK,QAAQ,KAAK,SAAS;GAC7B,IAAI,OAAO,eAAe,KAAK,KAAK,GAAG,KAAK,OAAO,UAAU,KAAK,KAAK;AAEvE,OAAI,QAAQ,WAAW,YACrB,QAAO,UAAU,KAAK;AAGxB,OAAI,QAAQ;IACV,SAAS,KAAK;IACd,MAAM,KAAK;IACX,UAAU,CAAC,KAAK;IACjB;;AAGH,SAAO;IACN,EAAE,CAAW"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/plugin-oas",
3
- "version": "4.4.1",
3
+ "version": "4.5.0",
4
4
  "description": "OpenAPI Specification (OAS) plugin for Kubb, providing core functionality for parsing and processing OpenAPI/Swagger schemas for code generation.",
5
5
  "keywords": [
6
6
  "openapi",
@@ -28,10 +28,6 @@
28
28
  "import": "./dist/index.js",
29
29
  "require": "./dist/index.cjs"
30
30
  },
31
- "./components": {
32
- "import": "./dist/components.js",
33
- "require": "./dist/components.cjs"
34
- },
35
31
  "./generators": {
36
32
  "import": "./dist/generators.js",
37
33
  "require": "./dist/generators.cjs"
@@ -61,9 +57,6 @@
61
57
  "hooks": [
62
58
  "./dist/hooks.d.ts"
63
59
  ],
64
- "components": [
65
- "./dist/components.d.ts"
66
- ],
67
60
  "mocks": [
68
61
  "./dist/mocks.d.ts"
69
62
  ],
@@ -86,16 +79,16 @@
86
79
  }
87
80
  ],
88
81
  "dependencies": {
89
- "@kubb/react-fabric": "0.2.10",
82
+ "@kubb/react-fabric": "0.2.14",
90
83
  "@stoplight/yaml": "^4.3.0",
91
84
  "p-limit": "^7.2.0",
92
85
  "remeda": "^2.32.0",
93
- "@kubb/core": "4.4.1",
94
- "@kubb/oas": "4.4.1"
86
+ "@kubb/core": "4.5.0",
87
+ "@kubb/oas": "4.5.0"
95
88
  },
96
89
  "devDependencies": {},
97
90
  "peerDependencies": {
98
- "@kubb/react-fabric": "0.2.10"
91
+ "@kubb/react-fabric": "0.2.14"
99
92
  },
100
93
  "engines": {
101
94
  "node": ">=20"
@@ -6,8 +6,8 @@ import type { contentType, HttpMethod, Oas, OasTypes, Operation, SchemaObject }
6
6
  import type { Fabric } from '@kubb/react-fabric'
7
7
  import pLimit from 'p-limit'
8
8
  import type { Generator } from './generators/types.ts'
9
- import { buildOperation, buildOperations } from './generators/utils.tsx'
10
9
  import type { Exclude, Include, OperationSchemas, Override } from './types.ts'
10
+ import { buildOperation, buildOperations } from './utils.tsx'
11
11
 
12
12
  export type OperationMethodResult<TFileMeta extends FileMetaBase> = Promise<KubbFile.File<TFileMeta> | Array<KubbFile.File<TFileMeta>> | null>
13
13
 
@@ -229,12 +229,16 @@ export class OperationGenerator<
229
229
 
230
230
  if (generator.type === 'react') {
231
231
  await buildOperation(operation, {
232
+ config: this.context.pluginManager.config,
232
233
  fabric: this.context.fabric,
233
- generator,
234
- instance: this,
235
- options: {
236
- ...this.options,
237
- ...options,
234
+ Component: generator.Operation,
235
+ generator: this,
236
+ plugin: {
237
+ ...this.context.plugin,
238
+ options: {
239
+ ...this.options,
240
+ ...options,
241
+ },
238
242
  },
239
243
  })
240
244
 
@@ -242,9 +246,16 @@ export class OperationGenerator<
242
246
  }
243
247
 
244
248
  const result = await generator.operation?.({
245
- instance: this,
249
+ generator: this,
250
+ config: this.context.pluginManager.config,
246
251
  operation,
247
- options: { ...this.options, ...options },
252
+ plugin: {
253
+ ...this.context.plugin,
254
+ options: {
255
+ ...this.options,
256
+ ...options,
257
+ },
258
+ },
248
259
  })
249
260
 
250
261
  return result ?? []
@@ -259,9 +270,10 @@ export class OperationGenerator<
259
270
  operations.map((op) => op.operation),
260
271
  {
261
272
  fabric: this.context.fabric,
262
- generator,
263
- instance: this,
264
- options: this.options,
273
+ config: this.context.pluginManager.config,
274
+ Component: generator.Operations,
275
+ generator: this,
276
+ plugin: this.context.plugin,
265
277
  },
266
278
  )
267
279
 
@@ -269,9 +281,10 @@ export class OperationGenerator<
269
281
  }
270
282
 
271
283
  const operationsResult = await generator.operations?.({
272
- instance: this,
284
+ generator: this,
285
+ config: this.context.pluginManager.config,
273
286
  operations: operations.map((op) => op.operation),
274
- options: this.options,
287
+ plugin: this.context.plugin,
275
288
  })
276
289
 
277
290
  return [...opResultsFlat, ...(operationsResult ?? [])] as unknown as KubbFile.File<TFileMeta>
@@ -9,12 +9,12 @@ import type { Fabric } from '@kubb/react-fabric'
9
9
  import pLimit from 'p-limit'
10
10
  import { isDeepEqual, isNumber, uniqueWith } from 'remeda'
11
11
  import type { Generator } from './generators/types.ts'
12
- import { buildSchema } from './generators/utils.tsx'
13
12
  import type { Schema, SchemaKeywordMapper } from './SchemaMapper.ts'
14
13
  import { isKeyword, schemaKeywords } from './SchemaMapper.ts'
15
14
  import type { OperationSchema, Override, Refs } from './types.ts'
16
15
  import { getSchemaFactory } from './utils/getSchemaFactory.ts'
17
16
  import { getSchemas } from './utils/getSchemas.ts'
17
+ import { buildSchema } from './utils.tsx'
18
18
 
19
19
  export type GetSchemaGeneratorOptions<T extends SchemaGenerator<any, any, any>> = T extends SchemaGenerator<infer Options, any, any> ? Options : never
20
20
 
@@ -91,14 +91,6 @@ export class SchemaGenerator<
91
91
  return uniqueWith(schemas, isDeepEqual)
92
92
  }
93
93
 
94
- deepSearch<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): Array<SchemaKeywordMapper[T]> {
95
- return SchemaGenerator.deepSearch<T>(tree, keyword)
96
- }
97
-
98
- find<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined {
99
- return SchemaGenerator.find<T>(tree, keyword)
100
- }
101
-
102
94
  static deepSearch<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): Array<SchemaKeywordMapper[T]> {
103
95
  const foundItems: SchemaKeywordMapper[T][] = []
104
96
 
@@ -145,32 +137,6 @@ export class SchemaGenerator<
145
137
  return foundItems
146
138
  }
147
139
 
148
- static findInObject<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined {
149
- let foundItem: SchemaKeywordMapper[T] | undefined
150
-
151
- tree?.forEach((schema) => {
152
- if (!foundItem && schema.keyword === keyword) {
153
- foundItem = schema as SchemaKeywordMapper[T]
154
- }
155
-
156
- if (isKeyword(schema, schemaKeywords.object)) {
157
- Object.values(schema.args?.properties || {}).forEach((entrySchema) => {
158
- if (!foundItem) {
159
- foundItem = SchemaGenerator.find<T>(entrySchema, keyword)
160
- }
161
- })
162
-
163
- Object.values(schema.args?.additionalProperties || {}).forEach((entrySchema) => {
164
- if (!foundItem) {
165
- foundItem = SchemaGenerator.find<T>([entrySchema], keyword)
166
- }
167
- })
168
- }
169
- })
170
-
171
- return foundItem
172
- }
173
-
174
140
  static find<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined {
175
141
  let foundItem: SchemaKeywordMapper[T] | undefined
176
142
 
@@ -563,13 +529,17 @@ export class SchemaGenerator<
563
529
  if (max !== undefined) {
564
530
  if (exclusiveMaximum) {
565
531
  baseItems.unshift({ keyword: schemaKeywords.exclusiveMaximum, args: max })
566
- } else baseItems.unshift({ keyword: schemaKeywords.max, args: max })
532
+ } else {
533
+ baseItems.unshift({ keyword: schemaKeywords.max, args: max })
534
+ }
567
535
  }
568
536
 
569
537
  if (min !== undefined) {
570
538
  if (exclusiveMinimum) {
571
539
  baseItems.unshift({ keyword: schemaKeywords.exclusiveMinimum, args: min })
572
- } else baseItems.unshift({ keyword: schemaKeywords.min, args: min })
540
+ } else {
541
+ baseItems.unshift({ keyword: schemaKeywords.min, args: min })
542
+ }
573
543
  }
574
544
 
575
545
  if (typeof exclusiveMaximum === 'number') {
@@ -1127,12 +1097,16 @@ export class SchemaGenerator<
1127
1097
  tree,
1128
1098
  },
1129
1099
  {
1100
+ config: this.context.pluginManager.config,
1130
1101
  fabric: this.context.fabric,
1131
- generator,
1132
- instance: this,
1133
- options: {
1134
- ...this.options,
1135
- ...options,
1102
+ Component: generator.Schema,
1103
+ generator: this,
1104
+ plugin: {
1105
+ ...this.context.plugin,
1106
+ options: {
1107
+ ...this.options,
1108
+ ...options,
1109
+ },
1136
1110
  },
1137
1111
  },
1138
1112
  )
@@ -1141,15 +1115,19 @@ export class SchemaGenerator<
1141
1115
  }
1142
1116
 
1143
1117
  const result = await generator.schema?.({
1144
- instance: this,
1118
+ config: this.context.pluginManager.config,
1119
+ generator: this,
1145
1120
  schema: {
1146
1121
  name,
1147
1122
  value: schemaObject,
1148
1123
  tree,
1149
1124
  },
1150
- options: {
1151
- ...this.options,
1152
- ...options,
1125
+ plugin: {
1126
+ ...this.context.plugin,
1127
+ options: {
1128
+ ...this.options,
1129
+ ...options,
1130
+ },
1153
1131
  },
1154
1132
  })
1155
1133
 
@@ -1,4 +1,5 @@
1
1
  import type { KubbFile } from '@kubb/fabric-core/types'
2
+ import type { SchemaObject } from '@kubb/oas'
2
3
 
3
4
  export type SchemaKeywordMapper = {
4
5
  object: {
@@ -161,6 +162,7 @@ export type SchemaKeywordBase<T> = {
161
162
  export type Schema = { keyword: string } | SchemaKeywordMapper[keyof SchemaKeywordMapper]
162
163
 
163
164
  export type SchemaTree = {
165
+ schema: SchemaObject
164
166
  parent: Schema | undefined
165
167
  current: Schema
166
168
  siblings: Schema[]
@@ -2,4 +2,3 @@ export { createGenerator } from './createGenerator.ts'
2
2
  export { createReactGenerator } from './createReactGenerator.ts'
3
3
  export { jsonGenerator } from './jsonGenerator.ts'
4
4
  export type { Generator } from './types.ts'
5
- export { buildOperation, buildOperations, buildSchema } from './utils.tsx'
@@ -6,8 +6,8 @@ import { createGenerator } from './createGenerator.ts'
6
6
 
7
7
  export const jsonGenerator = createGenerator<PluginOas>({
8
8
  name: 'plugin-oas',
9
- async schema({ schema, instance }) {
10
- const { pluginManager, plugin } = instance.context
9
+ async schema({ schema, generator }) {
10
+ const { pluginManager, plugin } = generator.context
11
11
  const file = pluginManager.getFile({
12
12
  name: camelCase(schema.name),
13
13
  extname: '.json',
@@ -27,11 +27,11 @@ export const jsonGenerator = createGenerator<PluginOas>({
27
27
  },
28
28
  ],
29
29
  banner: getBanner({
30
- oas: instance.context.oas,
30
+ oas: generator.context.oas,
31
31
  output: plugin.options.output,
32
32
  config: pluginManager.config,
33
33
  }),
34
- format: getFooter({ oas: instance.context.oas, output: plugin.options.output }),
34
+ format: getFooter({ oas: generator.context.oas, output: plugin.options.output }),
35
35
  },
36
36
  ]
37
37
  },
@@ -1,30 +1,29 @@
1
- import type { PluginFactoryOptions } from '@kubb/core'
1
+ import type { Config, Plugin, PluginFactoryOptions } from '@kubb/core'
2
2
  import type { Operation, SchemaObject } from '@kubb/oas'
3
- import type { OperationGenerator, Schema, SchemaGenerator, SchemaGeneratorOptions } from '@kubb/plugin-oas'
3
+ import type { OperationGenerator } from '../OperationGenerator.ts'
4
+ import type { SchemaGenerator, SchemaGeneratorOptions } from '../SchemaGenerator.ts'
5
+ import type { Schema } from '../SchemaMapper.ts'
4
6
  import type { CoreGenerator } from './createGenerator.ts'
5
7
  import type { ReactGenerator } from './createReactGenerator.ts'
6
8
 
7
9
  export type OperationsProps<TOptions extends PluginFactoryOptions> = {
8
- /**
9
- * @deprecated
10
- */
11
- instance: Omit<OperationGenerator<TOptions>, 'build'>
12
- options: TOptions['resolvedOptions']
10
+ config: Config
11
+ generator: Omit<OperationGenerator<TOptions>, 'build'>
12
+ plugin: Plugin<TOptions>
13
13
  operations: Array<Operation>
14
14
  }
15
15
 
16
16
  export type OperationProps<TOptions extends PluginFactoryOptions> = {
17
- /**
18
- * @deprecated
19
- */
20
- instance: Omit<OperationGenerator<TOptions>, 'build'>
21
- options: TOptions['resolvedOptions']
17
+ config: Config
18
+ generator: Omit<OperationGenerator<TOptions>, 'build'>
19
+ plugin: Plugin<TOptions>
22
20
  operation: Operation
23
21
  }
24
22
 
25
23
  export type SchemaProps<TOptions extends PluginFactoryOptions> = {
26
- instance: Omit<SchemaGenerator<SchemaGeneratorOptions, TOptions>, 'build'>
27
- options: TOptions['resolvedOptions']
24
+ config: Config
25
+ generator: Omit<SchemaGenerator<SchemaGeneratorOptions, TOptions>, 'build'>
26
+ plugin: Plugin<TOptions>
28
27
  schema: {
29
28
  name: string
30
29
  tree: Array<Schema>
@@ -1,6 +1,4 @@
1
1
  export { useOas } from './useOas.ts'
2
- export { useOperation } from './useOperation.ts'
3
2
  export type { SchemaNames } from './useOperationManager.ts'
4
3
  export { useOperationManager } from './useOperationManager.ts'
5
- export { useSchema } from './useSchema.ts'
6
4
  export { useSchemaManager } from './useSchemaManager.ts'
@@ -2,8 +2,7 @@ import type { FileMetaBase, Plugin, ResolveNameParams } from '@kubb/core'
2
2
  import { usePlugin, usePluginManager } from '@kubb/core/hooks'
3
3
  import type { KubbFile } from '@kubb/fabric-core/types'
4
4
  import type { Operation, Operation as OperationType } from '@kubb/oas'
5
- import { useContext } from '@kubb/react-fabric'
6
- import { Oas } from '../components/Oas.tsx'
5
+ import type { OperationGenerator } from '../OperationGenerator.ts'
7
6
  import type { OperationSchemas } from '../types.ts'
8
7
 
9
8
  type FileMeta = FileMetaBase & {
@@ -63,10 +62,9 @@ type UseOperationManagerResult = {
63
62
  /**
64
63
  * `useOperationManager` will return some helper functions that can be used to get the operation file, get the operation name.
65
64
  */
66
- export function useOperationManager(): UseOperationManagerResult {
65
+ export function useOperationManager(generator: Omit<OperationGenerator, 'build'>): UseOperationManagerResult {
67
66
  const plugin = usePlugin()
68
67
  const pluginManager = usePluginManager()
69
- const { generator } = useContext(Oas.Context)
70
68
 
71
69
  const getName: UseOperationManagerResult['getName'] = (operation, { prefix = '', suffix = '', pluginKey = plugin.key, type }) => {
72
70
  return pluginManager.resolveName({
package/src/index.ts CHANGED
@@ -1,4 +1,3 @@
1
- export * from './generators/index.ts'
2
1
  export type { OperationMethodResult } from './OperationGenerator.ts'
3
2
  export { OperationGenerator } from './OperationGenerator.ts'
4
3
  export { pluginOas, pluginOasName } from './plugin.ts'
@@ -19,3 +18,4 @@ export type {
19
18
  } from './SchemaMapper.ts'
20
19
  export { isKeyword, schemaKeywords } from './SchemaMapper.ts'
21
20
  export type * from './types.ts'
21
+ export { buildOperation, buildOperations, buildSchema } from './utils.tsx'
@@ -1,7 +1,7 @@
1
+ import path from 'node:path'
1
2
  import type { Config, Output } from '@kubb/core'
2
3
  import type { Oas } from '@kubb/oas'
3
4
  import { isFunction } from 'remeda'
4
- import path from 'node:path'
5
5
 
6
6
  type Props<TOas extends Oas> = {
7
7
  oas: TOas
@@ -1,8 +1,7 @@
1
- import { isParameterObject } from '@kubb/oas'
2
-
3
1
  import { camelCase, isValidVarName } from '@kubb/core/transformers'
4
2
  import type { FunctionParamsAST } from '@kubb/core/utils'
5
3
  import type { OasTypes } from '@kubb/oas'
4
+ import { isParameterObject } from '@kubb/oas'
6
5
  import type { Params } from '@kubb/react-fabric/types'
7
6
  import type { OperationSchema } from '../types.ts'
8
7
  /**
@@ -1,6 +1,5 @@
1
- import { isOpenApiV3_1Document } from '@kubb/oas'
2
-
3
1
  import type { Oas, OpenAPIV3, OpenAPIV3_1, SchemaObject } from '@kubb/oas'
2
+ import { isOpenApiV3_1Document } from '@kubb/oas'
4
3
 
5
4
  /**
6
5
  * Make it possible to narrow down the schema based on a specific version(3 or 3.1)