@kubb/plugin-oas 3.16.1 → 3.16.3

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 (111) hide show
  1. package/dist/Oas-CuqAnIw-.js +60 -0
  2. package/dist/Oas-CuqAnIw-.js.map +1 -0
  3. package/dist/Oas-Cv_pyXRM.cjs +78 -0
  4. package/dist/Oas-Cv_pyXRM.cjs.map +1 -0
  5. package/dist/OperationGenerator-CgbXErhW.d.cts +900 -0
  6. package/dist/OperationGenerator-OtLcGk2y.d.ts +900 -0
  7. package/dist/Schema-DJshqHto.d.cts +38 -0
  8. package/dist/Schema-DOXGUW1m.d.ts +38 -0
  9. package/dist/SchemaGenerator-8205BXCp.cjs +942 -0
  10. package/dist/SchemaGenerator-8205BXCp.cjs.map +1 -0
  11. package/dist/SchemaGenerator-B8Io6kky.js +930 -0
  12. package/dist/SchemaGenerator-B8Io6kky.js.map +1 -0
  13. package/dist/SchemaMapper-BaZQKrQB.js +54 -0
  14. package/dist/SchemaMapper-BaZQKrQB.js.map +1 -0
  15. package/dist/SchemaMapper-BiagBQN4.d.cts +388 -0
  16. package/dist/SchemaMapper-C2J2d3o4.d.ts +388 -0
  17. package/dist/SchemaMapper-D8J0V9Pj.cjs +66 -0
  18. package/dist/SchemaMapper-D8J0V9Pj.cjs.map +1 -0
  19. package/dist/chunk-CUT6urMc.cjs +30 -0
  20. package/dist/components.cjs +4 -19
  21. package/dist/components.d.cts +42 -35
  22. package/dist/components.d.ts +42 -35
  23. package/dist/components.js +3 -3
  24. package/dist/generators-BhLMlRNk.js +137 -0
  25. package/dist/generators-BhLMlRNk.js.map +1 -0
  26. package/dist/generators-DLH2kvlh.cjs +155 -0
  27. package/dist/generators-DLH2kvlh.cjs.map +1 -0
  28. package/dist/generators.cjs +4 -13
  29. package/dist/generators.d.cts +5 -7
  30. package/dist/generators.d.ts +5 -7
  31. package/dist/generators.js +5 -5
  32. package/dist/getFooter-BChY2kC1.cjs +43 -0
  33. package/dist/getFooter-BChY2kC1.cjs.map +1 -0
  34. package/dist/getFooter-T7_pZ6f8.js +31 -0
  35. package/dist/getFooter-T7_pZ6f8.js.map +1 -0
  36. package/dist/getSchemas-D8mP129c.cjs +67 -0
  37. package/dist/getSchemas-D8mP129c.cjs.map +1 -0
  38. package/dist/getSchemas-WoSBIxG8.js +55 -0
  39. package/dist/getSchemas-WoSBIxG8.js.map +1 -0
  40. package/dist/hooks.cjs +213 -195
  41. package/dist/hooks.cjs.map +1 -1
  42. package/dist/hooks.d.cts +91 -86
  43. package/dist/hooks.d.ts +91 -86
  44. package/dist/hooks.js +212 -193
  45. package/dist/hooks.js.map +1 -1
  46. package/dist/index.cjs +280 -344
  47. package/dist/index.cjs.map +1 -1
  48. package/dist/index.d.cts +7 -10
  49. package/dist/index.d.ts +7 -10
  50. package/dist/index.js +274 -318
  51. package/dist/index.js.map +1 -1
  52. package/dist/mocks.cjs +802 -737
  53. package/dist/mocks.cjs.map +1 -1
  54. package/dist/mocks.d.cts +12 -11
  55. package/dist/mocks.d.ts +12 -11
  56. package/dist/mocks.js +802 -735
  57. package/dist/mocks.js.map +1 -1
  58. package/dist/parseFromConfig-CMNGsef2.cjs +33 -0
  59. package/dist/parseFromConfig-CMNGsef2.cjs.map +1 -0
  60. package/dist/parseFromConfig-yAiFK03V.js +27 -0
  61. package/dist/parseFromConfig-yAiFK03V.js.map +1 -0
  62. package/dist/utils.cjs +58 -74
  63. package/dist/utils.cjs.map +1 -1
  64. package/dist/utils.d.cts +96 -42
  65. package/dist/utils.d.ts +96 -42
  66. package/dist/utils.js +47 -46
  67. package/dist/utils.js.map +1 -1
  68. package/package.json +28 -36
  69. package/src/SchemaGenerator.ts +6 -1
  70. package/src/components/Operation.tsx +1 -2
  71. package/src/mocks/schemas.ts +39 -0
  72. package/src/utils/getBanner.ts +5 -5
  73. package/src/utils/getFooter.ts +4 -4
  74. package/dist/OperationGenerator-C7NPZtOM.d.ts +0 -288
  75. package/dist/OperationGenerator-DJE2XQ83.d.cts +0 -288
  76. package/dist/Schema-AjebpeVY.d.ts +0 -32
  77. package/dist/Schema-M6983FL1.d.cts +0 -32
  78. package/dist/SchemaMapper-B21ZmWag.d.cts +0 -275
  79. package/dist/SchemaMapper-B21ZmWag.d.ts +0 -275
  80. package/dist/chunk-6S7YFY6F.js +0 -33
  81. package/dist/chunk-6S7YFY6F.js.map +0 -1
  82. package/dist/chunk-76E35IZ2.js +0 -56
  83. package/dist/chunk-76E35IZ2.js.map +0 -1
  84. package/dist/chunk-7RFNM43R.cjs +0 -41
  85. package/dist/chunk-7RFNM43R.cjs.map +0 -1
  86. package/dist/chunk-DTD4ZUDA.cjs +0 -36
  87. package/dist/chunk-DTD4ZUDA.cjs.map +0 -1
  88. package/dist/chunk-G3FDK7YW.js +0 -35
  89. package/dist/chunk-G3FDK7YW.js.map +0 -1
  90. package/dist/chunk-JNN4JPWK.js +0 -28
  91. package/dist/chunk-JNN4JPWK.js.map +0 -1
  92. package/dist/chunk-MBX66JAT.js +0 -93
  93. package/dist/chunk-MBX66JAT.js.map +0 -1
  94. package/dist/chunk-NFLZLRQS.cjs +0 -869
  95. package/dist/chunk-NFLZLRQS.cjs.map +0 -1
  96. package/dist/chunk-P2VXWGXZ.js +0 -862
  97. package/dist/chunk-P2VXWGXZ.js.map +0 -1
  98. package/dist/chunk-PORSNYI5.js +0 -47
  99. package/dist/chunk-PORSNYI5.js.map +0 -1
  100. package/dist/chunk-QJMOOF2A.cjs +0 -97
  101. package/dist/chunk-QJMOOF2A.cjs.map +0 -1
  102. package/dist/chunk-YWMMI3MO.cjs +0 -59
  103. package/dist/chunk-YWMMI3MO.cjs.map +0 -1
  104. package/dist/chunk-Z2NREI4X.cjs +0 -32
  105. package/dist/chunk-Z2NREI4X.cjs.map +0 -1
  106. package/dist/chunk-ZVFL3NXX.cjs +0 -50
  107. package/dist/chunk-ZVFL3NXX.cjs.map +0 -1
  108. package/dist/components.cjs.map +0 -1
  109. package/dist/components.js.map +0 -1
  110. package/dist/generators.cjs.map +0 -1
  111. package/dist/generators.js.map +0 -1
package/dist/utils.d.ts CHANGED
@@ -1,35 +1,73 @@
1
- import { Operation, Oas, SchemaObject, OpenAPIV3, OpenAPIV3_1, contentType, OasTypes } from '@kubb/oas';
2
- export { isOptional } from '@kubb/oas';
3
- import { FunctionParamsAST } from '@kubb/core/utils';
4
- import { Params } from '@kubb/react/types';
5
- import { n as OperationSchema } from './OperationGenerator-C7NPZtOM.js';
6
- import { Config, Output } from '@kubb/core';
7
- import '@kubb/core/fs';
8
- import './SchemaMapper-B21ZmWag.js';
1
+ import { Config, Oas, OasTypes, OpenAPIV3, OpenAPIV3_1, Operation, OperationSchema, Output, Params, SchemaObject, contentType } from "./OperationGenerator-OtLcGk2y.js";
2
+ import "./SchemaMapper-C2J2d3o4.js";
3
+ import { OASDocument, SchemaObject as SchemaObject$1 } from "oas/types";
4
+ import { OpenAPIV3 as OpenAPIV3$1 } from "openapi-types";
9
5
 
10
- declare function getComments(operation: Operation): string[];
6
+ //#region ../oas/src/utils.d.ts
11
7
 
8
+ declare function isOptional(schema?: SchemaObject$1): boolean;
9
+ //#endregion
10
+ //#region ../core/src/utils/FunctionParams.d.ts
11
+ type FunctionParamsASTWithoutType = {
12
+ name?: string;
13
+ type?: string;
14
+ /**
15
+ * @default true
16
+ */
17
+ required?: boolean;
18
+ /**
19
+ * @default true
20
+ */
21
+ enabled?: boolean;
22
+ default?: string;
23
+ };
24
+ type FunctionParamsASTWithType = {
25
+ name?: never;
26
+ type: string;
27
+ /**
28
+ * @default true
29
+ */
30
+ required?: boolean;
31
+ /**
32
+ * @default true
33
+ */
34
+ enabled?: boolean;
35
+ default?: string;
36
+ };
37
+ /**
38
+ * @deprecated
39
+ */
40
+ type FunctionParamsAST = FunctionParamsASTWithoutType | FunctionParamsASTWithType;
41
+ /**
42
+ * @deprecated
43
+ */
44
+ //#endregion
45
+ //#region src/utils/getComments.d.ts
46
+ declare function getComments(operation: Operation): string[];
47
+ //#endregion
48
+ //#region src/utils/getParams.d.ts
12
49
  declare function getPathParams(operationSchema: OperationSchema | undefined, options?: {
13
- typed?: boolean;
14
- casing?: 'camelcase';
15
- override?: (data: FunctionParamsAST) => FunctionParamsAST;
50
+ typed?: boolean;
51
+ casing?: 'camelcase';
52
+ override?: (data: FunctionParamsAST) => FunctionParamsAST;
16
53
  }): Params;
17
-
54
+ //#endregion
55
+ //#region src/utils/getSchemaFactory.d.ts
18
56
  /**
19
57
  * Make it possible to narrow down the schema based on a specific version(3 or 3.1)
20
58
  */
21
59
  type SchemaResult<TWithRef extends boolean = false> = {
22
- schemaObject?: (TWithRef extends true ? OpenAPIV3.SchemaObject | OpenAPIV3.ReferenceObject : OpenAPIV3.SchemaObject) & {
23
- nullable?: boolean;
24
- 'x-nullable'?: boolean;
25
- };
26
- version: '3.0';
60
+ schemaObject?: (TWithRef extends true ? OpenAPIV3.SchemaObject | OpenAPIV3.ReferenceObject : OpenAPIV3.SchemaObject) & {
61
+ nullable?: boolean;
62
+ 'x-nullable'?: boolean;
63
+ };
64
+ version: '3.0';
27
65
  } | {
28
- schemaObject?: (TWithRef extends true ? OpenAPIV3_1.SchemaObject | OpenAPIV3_1.ReferenceObject : OpenAPIV3_1.SchemaObject) & {
29
- nullable?: boolean;
30
- 'x-nullable'?: boolean;
31
- };
32
- version: '3.1';
66
+ schemaObject?: (TWithRef extends true ? OpenAPIV3_1.SchemaObject | OpenAPIV3_1.ReferenceObject : OpenAPIV3_1.SchemaObject) & {
67
+ nullable?: boolean;
68
+ 'x-nullable'?: boolean;
69
+ };
70
+ version: '3.1';
33
71
  };
34
72
  /**
35
73
  * Creates a factory function that generates a versioned OpenAPI schema result.
@@ -39,28 +77,44 @@ type SchemaResult<TWithRef extends boolean = false> = {
39
77
  * @returns A function that takes an optional schema and returns a versioned schema result.
40
78
  */
41
79
  declare function getSchemaFactory<TWithRef extends boolean = false>(oas: Oas): (schema?: SchemaObject) => SchemaResult<TWithRef>;
42
-
80
+ //#endregion
81
+ //#region src/utils/getSchemas.d.ts
43
82
  type Mode = 'schemas' | 'responses' | 'requestBodies';
44
83
  type GetSchemasProps = {
45
- oas: Oas;
46
- contentType?: contentType;
47
- includes?: Mode[];
84
+ oas: Oas;
85
+ contentType?: contentType;
86
+ includes?: Mode[];
48
87
  };
49
- declare function getSchemas({ oas, contentType, includes }: GetSchemasProps): Record<string, OasTypes.SchemaObject>;
50
-
88
+ declare function getSchemas({
89
+ oas,
90
+ contentType,
91
+ includes
92
+ }: GetSchemasProps): Record<string, OasTypes.SchemaObject>;
93
+ //#endregion
94
+ //#region src/utils/parseFromConfig.d.ts
51
95
  declare function parseFromConfig(config: Config, oasClass?: typeof Oas): Promise<Oas>;
52
-
53
- type Props$1 = {
54
- oas: Oas;
55
- output: Output<Oas>;
56
- config?: Config;
96
+ //#endregion
97
+ //#region src/utils/getBanner.d.ts
98
+ type Props$1<TOas extends Oas> = {
99
+ oas: TOas;
100
+ output: Output<any>;
101
+ config?: Config;
57
102
  };
58
- declare function getBanner({ output, oas, config }: Props$1): string;
59
-
60
- type Props = {
61
- oas: Oas;
62
- output: Output<Oas>;
103
+ declare function getBanner<TOas extends Oas>({
104
+ output,
105
+ oas,
106
+ config
107
+ }: Props$1<TOas>): string;
108
+ //#endregion
109
+ //#region src/utils/getFooter.d.ts
110
+ type Props<TOas extends Oas> = {
111
+ oas: TOas;
112
+ output: Output<any>;
63
113
  };
64
- declare function getFooter({ output, oas }: Props): string | undefined;
65
-
66
- export { getBanner, getComments, getFooter, getPathParams, getSchemaFactory, getSchemas, parseFromConfig };
114
+ declare function getFooter<TOas extends Oas>({
115
+ output,
116
+ oas
117
+ }: Props<TOas>): string | undefined;
118
+ //#endregion
119
+ export { getBanner, getComments, getFooter, getPathParams, getSchemaFactory, getSchemas, isOptional, parseFromConfig };
120
+ //# sourceMappingURL=utils.d.ts.map
package/dist/utils.js CHANGED
@@ -1,54 +1,55 @@
1
- export { parseFromConfig } from './chunk-G3FDK7YW.js';
2
- export { getBanner, getFooter } from './chunk-6S7YFY6F.js';
3
- export { getSchemaFactory, getSchemas } from './chunk-PORSNYI5.js';
4
- import transformers, { isValidVarName, camelCase } from '@kubb/core/transformers';
5
- import { URLPath } from '@kubb/core/utils';
6
- import { isParameterObject } from '@kubb/oas';
7
- export { isOptional } from '@kubb/oas';
1
+ import { getBanner, getFooter } from "./getFooter-T7_pZ6f8.js";
2
+ import { getSchemaFactory, getSchemas } from "./getSchemas-WoSBIxG8.js";
3
+ import { parseFromConfig } from "./parseFromConfig-yAiFK03V.js";
4
+ import transformers, { camelCase, isValidVarName } from "@kubb/core/transformers";
5
+ import { URLPath } from "@kubb/core/utils";
6
+ import { isOptional, isParameterObject } from "@kubb/oas";
8
7
 
8
+ //#region src/utils/getComments.ts
9
9
  function getComments(operation) {
10
- return [
11
- operation.getDescription() && `@description ${operation.getDescription()}`,
12
- operation.getSummary() && `@summary ${operation.getSummary()}`,
13
- operation.path && `{@link ${new URLPath(operation.path).URL}}`,
14
- operation.isDeprecated() && "@deprecated"
15
- ].filter(Boolean).map((text) => transformers.trim(text));
10
+ return [
11
+ operation.getDescription() && `@description ${operation.getDescription()}`,
12
+ operation.getSummary() && `@summary ${operation.getSummary()}`,
13
+ operation.path && `{@link ${new URLPath(operation.path).URL}}`,
14
+ operation.isDeprecated() && "@deprecated"
15
+ ].filter(Boolean).map((text) => transformers.trim(text));
16
16
  }
17
- function getASTParams(operationSchema, {
18
- typed = false,
19
- override
20
- } = {}) {
21
- if (!operationSchema || !operationSchema.schema.properties || !operationSchema.name) {
22
- return [];
23
- }
24
- return Object.entries(operationSchema.schema.properties).map(([name, schema]) => {
25
- const isParam = isParameterObject(schema);
26
- const data = {
27
- name,
28
- enabled: !!name,
29
- required: isParam ? schema.required : true,
30
- type: typed ? `${operationSchema.name}["${name}"]` : void 0
31
- };
32
- return override ? override(data) : data;
33
- });
17
+
18
+ //#endregion
19
+ //#region src/utils/getParams.ts
20
+ /**
21
+ *
22
+ * @deprecated
23
+ * TODO move to operationManager hook
24
+ */
25
+ function getASTParams(operationSchema, { typed = false, override } = {}) {
26
+ if (!operationSchema || !operationSchema.schema.properties || !operationSchema.name) return [];
27
+ return Object.entries(operationSchema.schema.properties).map(([name, schema]) => {
28
+ const isParam = isParameterObject(schema);
29
+ const data = {
30
+ name,
31
+ enabled: !!name,
32
+ required: isParam ? schema.required : true,
33
+ type: typed ? `${operationSchema.name}["${name}"]` : void 0
34
+ };
35
+ return override ? override(data) : data;
36
+ });
34
37
  }
35
38
  function getPathParams(operationSchema, options = {}) {
36
- return getASTParams(operationSchema, options).reduce((acc, curr) => {
37
- if (curr.name && curr.enabled) {
38
- let name = isValidVarName(curr.name) ? curr.name : camelCase(curr.name);
39
- if (options.casing === "camelcase") {
40
- name = camelCase(name);
41
- }
42
- acc[name] = {
43
- default: curr.default,
44
- type: curr.type,
45
- optional: !curr.required
46
- };
47
- }
48
- return acc;
49
- }, {});
39
+ return getASTParams(operationSchema, options).reduce((acc, curr) => {
40
+ if (curr.name && curr.enabled) {
41
+ let name = isValidVarName(curr.name) ? curr.name : camelCase(curr.name);
42
+ if (options.casing === "camelcase") name = camelCase(name);
43
+ acc[name] = {
44
+ default: curr.default,
45
+ type: curr.type,
46
+ optional: !curr.required
47
+ };
48
+ }
49
+ return acc;
50
+ }, {});
50
51
  }
51
52
 
52
- export { getComments, getPathParams };
53
- //# sourceMappingURL=utils.js.map
53
+ //#endregion
54
+ export { getBanner, getComments, getFooter, getPathParams, getSchemaFactory, getSchemas, isOptional, parseFromConfig };
54
55
  //# sourceMappingURL=utils.js.map
package/dist/utils.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/utils/getComments.ts","../src/utils/getParams.ts"],"names":[],"mappings":";;;;;;;;AAKO,SAAS,YAAY,SAAgC,EAAA;AAC1D,EAAO,OAAA;AAAA,IACL,UAAU,cAAe,EAAA,IAAK,CAAgB,aAAA,EAAA,SAAA,CAAU,gBAAgB,CAAA,CAAA;AAAA,IACxE,UAAU,UAAW,EAAA,IAAK,CAAY,SAAA,EAAA,SAAA,CAAU,YAAY,CAAA,CAAA;AAAA,IAC5D,SAAA,CAAU,QAAQ,CAAU,OAAA,EAAA,IAAI,QAAQ,SAAU,CAAA,IAAI,EAAE,GAAG,CAAA,CAAA,CAAA;AAAA,IAC3D,SAAA,CAAU,cAAkB,IAAA;AAAA,GAC9B,CACG,MAAO,CAAA,OAAO,CACd,CAAA,GAAA,CAAI,CAAC,IAAS,KAAA,YAAA,CAAa,IAAK,CAAA,IAAI,CAAC,CAAA;AAC1C;ACFO,SAAS,aACd,eACA,EAAA;AAAA,EACE,KAAQ,GAAA,KAAA;AAAA,EACR;AACF,CAAA,GAGI,EACiB,EAAA;AACrB,EAAI,IAAA,CAAC,mBAAmB,CAAC,eAAA,CAAgB,OAAO,UAAc,IAAA,CAAC,gBAAgB,IAAM,EAAA;AACnF,IAAA,OAAO,EAAC;AAAA;AAGV,EAAO,OAAA,MAAA,CAAO,OAAQ,CAAA,eAAA,CAAgB,MAAO,CAAA,UAAU,CAAE,CAAA,GAAA,CAAI,CAAC,CAAC,IAAM,EAAA,MAAM,CAAuC,KAAA;AAChH,IAAM,MAAA,OAAA,GAAU,kBAAkB,MAAM,CAAA;AACxC,IAAA,MAAM,IAA0B,GAAA;AAAA,MAC9B,IAAA;AAAA,MACA,OAAA,EAAS,CAAC,CAAC,IAAA;AAAA,MACX,QAAA,EAAU,OAAU,GAAA,MAAA,CAAO,QAAW,GAAA,IAAA;AAAA,MACtC,MAAM,KAAQ,GAAA,CAAA,EAAG,gBAAgB,IAAI,CAAA,EAAA,EAAK,IAAI,CAAO,EAAA,CAAA,GAAA;AAAA,KACvD;AAEA,IAAO,OAAA,QAAA,GAAW,QAAS,CAAA,IAAI,CAAI,GAAA,IAAA;AAAA,GACpC,CAAA;AACH;AAEO,SAAS,aACd,CAAA,eAAA,EACA,OAII,GAAA,EACJ,EAAA;AACA,EAAA,OAAO,aAAa,eAAiB,EAAA,OAAO,EAAE,MAAO,CAAA,CAAC,KAAK,IAAS,KAAA;AAClE,IAAI,IAAA,IAAA,CAAK,IAAQ,IAAA,IAAA,CAAK,OAAS,EAAA;AAC7B,MAAI,IAAA,IAAA,GAAO,eAAe,IAAK,CAAA,IAAI,IAAI,IAAK,CAAA,IAAA,GAAO,SAAU,CAAA,IAAA,CAAK,IAAI,CAAA;AAEtE,MAAI,IAAA,OAAA,CAAQ,WAAW,WAAa,EAAA;AAClC,QAAA,IAAA,GAAO,UAAU,IAAI,CAAA;AAAA;AAGvB,MAAA,GAAA,CAAI,IAAI,CAAI,GAAA;AAAA,QACV,SAAS,IAAK,CAAA,OAAA;AAAA,QACd,MAAM,IAAK,CAAA,IAAA;AAAA,QACX,QAAA,EAAU,CAAC,IAAK,CAAA;AAAA,OAClB;AAAA;AAGF,IAAO,OAAA,GAAA;AAAA,GACT,EAAG,EAAY,CAAA;AACjB","file":"utils.js","sourcesContent":["import transformers from '@kubb/core/transformers'\nimport { URLPath } from '@kubb/core/utils'\n\nimport type { Operation } from '@kubb/oas'\n\nexport function getComments(operation: Operation): string[] {\n return [\n operation.getDescription() && `@description ${operation.getDescription()}`,\n operation.getSummary() && `@summary ${operation.getSummary()}`,\n operation.path && `{@link ${new URLPath(operation.path).URL}}`,\n operation.isDeprecated() && '@deprecated',\n ]\n .filter(Boolean)\n .map((text) => transformers.trim(text))\n}\n","import { isParameterObject } from '@kubb/oas'\n\nimport { camelCase, isValidVarName } from '@kubb/core/transformers'\nimport type { FunctionParamsAST } from '@kubb/core/utils'\nimport type { OasTypes } from '@kubb/oas'\nimport type { Params } from '@kubb/react/types'\nimport type { OperationSchema } from '../types.ts'\n/**\n *\n * @deprecated\n * TODO move to operationManager hook\n */\nexport function getASTParams(\n operationSchema: OperationSchema | undefined,\n {\n typed = false,\n override,\n }: {\n typed?: boolean\n override?: (data: FunctionParamsAST) => FunctionParamsAST\n } = {},\n): FunctionParamsAST[] {\n if (!operationSchema || !operationSchema.schema.properties || !operationSchema.name) {\n return []\n }\n\n return Object.entries(operationSchema.schema.properties).map(([name, schema]: [string, OasTypes.SchemaObject]) => {\n const isParam = isParameterObject(schema)\n const data: FunctionParamsAST = {\n name,\n enabled: !!name,\n required: isParam ? schema.required : true,\n type: typed ? `${operationSchema.name}[\"${name}\"]` : undefined,\n }\n\n return override ? override(data) : data\n })\n}\n\nexport function getPathParams(\n operationSchema: OperationSchema | undefined,\n options: {\n typed?: boolean\n casing?: 'camelcase'\n override?: (data: FunctionParamsAST) => FunctionParamsAST\n } = {},\n) {\n return getASTParams(operationSchema, options).reduce((acc, curr) => {\n if (curr.name && curr.enabled) {\n let name = isValidVarName(curr.name) ? curr.name : camelCase(curr.name)\n\n if (options.casing === 'camelcase') {\n name = camelCase(name)\n }\n\n acc[name] = {\n default: curr.default,\n type: curr.type,\n optional: !curr.required,\n }\n }\n\n return acc\n }, {} as Params)\n}\n"]}
1
+ {"version":3,"file":"utils.js","names":["operation: Operation","operationSchema: OperationSchema | undefined","data: FunctionParamsAST","options: {\n typed?: boolean\n casing?: 'camelcase'\n override?: (data: FunctionParamsAST) => FunctionParamsAST\n }"],"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/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,YAAYA,WAAgC;AAC1D,QAAO;EACL,UAAU,gBAAgB,IAAI,CAAC,aAAa,EAAE,UAAU,gBAAgB,EAAE;EAC1E,UAAU,YAAY,IAAI,CAAC,SAAS,EAAE,UAAU,YAAY,EAAE;EAC9D,UAAU,QAAQ,CAAC,OAAO,EAAE,IAAI,QAAQ,UAAU,MAAM,IAAI,CAAC,CAAC;EAC9D,UAAU,cAAc,IAAI;CAC7B,EACE,OAAO,QAAQ,CACf,IAAI,CAAC,SAAS,aAAa,KAAK,KAAK,CAAC;AAC1C;;;;;;;;;ACFD,SAAgB,aACdC,iBACA,EACE,QAAQ,OACR,UAID,GAAG,CAAE,GACe;AACrB,KAAI,CAAC,mBAAmB,CAAC,gBAAgB,OAAO,cAAc,CAAC,gBAAgB,KAC7E,QAAO,CAAE;AAGX,QAAO,OAAO,QAAQ,gBAAgB,OAAO,WAAW,CAAC,IAAI,CAAC,CAAC,MAAM,OAAwC,KAAK;EAChH,MAAM,UAAU,kBAAkB,OAAO;EACzC,MAAMC,OAA0B;GAC9B;GACA,SAAS,CAAC,CAAC;GACX,UAAU,UAAU,OAAO,WAAW;GACtC,MAAM,QAAQ,GAAG,gBAAgB,KAAK,EAAE,EAAE,KAAK,EAAE,CAAC,GAAG;EACtD;AAED,SAAO,WAAW,SAAS,KAAK,GAAG;CACpC,EAAC;AACH;AAED,SAAgB,cACdD,iBACAE,UAII,CAAE,GACN;AACA,QAAO,aAAa,iBAAiB,QAAQ,CAAC,OAAO,CAAC,KAAK,SAAS;AAClE,MAAI,KAAK,QAAQ,KAAK,SAAS;GAC7B,IAAI,OAAO,eAAe,KAAK,KAAK,GAAG,KAAK,OAAO,UAAU,KAAK,KAAK;AAEvE,OAAI,QAAQ,WAAW,aACrB,OAAO,UAAU,KAAK;GAGxB,IAAI,QAAQ;IACV,SAAS,KAAK;IACd,MAAM,KAAK;IACX,UAAU,CAAC,KAAK;GACjB;EACF;AAED,SAAO;CACR,GAAE,CAAE,EAAW;AACjB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/plugin-oas",
3
- "version": "3.16.1",
3
+ "version": "3.16.3",
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",
@@ -26,40 +26,33 @@
26
26
  "exports": {
27
27
  ".": {
28
28
  "import": "./dist/index.js",
29
- "require": "./dist/index.cjs",
30
- "default": "./dist/index.cjs"
29
+ "require": "./dist/index.cjs"
30
+ },
31
+ "./components": {
32
+ "import": "./dist/components.js",
33
+ "require": "./dist/components.cjs"
31
34
  },
32
35
  "./generators": {
33
36
  "import": "./dist/generators.js",
34
- "require": "./dist/generators.cjs",
35
- "default": "./dist/generators.cjs"
37
+ "require": "./dist/generators.cjs"
38
+ },
39
+ "./hooks": {
40
+ "import": "./dist/hooks.js",
41
+ "require": "./dist/hooks.cjs"
36
42
  },
37
43
  "./mocks": {
38
44
  "import": "./dist/mocks.js",
39
- "require": "./dist/mocks.cjs",
40
- "default": "./dist/mocks.cjs"
45
+ "require": "./dist/mocks.cjs"
41
46
  },
42
47
  "./utils": {
43
48
  "import": "./dist/utils.js",
44
- "require": "./dist/utils.cjs",
45
- "default": "./dist/utils.cjs"
46
- },
47
- "./hooks": {
48
- "import": "./dist/hooks.js",
49
- "require": "./dist/hooks.cjs",
50
- "default": "./dist/hooks.cjs"
51
- },
52
- "./components": {
53
- "import": "./dist/components.js",
54
- "require": "./dist/components.cjs",
55
- "default": "./dist/components.cjs"
49
+ "require": "./dist/utils.cjs"
56
50
  },
57
- "./package.json": "./package.json",
58
- "./*": "./*"
51
+ "./package.json": "./package.json"
59
52
  },
60
- "main": "dist/index.cjs",
61
- "module": "dist/index.js",
62
- "types": "./dist/index.d.ts",
53
+ "main": "./dist/index.cjs",
54
+ "module": "./dist/index.js",
55
+ "types": "./dist/index.d.cts",
63
56
  "typesVersions": {
64
57
  "*": {
65
58
  "utils": [
@@ -87,19 +80,18 @@
87
80
  ],
88
81
  "dependencies": {
89
82
  "@stoplight/yaml": "^4.3.0",
90
- "p-limit": "~6.2.0",
91
- "remeda": "^2.26.0",
92
- "@kubb/core": "3.16.1",
93
- "@kubb/oas": "3.16.1",
94
- "@kubb/react": "3.16.1"
83
+ "p-limit": "^7.0.0",
84
+ "remeda": "^2.30.0",
85
+ "@kubb/core": "3.16.3",
86
+ "@kubb/oas": "3.16.3",
87
+ "@kubb/react": "3.16.3"
95
88
  },
96
89
  "devDependencies": {
97
90
  "@types/react": "^18.3.23",
98
91
  "react": "^18.3.1",
99
- "tsup": "^8.5.0",
100
- "typescript": "^5.8.3",
101
- "@kubb/config-ts": "3.16.1",
102
- "@kubb/config-tsup": "3.16.1"
92
+ "tsdown": "^0.14.1",
93
+ "typescript": "^5.9.2",
94
+ "@kubb/config-ts": "3.16.3"
103
95
  },
104
96
  "peerDependencies": {
105
97
  "@kubb/react": "^3.0.0"
@@ -112,13 +104,13 @@
112
104
  "registry": "https://registry.npmjs.org/"
113
105
  },
114
106
  "scripts": {
115
- "build": "tsup",
107
+ "build": "tsdown",
116
108
  "clean": "npx rimraf ./dist",
117
109
  "lint": "bun biome lint .",
118
- "lint:fix": "bun biome lint--fix --unsafe .",
110
+ "lint:fix": "bun biome lint --fix --unsafe .",
119
111
  "release": "pnpm publish --no-git-check",
120
112
  "release:canary": "bash ../../.github/canary.sh && node ../../scripts/build.js canary && pnpm publish --no-git-check",
121
- "start": "tsup --watch",
113
+ "start": "tsdown --watch",
122
114
  "test": "vitest --passWithNoTests",
123
115
  "typecheck": "tsc -p ./tsconfig.json --noEmit --emitDeclarationOnly false"
124
116
  }
@@ -5,6 +5,7 @@ import transformers, { pascalCase } from '@kubb/core/transformers'
5
5
  import { getUniqueName } from '@kubb/core/utils'
6
6
  import type { contentType, Oas, OpenAPIV3, SchemaObject } from '@kubb/oas'
7
7
  import { isDiscriminator, isNullable, isReference } from '@kubb/oas'
8
+ import pLimit from 'p-limit'
8
9
  import { isDeepEqual, isNumber, uniqueWith } from 'remeda'
9
10
  import type { Generator } from './generator.tsx'
10
11
  import type { Schema, SchemaKeywordMapper } from './SchemaMapper.ts'
@@ -12,7 +13,6 @@ import { isKeyword, schemaKeywords } from './SchemaMapper.ts'
12
13
  import type { OperationSchema, Override, Refs } from './types.ts'
13
14
  import { getSchemaFactory } from './utils/getSchemaFactory.ts'
14
15
  import { getSchemas } from './utils/getSchemas.ts'
15
- import pLimit from 'p-limit'
16
16
 
17
17
  export type GetSchemaGeneratorOptions<T extends SchemaGenerator<any, any, any>> = T extends SchemaGenerator<infer Options, any, any> ? Options : never
18
18
 
@@ -618,6 +618,11 @@ export class SchemaGenerator<
618
618
  keyword: schemaKeywords.describe,
619
619
  args: schemaObject.description,
620
620
  },
621
+ schemaObject.pattern &&
622
+ schemaObject.type === 'string' && {
623
+ keyword: schemaKeywords.matches,
624
+ args: schemaObject.pattern,
625
+ },
621
626
  nullable && { keyword: schemaKeywords.nullable },
622
627
  schemaObject.readOnly && { keyword: schemaKeywords.readOnly },
623
628
  schemaObject.writeOnly && { keyword: schemaKeywords.writeOnly },
@@ -1,6 +1,5 @@
1
- import { createContext } from '@kubb/react'
2
-
3
1
  import type { Operation as OperationType } from '@kubb/oas'
2
+ import { createContext } from '@kubb/react'
4
3
  import type { KubbNode } from '@kubb/react/types'
5
4
 
6
5
  type Props = {
@@ -450,6 +450,45 @@ const basic: Array<{ name: string; schema: Schema }> = [
450
450
  },
451
451
  },
452
452
  },
453
+ {
454
+ name: 'objectObjectEnum',
455
+ schema: {
456
+ keyword: schemaKeywords.object,
457
+ args: {
458
+ properties: {
459
+ prop1: [
460
+ {
461
+ keyword: schemaKeywords.object,
462
+ args: {
463
+ properties: {
464
+ prop2: [
465
+ {
466
+ keyword: schemaKeywords.schema,
467
+ args: { format: 'string', type: 'string' },
468
+ },
469
+ {
470
+ keyword: schemaKeywords.enum,
471
+ args: {
472
+ name: 'enum',
473
+ typeName: 'Enum',
474
+ asConst: false,
475
+ items: [
476
+ { name: 'A', value: 'A', format: schemaKeywords.string },
477
+ { name: 'B', value: 'B', format: schemaKeywords.string },
478
+ ],
479
+ },
480
+ },
481
+ ],
482
+ },
483
+ additionalProperties: [],
484
+ },
485
+ },
486
+ ],
487
+ },
488
+ additionalProperties: [],
489
+ },
490
+ },
491
+ },
453
492
  {
454
493
  name: 'objectArrayObject',
455
494
  schema: {
@@ -1,14 +1,14 @@
1
- import { getDefaultBanner, type Config, type Output } from '@kubb/core'
1
+ import { type Config, getDefaultBanner, type Output } from '@kubb/core'
2
2
  import type { Oas } from '@kubb/oas'
3
3
  import { isFunction } from 'remeda'
4
4
 
5
- type Props = {
6
- oas: Oas
7
- output: Output<Oas>
5
+ type Props<TOas extends Oas> = {
6
+ oas: TOas
7
+ output: Output<any>
8
8
  config?: Config
9
9
  }
10
10
 
11
- export function getBanner({ output, oas, config }: Props) {
11
+ export function getBanner<TOas extends Oas>({ output, oas, config }: Props<TOas>): string {
12
12
  let banner = ''
13
13
  if (config?.output?.defaultBanner !== false && config) {
14
14
  const { title, description, version } = oas.api?.info || {}
@@ -2,12 +2,12 @@ import type { Output } from '@kubb/core'
2
2
  import type { Oas } from '@kubb/oas'
3
3
  import { isFunction } from 'remeda'
4
4
 
5
- type Props = {
6
- oas: Oas
7
- output: Output<Oas>
5
+ type Props<TOas extends Oas> = {
6
+ oas: TOas
7
+ output: Output<any>
8
8
  }
9
9
 
10
- export function getFooter({ output, oas }: Props) {
10
+ export function getFooter<TOas extends Oas>({ output, oas }: Props<TOas>) {
11
11
  if (!output.footer) {
12
12
  return undefined
13
13
  }