@kubb/oas 4.5.8 → 4.5.9
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-C674urwx.d.cts → index-BuoKUWab.d.cts} +1 -1
- package/dist/{index-BGlrm4xM.d.ts → index-CT3Sz4Y8.d.ts} +1 -1
- package/dist/index.cjs +44 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +44 -4
- package/dist/index.js.map +1 -1
- package/dist/infer.d.cts +1 -1
- package/dist/infer.d.ts +1 -1
- package/package.json +4 -4
- package/src/Oas.ts +97 -7
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as HttpMethods, d as OpenAPIV3_1, f as Operation, h as Infer, l as OasTypes, m as contentType, n as RequestParams, p as SchemaObject, r as Model, s as HttpMethod, t as Response, u as OpenAPIV3 } from "./index-
|
|
1
|
+
import { c as HttpMethods, d as OpenAPIV3_1, f as Operation, h as Infer, l as OasTypes, m as contentType, n as RequestParams, p as SchemaObject, r as Model, s as HttpMethod, t as Response, u as OpenAPIV3 } from "./index-BuoKUWab.cjs";
|
|
2
2
|
import { findSchemaDefinition, matchesMimeType } from "oas/utils";
|
|
3
3
|
import { OASDocument, ParameterObject, SchemaObject as SchemaObject$1, User } from "oas/types";
|
|
4
4
|
import { Operation as Operation$1 } from "oas/operation";
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as HttpMethods, d as OpenAPIV3_1, f as Operation, h as Infer, l as OasTypes, m as contentType, n as RequestParams, p as SchemaObject, r as Model, s as HttpMethod, t as Response, u as OpenAPIV3 } from "./index-
|
|
1
|
+
import { c as HttpMethods, d as OpenAPIV3_1, f as Operation, h as Infer, l as OasTypes, m as contentType, n as RequestParams, p as SchemaObject, r as Model, s as HttpMethod, t as Response, u as OpenAPIV3 } from "./index-CT3Sz4Y8.js";
|
|
2
2
|
import { findSchemaDefinition, matchesMimeType } from "oas/utils";
|
|
3
3
|
import BaseOas from "oas";
|
|
4
4
|
import { OASDocument, ParameterObject, SchemaObject as SchemaObject$1, User } from "oas/types";
|
package/dist/index.js
CHANGED
|
@@ -4407,7 +4407,11 @@ var Oas = class extends BaseOas {
|
|
|
4407
4407
|
this.document = oas;
|
|
4408
4408
|
}
|
|
4409
4409
|
setOptions(options) {
|
|
4410
|
-
this.#options =
|
|
4410
|
+
this.#options = {
|
|
4411
|
+
...this.#options,
|
|
4412
|
+
...options
|
|
4413
|
+
};
|
|
4414
|
+
if (this.#options.discriminator === "inherit") this.#applyDiscriminatorInheritance();
|
|
4411
4415
|
}
|
|
4412
4416
|
get options() {
|
|
4413
4417
|
return this.#options;
|
|
@@ -4434,8 +4438,7 @@ var Oas = class extends BaseOas {
|
|
|
4434
4438
|
jsonpointer.set(this.api, $ref, value);
|
|
4435
4439
|
}
|
|
4436
4440
|
}
|
|
4437
|
-
|
|
4438
|
-
if (!isDiscriminator(schema$2)) return;
|
|
4441
|
+
#setDiscriminator(schema$2) {
|
|
4439
4442
|
const { mapping = {}, propertyName } = schema$2.discriminator;
|
|
4440
4443
|
if (this.#options.discriminator === "inherit") Object.entries(mapping).forEach(([mappingKey, mappingValue]) => {
|
|
4441
4444
|
if (mappingValue) {
|
|
@@ -4447,11 +4450,15 @@ var Oas = class extends BaseOas {
|
|
|
4447
4450
|
...childSchema.properties ? childSchema.properties[propertyName] : {},
|
|
4448
4451
|
enum: [...property?.enum?.filter((value) => value !== mappingKey) ?? [], mappingKey]
|
|
4449
4452
|
};
|
|
4450
|
-
childSchema.required = [...childSchema.required ?? [], propertyName];
|
|
4453
|
+
childSchema.required = [...new Set([...childSchema.required ?? [], propertyName])];
|
|
4451
4454
|
this.set(mappingValue, childSchema);
|
|
4452
4455
|
}
|
|
4453
4456
|
}
|
|
4454
4457
|
});
|
|
4458
|
+
}
|
|
4459
|
+
getDiscriminator(schema$2) {
|
|
4460
|
+
if (!isDiscriminator(schema$2)) return;
|
|
4461
|
+
const { mapping = {}, propertyName } = schema$2.discriminator;
|
|
4455
4462
|
if (schema$2.oneOf) schema$2.oneOf.forEach((schema$3) => {
|
|
4456
4463
|
if (isReference(schema$3)) {
|
|
4457
4464
|
const key = this.getKey(schema$3.$ref);
|
|
@@ -4483,6 +4490,39 @@ var Oas = class extends BaseOas {
|
|
|
4483
4490
|
};
|
|
4484
4491
|
return schema$2;
|
|
4485
4492
|
}
|
|
4493
|
+
#applyDiscriminatorInheritance() {
|
|
4494
|
+
const components = this.api.components;
|
|
4495
|
+
if (!components?.schemas) return;
|
|
4496
|
+
const visited = /* @__PURE__ */ new WeakSet();
|
|
4497
|
+
const enqueue = (value) => {
|
|
4498
|
+
if (!value) return;
|
|
4499
|
+
if (Array.isArray(value)) {
|
|
4500
|
+
for (const item of value) enqueue(item);
|
|
4501
|
+
return;
|
|
4502
|
+
}
|
|
4503
|
+
if (typeof value === "object") visit(value);
|
|
4504
|
+
};
|
|
4505
|
+
const visit = (schema$2) => {
|
|
4506
|
+
if (!schema$2 || typeof schema$2 !== "object") return;
|
|
4507
|
+
if (isReference(schema$2)) {
|
|
4508
|
+
visit(this.get(schema$2.$ref));
|
|
4509
|
+
return;
|
|
4510
|
+
}
|
|
4511
|
+
const schemaObject = schema$2;
|
|
4512
|
+
if (visited.has(schemaObject)) return;
|
|
4513
|
+
visited.add(schemaObject);
|
|
4514
|
+
if (isDiscriminator(schemaObject)) this.#setDiscriminator(schemaObject);
|
|
4515
|
+
if ("allOf" in schemaObject) enqueue(schemaObject.allOf);
|
|
4516
|
+
if ("oneOf" in schemaObject) enqueue(schemaObject.oneOf);
|
|
4517
|
+
if ("anyOf" in schemaObject) enqueue(schemaObject.anyOf);
|
|
4518
|
+
if ("not" in schemaObject) enqueue(schemaObject.not);
|
|
4519
|
+
if ("items" in schemaObject) enqueue(schemaObject.items);
|
|
4520
|
+
if ("prefixItems" in schemaObject) enqueue(schemaObject.prefixItems);
|
|
4521
|
+
if (schemaObject.properties) enqueue(Object.values(schemaObject.properties));
|
|
4522
|
+
if (schemaObject.additionalProperties && typeof schemaObject.additionalProperties === "object") enqueue(schemaObject.additionalProperties);
|
|
4523
|
+
};
|
|
4524
|
+
for (const schema$2 of Object.values(components.schemas)) visit(schema$2);
|
|
4525
|
+
}
|
|
4486
4526
|
/**
|
|
4487
4527
|
* Oas does not have a getResponseBody(contentType)
|
|
4488
4528
|
*/
|