@kubb/plugin-oas 4.29.1 → 4.31.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/utils.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { t as __name } from "./chunk-DKWOrOAv.js";
2
- import { n as withRequiredRequestBodySchema, r as SchemaGenerator, s as getSchemaFactory, t as isRequestBodyRequired } from "./requestBody-BB837wKB.js";
2
+ import { n as withRequiredRequestBodySchema, r as SchemaGenerator, s as getSchemaFactory, t as isRequestBodyRequired } from "./requestBody-CJhU4lwJ.js";
3
3
  import { n as schemaKeywords } from "./SchemaMapper-eQhTeFim.js";
4
4
  import { n as getBanner, t as getFooter } from "./getFooter-_DD1dfMI.js";
5
5
  import transformers, { camelCase, isValidVarName } from "@kubb/core/transformers";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/plugin-oas",
3
- "version": "4.29.1",
3
+ "version": "4.31.1",
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",
@@ -70,7 +70,8 @@
70
70
  "src",
71
71
  "dist",
72
72
  "!/**/**.test.**",
73
- "!/**/__tests__/**"
73
+ "!/**/__tests__/**",
74
+ "!/**/__snapshots__/**"
74
75
  ],
75
76
  "size-limit": [
76
77
  {
@@ -80,13 +81,13 @@
80
81
  }
81
82
  ],
82
83
  "dependencies": {
83
- "@kubb/react-fabric": "0.13.1",
84
+ "@kubb/react-fabric": "0.13.3",
84
85
  "remeda": "^2.33.6",
85
- "@kubb/core": "4.29.1",
86
- "@kubb/oas": "4.29.1"
86
+ "@kubb/core": "4.31.1",
87
+ "@kubb/oas": "4.31.1"
87
88
  },
88
89
  "peerDependencies": {
89
- "@kubb/react-fabric": "0.13.0"
90
+ "@kubb/react-fabric": "0.13.3"
90
91
  },
91
92
  "engines": {
92
93
  "node": ">=20"
@@ -478,6 +478,21 @@ export class SchemaGenerator<
478
478
  ]
479
479
  }
480
480
 
481
+ // Handle non-component internal refs (e.g., #/paths/... created by the bundler when deduplicating
482
+ // external schemas referenced multiple times). These path-based refs produce misleading names
483
+ // from their last path segment (e.g., "#/.../schema/items" → "items" → "itemsSchema").
484
+ // Resolve them inline instead of registering them as named schema references.
485
+ if ($ref.startsWith('#') && !$ref.startsWith('#/components/')) {
486
+ try {
487
+ const inlineSchema = this.context.oas.get<SchemaObject>($ref)
488
+ if (inlineSchema && !isReference(inlineSchema)) {
489
+ return this.parse({ schema: inlineSchema, name, parentName: null, rootName: null })
490
+ }
491
+ } catch {
492
+ // If lookup fails, fall through to standard processing
493
+ }
494
+ }
495
+
481
496
  // Ensure name mapping is initialized before resolving names
482
497
  this.#ensureNameMapping()
483
498
 
package/src/utils.tsx CHANGED
@@ -32,6 +32,7 @@ export async function buildOperations<TOptions extends PluginFactoryOptions>(
32
32
  )
33
33
 
34
34
  await fabric.context.fileManager.upsert(...fabricChild.files)
35
+ fabricChild.unmount()
35
36
  }
36
37
 
37
38
  type BuildOperationOptions<TOptions extends PluginFactoryOptions> = {
@@ -60,6 +61,7 @@ export async function buildOperation<TOptions extends PluginFactoryOptions>(
60
61
  )
61
62
 
62
63
  await fabric.context.fileManager.upsert(...fabricChild.files)
64
+ fabricChild.unmount()
63
65
  }
64
66
 
65
67
  type BuildSchemaOptions<TOptions extends PluginFactoryOptions> = {
@@ -92,4 +94,5 @@ export async function buildSchema<TOptions extends PluginFactoryOptions>(
92
94
  )
93
95
 
94
96
  await fabric.context.fileManager.upsert(...fabricChild.files)
97
+ fabricChild.unmount()
95
98
  }
@@ -1,294 +0,0 @@
1
- import { KubbFile } from "@kubb/fabric-core/types";
2
- import { SchemaObject } from "@kubb/oas";
3
-
4
- //#region \0rolldown/runtime.js
5
- //#endregion
6
- //#region src/SchemaMapper.d.ts
7
- type SchemaKeywordMapper = {
8
- object: {
9
- keyword: 'object';
10
- args: {
11
- properties: {
12
- [x: string]: Schema[];
13
- };
14
- additionalProperties: Schema[];
15
- patternProperties?: Record<string, Schema[]>;
16
- strict?: boolean;
17
- };
18
- };
19
- url: {
20
- keyword: 'url';
21
- };
22
- readOnly: {
23
- keyword: 'readOnly';
24
- };
25
- writeOnly: {
26
- keyword: 'writeOnly';
27
- };
28
- uuid: {
29
- keyword: 'uuid';
30
- };
31
- email: {
32
- keyword: 'email';
33
- };
34
- firstName: {
35
- keyword: 'firstName';
36
- };
37
- lastName: {
38
- keyword: 'lastName';
39
- };
40
- phone: {
41
- keyword: 'phone';
42
- };
43
- password: {
44
- keyword: 'password';
45
- };
46
- date: {
47
- keyword: 'date';
48
- args: {
49
- type?: 'date' | 'string';
50
- };
51
- };
52
- time: {
53
- keyword: 'time';
54
- args: {
55
- type?: 'date' | 'string';
56
- };
57
- };
58
- datetime: {
59
- keyword: 'datetime';
60
- args: {
61
- offset?: boolean;
62
- local?: boolean;
63
- };
64
- };
65
- tuple: {
66
- keyword: 'tuple';
67
- args: {
68
- items: Schema[];
69
- min?: number;
70
- max?: number;
71
- rest?: Schema;
72
- };
73
- };
74
- array: {
75
- keyword: 'array';
76
- args: {
77
- items: Schema[];
78
- min?: number;
79
- max?: number;
80
- unique?: boolean;
81
- };
82
- };
83
- enum: {
84
- keyword: 'enum';
85
- args: {
86
- name: string;
87
- typeName: string;
88
- asConst: boolean;
89
- items: Array<{
90
- name: string | number;
91
- format: 'string' | 'number' | 'boolean';
92
- value?: string | number | boolean;
93
- }>;
94
- };
95
- };
96
- and: {
97
- keyword: 'and';
98
- args: Schema[];
99
- };
100
- const: {
101
- keyword: 'const';
102
- args: {
103
- name: string | number;
104
- format: 'string' | 'number' | 'boolean';
105
- value?: string | number | boolean;
106
- };
107
- };
108
- union: {
109
- keyword: 'union';
110
- args: Schema[];
111
- };
112
- ref: {
113
- keyword: 'ref';
114
- args: {
115
- name: string;
116
- $ref: string;
117
- /**
118
- * Full qualified path.
119
- */
120
- path: KubbFile.Path;
121
- /**
122
- * When true `File.Import` is used.
123
- * When false a reference is used inside the current file.
124
- */
125
- isImportable: boolean;
126
- };
127
- };
128
- matches: {
129
- keyword: 'matches';
130
- args?: string;
131
- };
132
- boolean: {
133
- keyword: 'boolean';
134
- };
135
- default: {
136
- keyword: 'default';
137
- args: string | number | boolean;
138
- };
139
- string: {
140
- keyword: 'string';
141
- };
142
- integer: {
143
- keyword: 'integer';
144
- };
145
- bigint: {
146
- keyword: 'bigint';
147
- };
148
- number: {
149
- keyword: 'number';
150
- };
151
- max: {
152
- keyword: 'max';
153
- args: number;
154
- };
155
- min: {
156
- keyword: 'min';
157
- args: number;
158
- };
159
- exclusiveMaximum: {
160
- keyword: 'exclusiveMaximum';
161
- args: number;
162
- };
163
- exclusiveMinimum: {
164
- keyword: 'exclusiveMinimum';
165
- args: number;
166
- };
167
- describe: {
168
- keyword: 'describe';
169
- args: string;
170
- };
171
- example: {
172
- keyword: 'example';
173
- args: string;
174
- };
175
- deprecated: {
176
- keyword: 'deprecated';
177
- };
178
- optional: {
179
- keyword: 'optional';
180
- };
181
- undefined: {
182
- keyword: 'undefined';
183
- };
184
- nullish: {
185
- keyword: 'nullish';
186
- };
187
- nullable: {
188
- keyword: 'nullable';
189
- };
190
- null: {
191
- keyword: 'null';
192
- };
193
- any: {
194
- keyword: 'any';
195
- };
196
- unknown: {
197
- keyword: 'unknown';
198
- };
199
- void: {
200
- keyword: 'void';
201
- };
202
- blob: {
203
- keyword: 'blob';
204
- };
205
- schema: {
206
- keyword: 'schema';
207
- args: {
208
- type: 'string' | 'number' | 'integer' | 'boolean' | 'array' | 'object';
209
- format?: string;
210
- };
211
- };
212
- name: {
213
- keyword: 'name';
214
- args: string;
215
- };
216
- catchall: {
217
- keyword: 'catchall';
218
- };
219
- interface: {
220
- keyword: 'interface';
221
- };
222
- };
223
- declare const schemaKeywords: {
224
- any: "any";
225
- unknown: "unknown";
226
- number: "number";
227
- integer: "integer";
228
- bigint: "bigint";
229
- string: "string";
230
- boolean: "boolean";
231
- undefined: "undefined";
232
- nullable: "nullable";
233
- null: "null";
234
- nullish: "nullish";
235
- array: "array";
236
- tuple: "tuple";
237
- enum: "enum";
238
- union: "union";
239
- datetime: "datetime";
240
- date: "date";
241
- email: "email";
242
- uuid: "uuid";
243
- url: "url";
244
- void: "void";
245
- default: "default";
246
- const: "const";
247
- and: "and";
248
- describe: "describe";
249
- min: "min";
250
- max: "max";
251
- exclusiveMinimum: "exclusiveMinimum";
252
- exclusiveMaximum: "exclusiveMaximum";
253
- optional: "optional";
254
- readOnly: "readOnly";
255
- writeOnly: "writeOnly";
256
- object: "object";
257
- ref: "ref";
258
- matches: "matches";
259
- firstName: "firstName";
260
- lastName: "lastName";
261
- password: "password";
262
- phone: "phone";
263
- blob: "blob";
264
- deprecated: "deprecated";
265
- example: "example";
266
- schema: "schema";
267
- catchall: "catchall";
268
- time: "time";
269
- name: "name";
270
- interface: "interface";
271
- };
272
- type SchemaKeyword = keyof SchemaKeywordMapper;
273
- type SchemaMapper<T = string | null | undefined> = { [K in keyof SchemaKeywordMapper]: (() => T | undefined) | undefined };
274
- type SchemaKeywordBase<T> = {
275
- keyword: SchemaKeyword;
276
- args: T;
277
- };
278
- type Schema = {
279
- keyword: string;
280
- } | SchemaKeywordMapper[keyof SchemaKeywordMapper];
281
- type SchemaTree = {
282
- schema: SchemaObject;
283
- parent: Schema | undefined;
284
- current: Schema;
285
- siblings: Schema[];
286
- /**
287
- * this is equal to the key of a property(object)
288
- */
289
- name?: string;
290
- };
291
- declare function isKeyword<T extends Schema, K extends keyof SchemaKeywordMapper>(meta: T, keyword: K): meta is Extract<T, SchemaKeywordMapper[K]>;
292
- //#endregion
293
- export { SchemaMapper as a, schemaKeywords as c, SchemaKeywordMapper as i, __name as l, SchemaKeyword as n, SchemaTree as o, SchemaKeywordBase as r, isKeyword as s, Schema as t };
294
- //# sourceMappingURL=SchemaMapper-nkCtMfTV.d.ts.map