@samchon/openapi
Advanced tools
Comparing version 1.1.1 to 1.1.2-dev.20241024
@@ -291,3 +291,3 @@ "use strict"; | ||
if (OpenApiTypeChecker_1.OpenApiTypeChecker.isReference(u)) | ||
downgradeNullableReference(collection)(u); | ||
downgradeNullableReference(new Set())(collection)(u); | ||
else | ||
@@ -312,17 +312,26 @@ u.nullable = true; | ||
}; | ||
var downgradeNullableReference = function (collection) { | ||
return function (schema) { | ||
var _a; | ||
var key = schema.$ref.split("/").pop(); | ||
if (key.endsWith(".Nullable")) | ||
return; | ||
var found = (_a = collection.original.schemas) === null || _a === void 0 ? void 0 : _a[key]; | ||
if (found === undefined) | ||
return; | ||
else if (collection.downgraded.schemas["".concat(key, ".Nullable")] === undefined) { | ||
collection.downgraded.schemas["".concat(key, ".Nullable")] = {}; | ||
collection.downgraded.schemas["".concat(key, ".Nullable")] = | ||
OpenApiV3Downgrader.downgradeSchema(collection)(found); | ||
} | ||
schema.$ref += ".Nullable"; | ||
var downgradeNullableReference = function (visited) { | ||
return function (collection) { | ||
return function (schema) { | ||
var _a, _b, _c; | ||
var _d; | ||
var key = schema.$ref.split("/").pop(); | ||
if (key.endsWith(".Nullable")) | ||
return; | ||
var found = (_a = collection.original.schemas) === null || _a === void 0 ? void 0 : _a[key]; | ||
if (found === undefined) | ||
return; | ||
else if (isNullable(visited)(collection.original)(found) === true) | ||
return; | ||
else if (((_b = collection.downgraded.schemas) === null || _b === void 0 ? void 0 : _b["".concat(key, ".Nullable")]) === undefined) { | ||
(_c = (_d = collection.downgraded).schemas) !== null && _c !== void 0 ? _c : (_d.schemas = {}); | ||
collection.downgraded.schemas["".concat(key, ".Nullable")] = {}; | ||
collection.downgraded.schemas["".concat(key, ".Nullable")] = OpenApiV3Downgrader.downgradeSchema(collection)(OpenApiTypeChecker_1.OpenApiTypeChecker.isOneOf(found) | ||
? __assign(__assign({}, found), { oneOf: __spreadArray(__spreadArray([], __read(found.oneOf), false), [{ type: "null" }], false) }) : __assign(__assign({ title: found.title, description: found.description }, Object.fromEntries(Object.entries(found).filter(function (_a) { | ||
var _b = __read(_a, 2), key = _b[0], value = _b[1]; | ||
return key.startsWith("x-") && value !== undefined; | ||
}))), { oneOf: [found, { type: "null" }] })); | ||
} | ||
schema.$ref += ".Nullable"; | ||
}; | ||
}; | ||
@@ -329,0 +338,0 @@ }; |
@@ -301,3 +301,3 @@ "use strict"; | ||
visitConstant(input); | ||
if (nullable) | ||
if (nullable) { | ||
try { | ||
@@ -307,3 +307,3 @@ for (var union_1 = __values(union), union_1_1 = union_1.next(); !union_1_1.done; union_1_1 = union_1.next()) { | ||
if (OpenApiTypeChecker_1.OpenApiTypeChecker.isReference(u)) | ||
downgradeNullableReference(collection)(u); | ||
downgradeNullableReference(new Set())(collection)(u); | ||
else | ||
@@ -320,2 +320,3 @@ u["x-nullable"] = true; | ||
} | ||
} | ||
if (nullable === true && union.length === 0) | ||
@@ -329,17 +330,24 @@ return __assign({ type: "null" }, attribute); | ||
}; | ||
var downgradeNullableReference = function (collection) { | ||
return function (schema) { | ||
var _a; | ||
var key = schema.$ref.split("/").pop(); | ||
if (key.endsWith(".Nullable")) | ||
return; | ||
var found = (_a = collection.original.schemas) === null || _a === void 0 ? void 0 : _a[key]; | ||
if (found === undefined) | ||
return; | ||
else if (collection.downgraded["".concat(key, ".Nullable")] === undefined) { | ||
collection.downgraded["".concat(key, ".Nullable")] = {}; | ||
collection.downgraded["".concat(key, ".Nullable")] = | ||
SwaggerV2Downgrader.downgradeSchema(collection)(found); | ||
} | ||
schema.$ref += ".Nullable"; | ||
var downgradeNullableReference = function (visited) { | ||
return function (collection) { | ||
return function (schema) { | ||
var _a; | ||
var key = schema.$ref.split("/").pop(); | ||
if (key.endsWith(".Nullable")) | ||
return; | ||
var found = (_a = collection.original.schemas) === null || _a === void 0 ? void 0 : _a[key]; | ||
if (found === undefined) | ||
return; | ||
else if (isNullable(visited)(collection.original)(found) === true) | ||
return; | ||
else if (collection.downgraded["".concat(key, ".Nullable")] === undefined) { | ||
collection.downgraded["".concat(key, ".Nullable")] = {}; | ||
collection.downgraded["".concat(key, ".Nullable")] = SwaggerV2Downgrader.downgradeSchema(collection)(OpenApiTypeChecker_1.OpenApiTypeChecker.isOneOf(found) | ||
? __assign(__assign({}, found), { oneOf: __spreadArray(__spreadArray([], __read(found.oneOf), false), [{ type: "null" }], false) }) : __assign(__assign({ title: found.title, description: found.description }, Object.fromEntries(Object.entries(found).filter(function (_a) { | ||
var _b = __read(_a, 2), key = _b[0], value = _b[1]; | ||
return key.startsWith("x-") && value !== undefined; | ||
}))), { oneOf: [found, { type: "null" }] })); | ||
} | ||
schema.$ref += ".Nullable"; | ||
}; | ||
}; | ||
@@ -346,0 +354,0 @@ }; |
{ | ||
"name": "@samchon/openapi", | ||
"version": "1.1.1", | ||
"version": "1.1.2-dev.20241024", | ||
"description": "OpenAPI definitions and converters for 'typia' and 'nestia'.", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index.js", |
@@ -0,0 +0,0 @@ # `@samchon/openapi` |
@@ -0,0 +0,0 @@ import { OpenApi } from "../OpenApi"; |
@@ -0,0 +0,0 @@ import { OpenApi } from "../OpenApi"; |
@@ -0,0 +0,0 @@ import { OpenApi } from "../OpenApi"; |
@@ -0,0 +0,0 @@ import { OpenApi } from "../OpenApi"; |
@@ -0,0 +0,0 @@ import { OpenApi } from "../OpenApi"; |
@@ -0,0 +0,0 @@ import { OpenApi } from "../OpenApi"; |
@@ -281,3 +281,3 @@ import { OpenApi } from "../OpenApi"; | ||
if (OpenApiTypeChecker.isReference(u as any)) | ||
downgradeNullableReference(collection)(u as any); | ||
downgradeNullableReference(new Set())(collection)(u as any); | ||
else (u as OpenApiV3.IJsonSchema.IArray).nullable = true; | ||
@@ -297,2 +297,3 @@ if (nullable === true && union.length === 0) | ||
const downgradeNullableReference = | ||
(visited: Set<string>) => | ||
(collection: IComponentsCollection) => | ||
@@ -306,8 +307,28 @@ (schema: OpenApiV3.IJsonSchema.IReference): void => { | ||
if (found === undefined) return; | ||
else if (isNullable(visited)(collection.original)(found) === true) return; | ||
else if ( | ||
collection.downgraded.schemas![`${key}.Nullable`] === undefined | ||
collection.downgraded.schemas?.[`${key}.Nullable`] === undefined | ||
) { | ||
collection.downgraded.schemas![`${key}.Nullable`] = {}; | ||
collection.downgraded.schemas![`${key}.Nullable`] = | ||
downgradeSchema(collection)(found); | ||
collection.downgraded.schemas ??= {}; | ||
collection.downgraded.schemas[`${key}.Nullable`] = {}; | ||
collection.downgraded.schemas[`${key}.Nullable`] = downgradeSchema( | ||
collection, | ||
)( | ||
OpenApiTypeChecker.isOneOf(found) | ||
? { | ||
...found, | ||
oneOf: [...found.oneOf, { type: "null" }], | ||
} | ||
: { | ||
title: found.title, | ||
description: found.description, | ||
...Object.fromEntries( | ||
Object.entries(found).filter( | ||
([key, value]) => | ||
key.startsWith("x-") && value !== undefined, | ||
), | ||
), | ||
oneOf: [found, { type: "null" }], | ||
}, | ||
); | ||
} | ||
@@ -314,0 +335,0 @@ schema.$ref += ".Nullable"; |
@@ -0,0 +0,0 @@ import { OpenApi } from "../OpenApi"; |
@@ -300,7 +300,8 @@ import { OpenApi } from "../OpenApi"; | ||
visitConstant(input); | ||
if (nullable) | ||
if (nullable) { | ||
for (const u of union) | ||
if (OpenApiTypeChecker.isReference(u as any)) | ||
downgradeNullableReference(collection)(u as any); | ||
downgradeNullableReference(new Set())(collection)(u as any); | ||
else (u as SwaggerV2.IJsonSchema.IArray)["x-nullable"] = true; | ||
} | ||
@@ -321,2 +322,3 @@ if (nullable === true && union.length === 0) | ||
const downgradeNullableReference = | ||
(visited: Set<string>) => | ||
(collection: IComponentsCollection) => | ||
@@ -330,6 +332,23 @@ (schema: SwaggerV2.IJsonSchema.IReference): void => { | ||
if (found === undefined) return; | ||
else if (isNullable(visited)(collection.original)(found) === true) return; | ||
else if (collection.downgraded[`${key}.Nullable`] === undefined) { | ||
collection.downgraded[`${key}.Nullable`] = {}; | ||
collection.downgraded[`${key}.Nullable`] = | ||
downgradeSchema(collection)(found); | ||
collection.downgraded[`${key}.Nullable`] = downgradeSchema(collection)( | ||
OpenApiTypeChecker.isOneOf(found) | ||
? { | ||
...found, | ||
oneOf: [...found.oneOf, { type: "null" }], | ||
} | ||
: { | ||
title: found.title, | ||
description: found.description, | ||
...Object.fromEntries( | ||
Object.entries(found).filter( | ||
([key, value]) => | ||
key.startsWith("x-") && value !== undefined, | ||
), | ||
), | ||
oneOf: [found, { type: "null" }], | ||
}, | ||
); | ||
} | ||
@@ -336,0 +355,0 @@ schema.$ref += ".Nullable"; |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ import type { HttpLlm } from "../HttpLlm"; |
@@ -0,0 +0,0 @@ import type { HttpMigration } from "../HttpMigration"; |
@@ -0,0 +0,0 @@ import { HttpMigration } from "./HttpMigration"; |
@@ -0,0 +0,0 @@ import { OpenApi } from "./OpenApi"; |
@@ -0,0 +0,0 @@ // STRUCTURES |
@@ -0,0 +0,0 @@ import { OpenApiV3 } from "./OpenApiV3"; |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ /// <reference lib="dom" /> |
@@ -0,0 +0,0 @@ import { OpenApi } from "../OpenApi"; |
@@ -0,0 +0,0 @@ import { OpenApi } from "../OpenApi"; |
@@ -0,0 +0,0 @@ import { OpenApi } from "../OpenApi"; |
@@ -0,0 +0,0 @@ import { OpenApi } from "../OpenApi"; |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ import { ILlmFunction } from "./ILlmFunction"; |
@@ -0,0 +0,0 @@ import { ILlmSchema } from "./ILlmSchema"; |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ export namespace Escaper { |
@@ -0,0 +0,0 @@ import { IHttpLlmFunction } from "../structures/IHttpLlmFunction"; |
@@ -0,0 +0,0 @@ import { IHttpLlmFunction } from "../structures/IHttpLlmFunction"; |
@@ -0,0 +0,0 @@ import { ILlmSchema } from "../structures/ILlmSchema"; |
@@ -0,0 +0,0 @@ export namespace MapUtil { |
@@ -0,0 +0,0 @@ import { StringUtil } from "./StringUtil"; |
@@ -0,0 +0,0 @@ import { OpenApi } from "../OpenApi"; |
@@ -0,0 +0,0 @@ import { NamingConvention } from "./NamingConvention"; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
1169866
19760
1