@kubb/adapter-oas 5.14.5 → 5.15.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.
- package/dist/index.cjs +61 -66
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +0 -10
- package/dist/index.d.ts +0 -10
- package/dist/index.js +61 -66
- package/dist/index.js.map +1 -1
- package/dist/validateWorker.js +1 -2
- package/package.json +4 -4
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { AdapterFactoryOptions, ast } from "@kubb/kit";
|
|
2
|
-
//#region ../../node_modules/.pnpm/@types+json-schema@7.0.15/node_modules/@types/json-schema/index.d.ts
|
|
3
2
|
// ==================================================================================================
|
|
4
3
|
// JSON Schema Draft 04
|
|
5
4
|
// ==================================================================================================
|
|
@@ -596,8 +595,6 @@ interface JSONSchema7 {
|
|
|
596
595
|
writeOnly?: boolean | undefined;
|
|
597
596
|
examples?: JSONSchema7Type | undefined;
|
|
598
597
|
}
|
|
599
|
-
//#endregion
|
|
600
|
-
//#region ../../node_modules/.pnpm/openapi-types@12.1.3/node_modules/openapi-types/dist/index.d.ts
|
|
601
598
|
declare namespace OpenAPIV3_1 {
|
|
602
599
|
type Modify<T, R> = Omit<T, keyof R> & R;
|
|
603
600
|
type PathsWebhooksComponents<T extends {} = {}> = {
|
|
@@ -1053,8 +1050,6 @@ declare namespace OpenAPIV3 {
|
|
|
1053
1050
|
externalDocs?: ExternalDocumentationObject;
|
|
1054
1051
|
}
|
|
1055
1052
|
}
|
|
1056
|
-
//#endregion
|
|
1057
|
-
//#region src/types.d.ts
|
|
1058
1053
|
/**
|
|
1059
1054
|
* Media type used to pick a schema from an operation's request or response.
|
|
1060
1055
|
*
|
|
@@ -1254,8 +1249,6 @@ type AdapterOasResolvedOptions = {
|
|
|
1254
1249
|
* `@kubb/core` adapter factory type for the OpenAPI adapter.
|
|
1255
1250
|
*/
|
|
1256
1251
|
type AdapterOas = AdapterFactoryOptions<'oas', AdapterOasOptions, AdapterOasResolvedOptions, Document>;
|
|
1257
|
-
//#endregion
|
|
1258
|
-
//#region src/adapter.d.ts
|
|
1259
1252
|
/**
|
|
1260
1253
|
* The `name` of `@kubb/adapter-oas`, used to identify this adapter in a Kubb config.
|
|
1261
1254
|
*/
|
|
@@ -1288,8 +1281,6 @@ export declare const adapterOasName = "oas";
|
|
|
1288
1281
|
* ```
|
|
1289
1282
|
*/
|
|
1290
1283
|
export declare const adapterOas: import("@kubb/core").AdapterFactory<AdapterOas>;
|
|
1291
|
-
//#endregion
|
|
1292
|
-
//#region src/operation.d.ts
|
|
1293
1284
|
/**
|
|
1294
1285
|
* A single OpenAPI operation: its path, method, raw operation object and resolved path item.
|
|
1295
1286
|
*/
|
|
@@ -1299,6 +1290,5 @@ type Operation = {
|
|
|
1299
1290
|
schema: OperationObject$1;
|
|
1300
1291
|
pathItem: PathItemObject$1;
|
|
1301
1292
|
};
|
|
1302
|
-
//#endregion
|
|
1303
1293
|
export type { AdapterOas, AdapterOasOptions, AdapterOasResolvedOptions, ContentType, DiscriminatorObject$1 as DiscriminatorObject, Document, MediaTypeObject$1 as MediaTypeObject, Operation, ReferenceObject$1 as ReferenceObject, ResponseObject$1 as ResponseObject, SchemaObject$1 as SchemaObject };
|
|
1304
1294
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { AdapterFactoryOptions, ast } from "@kubb/kit";
|
|
2
|
-
//#region ../../node_modules/.pnpm/@types+json-schema@7.0.15/node_modules/@types/json-schema/index.d.ts
|
|
3
2
|
// ==================================================================================================
|
|
4
3
|
// JSON Schema Draft 04
|
|
5
4
|
// ==================================================================================================
|
|
@@ -596,8 +595,6 @@ interface JSONSchema7 {
|
|
|
596
595
|
writeOnly?: boolean | undefined;
|
|
597
596
|
examples?: JSONSchema7Type | undefined;
|
|
598
597
|
}
|
|
599
|
-
//#endregion
|
|
600
|
-
//#region ../../node_modules/.pnpm/openapi-types@12.1.3/node_modules/openapi-types/dist/index.d.ts
|
|
601
598
|
declare namespace OpenAPIV3_1 {
|
|
602
599
|
type Modify<T, R> = Omit<T, keyof R> & R;
|
|
603
600
|
type PathsWebhooksComponents<T extends {} = {}> = {
|
|
@@ -1053,8 +1050,6 @@ declare namespace OpenAPIV3 {
|
|
|
1053
1050
|
externalDocs?: ExternalDocumentationObject;
|
|
1054
1051
|
}
|
|
1055
1052
|
}
|
|
1056
|
-
//#endregion
|
|
1057
|
-
//#region src/types.d.ts
|
|
1058
1053
|
/**
|
|
1059
1054
|
* Media type used to pick a schema from an operation's request or response.
|
|
1060
1055
|
*
|
|
@@ -1254,8 +1249,6 @@ type AdapterOasResolvedOptions = {
|
|
|
1254
1249
|
* `@kubb/core` adapter factory type for the OpenAPI adapter.
|
|
1255
1250
|
*/
|
|
1256
1251
|
type AdapterOas = AdapterFactoryOptions<'oas', AdapterOasOptions, AdapterOasResolvedOptions, Document>;
|
|
1257
|
-
//#endregion
|
|
1258
|
-
//#region src/adapter.d.ts
|
|
1259
1252
|
/**
|
|
1260
1253
|
* The `name` of `@kubb/adapter-oas`, used to identify this adapter in a Kubb config.
|
|
1261
1254
|
*/
|
|
@@ -1288,8 +1281,6 @@ export declare const adapterOasName = "oas";
|
|
|
1288
1281
|
* ```
|
|
1289
1282
|
*/
|
|
1290
1283
|
export declare const adapterOas: import("@kubb/core").AdapterFactory<AdapterOas>;
|
|
1291
|
-
//#endregion
|
|
1292
|
-
//#region src/operation.d.ts
|
|
1293
1284
|
/**
|
|
1294
1285
|
* A single OpenAPI operation: its path, method, raw operation object and resolved path item.
|
|
1295
1286
|
*/
|
|
@@ -1299,6 +1290,5 @@ type Operation = {
|
|
|
1299
1290
|
schema: OperationObject$1;
|
|
1300
1291
|
pathItem: PathItemObject$1;
|
|
1301
1292
|
};
|
|
1302
|
-
//#endregion
|
|
1303
1293
|
export type { AdapterOas, AdapterOasOptions, AdapterOasResolvedOptions, ContentType, DiscriminatorObject$1 as DiscriminatorObject, Document, MediaTypeObject$1 as MediaTypeObject, Operation, ReferenceObject$1 as ReferenceObject, ResponseObject$1 as ResponseObject, SchemaObject$1 as SchemaObject };
|
|
1304
1294
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -7,23 +7,20 @@ import { bundle } from "api-ref-bundler";
|
|
|
7
7
|
import { CORE_SCHEMA, load } from "js-yaml";
|
|
8
8
|
import * as yaml from "yaml";
|
|
9
9
|
import { parse } from "yaml";
|
|
10
|
-
|
|
10
|
+
// \0rolldown/runtime.js
|
|
11
11
|
var __defProp = Object.defineProperty;
|
|
12
12
|
var __name = (target, value) => __defProp(target, "name", {
|
|
13
13
|
value,
|
|
14
14
|
configurable: true
|
|
15
15
|
});
|
|
16
|
-
|
|
17
|
-
//#region kubb-extension.json
|
|
16
|
+
// kubb-extension.json
|
|
18
17
|
var compatibility = {
|
|
19
18
|
"kubb": ">=5.8.3",
|
|
20
19
|
"node": ">=22.22"
|
|
21
20
|
};
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
//#endregion
|
|
26
|
-
//#region src/constants.ts
|
|
21
|
+
// package.json
|
|
22
|
+
var version = "5.15.0";
|
|
23
|
+
// src/constants.ts
|
|
27
24
|
/**
|
|
28
25
|
* Default parser options applied when no explicit options are provided.
|
|
29
26
|
*/
|
|
@@ -147,8 +144,7 @@ const enumExtensionKeys = ["x-enumNames", "x-enum-varnames"];
|
|
|
147
144
|
* Vendor extension keys that attach human-readable descriptions to enum values, checked in priority order.
|
|
148
145
|
*/
|
|
149
146
|
const enumDescriptionKeys = ["x-enumDescriptions", "x-enum-descriptions"];
|
|
150
|
-
|
|
151
|
-
//#region src/emit/discriminator/propagate.ts
|
|
147
|
+
// src/emit/discriminator/propagate.ts
|
|
152
148
|
/**
|
|
153
149
|
* Maps each child schema name to its discriminator patch data by scanning the given
|
|
154
150
|
* top-level AST schema nodes for union schemas that carry a `discriminatorPropertyName`.
|
|
@@ -231,8 +227,7 @@ function patchDiscriminatorNode(node, entry) {
|
|
|
231
227
|
members: newMembers
|
|
232
228
|
};
|
|
233
229
|
}
|
|
234
|
-
|
|
235
|
-
//#region ../../internals/utils/src/casing.ts
|
|
230
|
+
// ../../internals/utils/src/casing.ts
|
|
236
231
|
/**
|
|
237
232
|
* Shared implementation for camelCase and PascalCase conversion.
|
|
238
233
|
* Splits on common word boundaries (spaces, hyphens, underscores, dots, slashes, colons)
|
|
@@ -247,7 +242,7 @@ function convert(text, pascal) {
|
|
|
247
242
|
}).join("").replace(/[^a-zA-Z0-9]/g, "");
|
|
248
243
|
}
|
|
249
244
|
const cache = /* @__PURE__ */ new Map();
|
|
250
|
-
const cacheLimit =
|
|
245
|
+
const cacheLimit = 1e5;
|
|
251
246
|
function toCamelOrPascal(text, pascal) {
|
|
252
247
|
const key = `${pascal ? "P" : "c"}${text}`;
|
|
253
248
|
const cached = cache.get(key);
|
|
@@ -269,8 +264,7 @@ function toCamelOrPascal(text, pascal) {
|
|
|
269
264
|
function pascalCase(text, { prefix = "", suffix = "" } = {}) {
|
|
270
265
|
return toCamelOrPascal(`${prefix} ${text} ${suffix}`, true);
|
|
271
266
|
}
|
|
272
|
-
|
|
273
|
-
//#region ../../internals/utils/src/errors.ts
|
|
267
|
+
// ../../internals/utils/src/errors.ts
|
|
274
268
|
/**
|
|
275
269
|
* Coerces an unknown thrown value to an `Error` instance.
|
|
276
270
|
* Returns the value as-is when it is already an `Error`; otherwise wraps it with `String(value)`.
|
|
@@ -297,8 +291,7 @@ function toError(value) {
|
|
|
297
291
|
function getErrorMessage(value) {
|
|
298
292
|
return value instanceof Error ? value.message : String(value);
|
|
299
293
|
}
|
|
300
|
-
|
|
301
|
-
//#region ../../internals/utils/src/jsonPointer.ts
|
|
294
|
+
// ../../internals/utils/src/jsonPointer.ts
|
|
302
295
|
/**
|
|
303
296
|
* Escapes a single JSON pointer reference token per RFC 6901 (`~` → `~0`, `/` → `~1`), so a
|
|
304
297
|
* name holding those characters maps to a distinct pointer.
|
|
@@ -311,8 +304,7 @@ function getErrorMessage(value) {
|
|
|
311
304
|
function escapePointerToken(token) {
|
|
312
305
|
return token.replaceAll("~", "~0").replaceAll("/", "~1");
|
|
313
306
|
}
|
|
314
|
-
|
|
315
|
-
//#region ../../internals/utils/src/runtime.ts
|
|
307
|
+
// ../../internals/utils/src/runtime.ts
|
|
316
308
|
const isBun = typeof Bun !== "undefined";
|
|
317
309
|
const isDeno = "Deno" in globalThis;
|
|
318
310
|
/**
|
|
@@ -341,8 +333,7 @@ function detect() {
|
|
|
341
333
|
version: process.versions?.node ?? ""
|
|
342
334
|
};
|
|
343
335
|
}
|
|
344
|
-
|
|
345
|
-
//#region ../../internals/utils/src/fs.ts
|
|
336
|
+
// ../../internals/utils/src/fs.ts
|
|
346
337
|
/**
|
|
347
338
|
* Resolves to `true` when the file or directory at `path` exists.
|
|
348
339
|
* Uses `Bun.file().exists()` when running under Bun, `fs.access` otherwise.
|
|
@@ -371,8 +362,7 @@ async function read(path) {
|
|
|
371
362
|
if (runtime.isBun) return Bun.file(path).text();
|
|
372
363
|
return readFile(path, { encoding: "utf8" });
|
|
373
364
|
}
|
|
374
|
-
|
|
375
|
-
//#region src/oas.ts
|
|
365
|
+
// src/oas.ts
|
|
376
366
|
/**
|
|
377
367
|
* Returns `true` when a schema should be treated as nullable.
|
|
378
368
|
*
|
|
@@ -455,8 +445,7 @@ const jsonMimeFragments = [
|
|
|
455
445
|
function isJsonMimeType(mimeType) {
|
|
456
446
|
return jsonMimeFragments.some((fragment) => mimeType.includes(fragment));
|
|
457
447
|
}
|
|
458
|
-
|
|
459
|
-
//#region src/refs.ts
|
|
448
|
+
// src/refs.ts
|
|
460
449
|
/**
|
|
461
450
|
* Creates the `$ref` resolution service for one document. One pointer walk backs every method.
|
|
462
451
|
*
|
|
@@ -563,8 +552,7 @@ function createRefs(document) {
|
|
|
563
552
|
derefKeepingRef
|
|
564
553
|
};
|
|
565
554
|
}
|
|
566
|
-
|
|
567
|
-
//#region src/load/source.ts
|
|
555
|
+
// src/load/source.ts
|
|
568
556
|
const urlRegExp = /^https?:\/+/i;
|
|
569
557
|
/**
|
|
570
558
|
* Node reports every connection failure as `TypeError: fetch failed` and keeps the useful part
|
|
@@ -668,8 +656,7 @@ async function assertInputExists(input) {
|
|
|
668
656
|
location: { kind: "config" }
|
|
669
657
|
});
|
|
670
658
|
}
|
|
671
|
-
|
|
672
|
-
//#region src/load/normalize.ts
|
|
659
|
+
// src/load/normalize.ts
|
|
673
660
|
/**
|
|
674
661
|
* True when `node` contains a `$ref` pointing outside the current document (a relative path,
|
|
675
662
|
* absolute path, or URL). An internal `#/...` fragment does not count.
|
|
@@ -699,6 +686,30 @@ function inlinePathRefs(node, resolve, visiting = []) {
|
|
|
699
686
|
for (const [key, value] of Object.entries(node)) node[key] = inlinePathRefs(value, resolve, visiting);
|
|
700
687
|
return node;
|
|
701
688
|
}
|
|
689
|
+
const namedEntryKeys = /* @__PURE__ */ new Set([
|
|
690
|
+
"properties",
|
|
691
|
+
"patternProperties",
|
|
692
|
+
"headers",
|
|
693
|
+
"schemas",
|
|
694
|
+
"responses",
|
|
695
|
+
"parameters",
|
|
696
|
+
"requestBodies",
|
|
697
|
+
"examples",
|
|
698
|
+
"links",
|
|
699
|
+
"callbacks",
|
|
700
|
+
"securitySchemes",
|
|
701
|
+
"securityDefinitions",
|
|
702
|
+
"pathItems",
|
|
703
|
+
"definitions",
|
|
704
|
+
"$defs"
|
|
705
|
+
]);
|
|
706
|
+
/**
|
|
707
|
+
* True when `path` runs through an `x-` vendor extension. Kubb never reads an extension, so a `$ref`
|
|
708
|
+
* Kubb cannot read inside one cannot change the output.
|
|
709
|
+
*/
|
|
710
|
+
function isExtensionPath(path) {
|
|
711
|
+
return path.some((token, index) => String(token).startsWith("x-") && !namedEntryKeys.has(String(path[index - 1])));
|
|
712
|
+
}
|
|
702
713
|
/**
|
|
703
714
|
* Bundles a multi-file OpenAPI document into a single document via `api-ref-bundler`.
|
|
704
715
|
*
|
|
@@ -714,7 +725,7 @@ function inlinePathRefs(node, resolve, visiting = []) {
|
|
|
714
725
|
*
|
|
715
726
|
* `document` stands in for the file at `pathOrUrl`, such as inline input. Every other file or URL
|
|
716
727
|
* read, including one that fails, lands in `sources`. A `$ref` that cannot be read reports
|
|
717
|
-
* `KUBB_REF_NOT_FOUND` at the key that holds it.
|
|
728
|
+
* `KUBB_REF_NOT_FOUND` at the key that holds it, as a warning when it sits inside an `x-` extension.
|
|
718
729
|
*
|
|
719
730
|
* @example Local file
|
|
720
731
|
* `const document = await bundleDocument('./openapi.yaml')`
|
|
@@ -741,7 +752,7 @@ async function bundleDocument(pathOrUrl, { document, sources = [] } = {}) {
|
|
|
741
752
|
const pointer = toKey(state.baseFile) === toKey(pathOrUrl) ? `#/${path.map((token) => escapePointerToken(String(token))).join("/")}` : void 0;
|
|
742
753
|
const diagnostic = {
|
|
743
754
|
code: Diagnostics.code.refNotFound,
|
|
744
|
-
severity: "error",
|
|
755
|
+
severity: isExtensionPath(path) ? "warning" : "error",
|
|
745
756
|
message: `Could not bundle an external \`$ref\`. ${message}.`,
|
|
746
757
|
help: "Check that the file or URL the `$ref` points at exists and is readable, or fix the `$ref`.",
|
|
747
758
|
...pointer && { location: {
|
|
@@ -749,7 +760,7 @@ async function bundleDocument(pathOrUrl, { document, sources = [] } = {}) {
|
|
|
749
760
|
pointer
|
|
750
761
|
} }
|
|
751
762
|
};
|
|
752
|
-
if (!Diagnostics.report(diagnostic)) throw new Diagnostics.Error(diagnostic);
|
|
763
|
+
if (!Diagnostics.report(diagnostic) && diagnostic.severity === "error") throw new Diagnostics.Error(diagnostic);
|
|
753
764
|
} } });
|
|
754
765
|
}
|
|
755
766
|
const inlineInputName = "<inline input>";
|
|
@@ -891,8 +902,7 @@ async function validateDocumentInWorker(document) {
|
|
|
891
902
|
if ("thrown" in message) return reportInvalidSpec(message.thrown);
|
|
892
903
|
if (!message.valid) reportValidationErrors(message);
|
|
893
904
|
}
|
|
894
|
-
|
|
895
|
-
//#region src/model/components.ts
|
|
905
|
+
// src/model/components.ts
|
|
896
906
|
/**
|
|
897
907
|
* Extracts the inline schema from a media-type `content` map, with the media type it sits under.
|
|
898
908
|
*
|
|
@@ -1094,8 +1104,7 @@ function getSchemas(document, { contentType }, refs) {
|
|
|
1094
1104
|
pointers
|
|
1095
1105
|
};
|
|
1096
1106
|
}
|
|
1097
|
-
|
|
1098
|
-
//#region src/model/server.ts
|
|
1107
|
+
// src/model/server.ts
|
|
1099
1108
|
/**
|
|
1100
1109
|
* Reads the server URL from the document's `servers` array at `server.index`,
|
|
1101
1110
|
* interpolating any `server.variables` into the URL template.
|
|
@@ -1147,8 +1156,7 @@ function resolveServerUrl(server, overrides) {
|
|
|
1147
1156
|
}
|
|
1148
1157
|
return url;
|
|
1149
1158
|
}
|
|
1150
|
-
|
|
1151
|
-
//#region src/emit/schemaShape.ts
|
|
1159
|
+
// src/emit/schemaShape.ts
|
|
1152
1160
|
/**
|
|
1153
1161
|
* Whether `format` maps to a dedicated type; `false` is what `KUBB_UNSUPPORTED_FORMAT` flags.
|
|
1154
1162
|
*/
|
|
@@ -1201,8 +1209,7 @@ function flattenSchema(schema) {
|
|
|
1201
1209
|
for (const fragment of allOfFragments) for (const [key, value] of Object.entries(fragment)) merged[key] ??= value;
|
|
1202
1210
|
return merged;
|
|
1203
1211
|
}
|
|
1204
|
-
|
|
1205
|
-
//#region src/schemaDiagnostics.ts
|
|
1212
|
+
// src/schemaDiagnostics.ts
|
|
1206
1213
|
/**
|
|
1207
1214
|
* Links one freshly converted schema and its nested schemas to their RFC 6901 pointers
|
|
1208
1215
|
* (`#/components/schemas/Pet/properties/owner/properties/name`), and reports the advisory
|
|
@@ -1256,8 +1263,7 @@ function visit(node, pointer) {
|
|
|
1256
1263
|
for (const [index, member] of (node.members ?? []).entries()) visit(member, `${pointer}/${keyword}/${index}`);
|
|
1257
1264
|
}
|
|
1258
1265
|
}
|
|
1259
|
-
|
|
1260
|
-
//#region src/operation.ts
|
|
1266
|
+
// src/operation.ts
|
|
1261
1267
|
function slugify(value) {
|
|
1262
1268
|
return value.replace(/[^a-zA-Z0-9]/g, "-").replace(/-{2,}/g, "-").replace(/^-|-$/g, "");
|
|
1263
1269
|
}
|
|
@@ -1526,8 +1532,7 @@ function parseOperation({ operation, ...ctx }) {
|
|
|
1526
1532
|
extensions: pickExtensions(operation.schema)
|
|
1527
1533
|
});
|
|
1528
1534
|
}
|
|
1529
|
-
|
|
1530
|
-
//#region src/emit/createNode.ts
|
|
1535
|
+
// src/emit/createNode.ts
|
|
1531
1536
|
/**
|
|
1532
1537
|
* Builds a schema node from a converter's base context plus its type-specific fields. Every
|
|
1533
1538
|
* converter needs the same metadata fields (`title`, `description`, `examples`, ...) alongside
|
|
@@ -1548,8 +1553,7 @@ function createNode({ schema, name, nullable, defaultValue }, extras) {
|
|
|
1548
1553
|
...extras
|
|
1549
1554
|
});
|
|
1550
1555
|
}
|
|
1551
|
-
|
|
1552
|
-
//#region src/emit/discriminator/preserve.ts
|
|
1556
|
+
// src/emit/discriminator/preserve.ts
|
|
1553
1557
|
/**
|
|
1554
1558
|
* Turns string mapping keys into the discriminator property's type when they parse cleanly.
|
|
1555
1559
|
*/
|
|
@@ -1785,8 +1789,7 @@ function extractDiscriminatedAllOfMembers({ allOfMembers, name, refs }) {
|
|
|
1785
1789
|
discriminantValues
|
|
1786
1790
|
};
|
|
1787
1791
|
}
|
|
1788
|
-
|
|
1789
|
-
//#region src/emit/converters/annotatedEnum.ts
|
|
1792
|
+
// src/emit/converters/annotatedEnum.ts
|
|
1790
1793
|
const ANNOTATIONS = /* @__PURE__ */ new Set([
|
|
1791
1794
|
"title",
|
|
1792
1795
|
"description",
|
|
@@ -1852,8 +1855,7 @@ function convertAnnotatedEnum(context) {
|
|
|
1852
1855
|
namedEnumValues
|
|
1853
1856
|
});
|
|
1854
1857
|
}
|
|
1855
|
-
|
|
1856
|
-
//#region src/emit/converters/composition.ts
|
|
1858
|
+
// src/emit/converters/composition.ts
|
|
1857
1859
|
/**
|
|
1858
1860
|
* Collects property schemas from all `allOf` members and outer schema properties,
|
|
1859
1861
|
* recursively resolving `$ref` pointers.
|
|
@@ -2189,8 +2191,7 @@ function convertMultiType({ schema, name, nullable, defaultValue, parse }) {
|
|
|
2189
2191
|
})
|
|
2190
2192
|
});
|
|
2191
2193
|
}
|
|
2192
|
-
|
|
2193
|
-
//#region src/emit/converters/scalar.ts
|
|
2194
|
+
// src/emit/converters/scalar.ts
|
|
2194
2195
|
/**
|
|
2195
2196
|
* Normalizes malformed `{ type: 'array', enum: [...] }` schemas by moving enum values into items.
|
|
2196
2197
|
*
|
|
@@ -2366,8 +2367,7 @@ function convertNumeric(context, type) {
|
|
|
2366
2367
|
...getNumericConstraints(context.schema)
|
|
2367
2368
|
});
|
|
2368
2369
|
}
|
|
2369
|
-
|
|
2370
|
-
//#region src/emit/converters/structural.ts
|
|
2370
|
+
// src/emit/converters/structural.ts
|
|
2371
2371
|
/**
|
|
2372
2372
|
* Resolves a `true` or empty-object map schema (`additionalProperties`/`patternProperties`) to
|
|
2373
2373
|
* `options.unknownType`, otherwise parses it as a regular schema.
|
|
@@ -2398,8 +2398,9 @@ function nameEnums(node, options) {
|
|
|
2398
2398
|
* Converts an object-like schema into an `ObjectSchemaNode`.
|
|
2399
2399
|
*/
|
|
2400
2400
|
function convertObject({ schema, name, nullable, defaultValue, options, parse, refs }) {
|
|
2401
|
+
const requiredNames = Array.isArray(schema.required) ? new Set(schema.required) : void 0;
|
|
2401
2402
|
const properties = schema.properties ? Object.entries(schema.properties).map(([propName, propSchema]) => {
|
|
2402
|
-
const required =
|
|
2403
|
+
const required = requiredNames ? requiredNames.has(propName) : !!schema.required;
|
|
2403
2404
|
const resolvedPropSchema = propSchema;
|
|
2404
2405
|
const propNullable = isNullable(resolvedPropSchema);
|
|
2405
2406
|
const schemaNode = nameEnums(parse({
|
|
@@ -2518,8 +2519,7 @@ function convertArray({ schema, name, nullable, defaultValue, options, parse })
|
|
|
2518
2519
|
unique: schema.uniqueItems ?? void 0
|
|
2519
2520
|
});
|
|
2520
2521
|
}
|
|
2521
|
-
|
|
2522
|
-
//#region src/emit/parseSchema.ts
|
|
2522
|
+
// src/emit/parseSchema.ts
|
|
2523
2523
|
/**
|
|
2524
2524
|
* Ordered schema rule table. Order is significant: composition keywords (`not`, `$ref`, `allOf`,
|
|
2525
2525
|
* `oneOf`/`anyOf`) take precedence over `const` (except a `$ref` with a sibling `const`, where the
|
|
@@ -2620,8 +2620,7 @@ const schemaRules = [
|
|
|
2620
2620
|
convert: ({ schema, name, nullable }) => createNullNode(schema, name, nullable)
|
|
2621
2621
|
}
|
|
2622
2622
|
];
|
|
2623
|
-
|
|
2624
|
-
//#region src/parser.ts
|
|
2623
|
+
// src/parser.ts
|
|
2625
2624
|
/**
|
|
2626
2625
|
* Creates the schema converter bound to one OpenAPI document: `parseSchema` dispatches each
|
|
2627
2626
|
* schema through the ordered `schemaRules` table, with the parser options merged once.
|
|
@@ -2658,8 +2657,7 @@ function createSchemaParser(ctx) {
|
|
|
2658
2657
|
}
|
|
2659
2658
|
return parseSchema;
|
|
2660
2659
|
}
|
|
2661
|
-
|
|
2662
|
-
//#region src/promoteEnums.ts
|
|
2660
|
+
// src/promoteEnums.ts
|
|
2663
2661
|
/**
|
|
2664
2662
|
* Collects inline enums to lift to the top level, keyed by the name the parser derived for them
|
|
2665
2663
|
* (e.g. `PetStatusEnum`). An enum already defined as a top-level component is left as-is, and a
|
|
@@ -2705,8 +2703,7 @@ function refPromotedEnums(node, promoted) {
|
|
|
2705
2703
|
});
|
|
2706
2704
|
} });
|
|
2707
2705
|
}
|
|
2708
|
-
|
|
2709
|
-
//#region src/sourceLocator.ts
|
|
2706
|
+
// src/sourceLocator.ts
|
|
2710
2707
|
let cached;
|
|
2711
2708
|
const toRange = ([start, end]) => ({
|
|
2712
2709
|
start,
|
|
@@ -2864,8 +2861,7 @@ const locate = (source, location) => {
|
|
|
2864
2861
|
const { document } = cached;
|
|
2865
2862
|
return findPointer(document, location.pointer) ?? (ref ? findRefUsage(document, ref) : void 0);
|
|
2866
2863
|
};
|
|
2867
|
-
|
|
2868
|
-
//#region src/adapter.ts
|
|
2864
|
+
// src/adapter.ts
|
|
2869
2865
|
/**
|
|
2870
2866
|
* The `name` of `@kubb/adapter-oas`, used to identify this adapter in a Kubb config.
|
|
2871
2867
|
*/
|
|
@@ -3110,7 +3106,6 @@ const adapterOas = defineExtension({
|
|
|
3110
3106
|
};
|
|
3111
3107
|
}
|
|
3112
3108
|
});
|
|
3113
|
-
//#endregion
|
|
3114
3109
|
export { adapterOas, adapterOasName };
|
|
3115
3110
|
|
|
3116
3111
|
//# sourceMappingURL=index.js.map
|