@kubb/oas 4.18.3 → 4.18.5
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 +16 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +41 -39
- package/dist/index.d.ts +41 -39
- package/dist/index.js +16 -10
- package/dist/index.js.map +1 -1
- package/package.json +3 -4
- package/src/Oas.ts +9 -9
- package/src/utils.spec.ts +10 -10
- package/src/utils.ts +17 -2
package/dist/index.cjs
CHANGED
|
@@ -4370,13 +4370,19 @@ function isParameterObject(obj) {
|
|
|
4370
4370
|
return obj && "in" in obj;
|
|
4371
4371
|
}
|
|
4372
4372
|
/**
|
|
4373
|
-
* Determines if a schema is nullable, considering
|
|
4373
|
+
* Determines if a schema is nullable, considering:
|
|
4374
|
+
* - OpenAPI 3.0 `nullable` / `x-nullable`
|
|
4375
|
+
* - OpenAPI 3.1 JSON Schema `type: ['null', ...]` or `type: 'null'`
|
|
4374
4376
|
*
|
|
4375
4377
|
* @param schema - The schema object to check.
|
|
4376
4378
|
* @returns `true` if the schema is marked as nullable; otherwise, `false`.
|
|
4377
4379
|
*/
|
|
4378
4380
|
function isNullable(schema) {
|
|
4379
|
-
|
|
4381
|
+
if ((schema?.nullable ?? schema?.["x-nullable"]) === true) return true;
|
|
4382
|
+
const schemaType = schema?.type;
|
|
4383
|
+
if (schemaType === "null") return true;
|
|
4384
|
+
if (Array.isArray(schemaType)) return schemaType.includes("null");
|
|
4385
|
+
return false;
|
|
4380
4386
|
}
|
|
4381
4387
|
/**
|
|
4382
4388
|
* Determines if the given object is an OpenAPI ReferenceObject.
|
|
@@ -4664,17 +4670,17 @@ var Oas = class extends oas.default {
|
|
|
4664
4670
|
if (!(contentType in responseBody.content)) return false;
|
|
4665
4671
|
return responseBody.content[contentType];
|
|
4666
4672
|
}
|
|
4667
|
-
let
|
|
4673
|
+
let availableContentType;
|
|
4668
4674
|
const contentTypes = Object.keys(responseBody.content);
|
|
4669
4675
|
contentTypes.forEach((mt) => {
|
|
4670
|
-
if (!
|
|
4676
|
+
if (!availableContentType && oas_utils.matchesMimeType.json(mt)) availableContentType = mt;
|
|
4671
4677
|
});
|
|
4672
|
-
if (!
|
|
4673
|
-
if (!
|
|
4678
|
+
if (!availableContentType) contentTypes.forEach((mt) => {
|
|
4679
|
+
if (!availableContentType) availableContentType = mt;
|
|
4674
4680
|
});
|
|
4675
|
-
if (
|
|
4676
|
-
|
|
4677
|
-
responseBody.content[
|
|
4681
|
+
if (availableContentType) return [
|
|
4682
|
+
availableContentType,
|
|
4683
|
+
responseBody.content[availableContentType],
|
|
4678
4684
|
...responseBody.description ? [responseBody.description] : []
|
|
4679
4685
|
];
|
|
4680
4686
|
return false;
|
|
@@ -4746,7 +4752,7 @@ var Oas = class extends oas.default {
|
|
|
4746
4752
|
properties: {}
|
|
4747
4753
|
});
|
|
4748
4754
|
}
|
|
4749
|
-
async
|
|
4755
|
+
async validate() {
|
|
4750
4756
|
return new (await (import("oas-normalize").then((m) => m.default)))(this.api, {
|
|
4751
4757
|
enablePaths: true,
|
|
4752
4758
|
colorizeErrors: true
|