@samchon/openapi
Advanced tools
Comparing version 1.0.4 to 1.0.5
@@ -184,2 +184,3 @@ "use strict"; | ||
})(), | ||
deprecated: operation.deprecated, | ||
route: function () { return route; }, | ||
@@ -186,0 +187,0 @@ operation: function () { return operation; }, |
@@ -38,4 +38,16 @@ "use strict"; | ||
}; | ||
var __values = (this && this.__values) || function(o) { | ||
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; | ||
if (m) return m.call(o); | ||
if (o && typeof o.length === "number") return { | ||
next: function () { | ||
if (o && i >= o.length) o = void 0; | ||
return { value: o && o[i++], done: !o }; | ||
} | ||
}; | ||
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.OpenApiV3Converter = void 0; | ||
var OpenApiTypeChecker_1 = require("../utils/OpenApiTypeChecker"); | ||
var OpenApiV3Converter; | ||
@@ -243,2 +255,3 @@ (function (OpenApiV3Converter) { | ||
return function (input) { | ||
var e_1, _a; | ||
var nullable = { | ||
@@ -249,6 +262,6 @@ value: false, | ||
var union = []; | ||
var attribute = __assign({ title: input.title, description: input.description }, Object.fromEntries(Object.entries(input).filter(function (_a) { | ||
var attribute = __assign(__assign({ title: input.title, description: input.description }, Object.fromEntries(Object.entries(input).filter(function (_a) { | ||
var _b = __read(_a, 2), key = _b[0], value = _b[1]; | ||
return key.startsWith("x-") && value !== undefined; | ||
}))); | ||
}))), { example: input.example, examples: input.examples }); | ||
var visit = function (schema) { | ||
@@ -324,2 +337,26 @@ var _a, _b, _c, _d; | ||
}); | ||
if (union.length === 2 && | ||
union.filter(function (x) { return OpenApiTypeChecker_1.OpenApiTypeChecker.isNull(x); }).length === 1) { | ||
var type = union.filter(function (x) { return OpenApiTypeChecker_1.OpenApiTypeChecker.isNull(x) === false; })[0]; | ||
try { | ||
for (var _b = __values([ | ||
"title", | ||
"description", | ||
"deprecated", | ||
"example", | ||
"examples", | ||
]), _c = _b.next(); !_c.done; _c = _b.next()) { | ||
var key = _c.value; | ||
if (type[key] !== undefined) | ||
delete type[key]; | ||
} | ||
} | ||
catch (e_1_1) { e_1 = { error: e_1_1 }; } | ||
finally { | ||
try { | ||
if (_c && !_c.done && (_a = _b.return)) _a.call(_b); | ||
} | ||
finally { if (e_1) throw e_1.error; } | ||
} | ||
} | ||
return __assign(__assign(__assign({}, (union.length === 0 | ||
@@ -326,0 +363,0 @@ ? { type: undefined } |
@@ -198,6 +198,6 @@ "use strict"; | ||
var union = []; | ||
var attribute = __assign({ title: input.title, description: input.description }, Object.fromEntries(Object.entries(input).filter(function (_a) { | ||
var attribute = __assign(__assign({ title: input.title, description: input.description }, Object.fromEntries(Object.entries(input).filter(function (_a) { | ||
var _b = __read(_a, 2), key = _b[0], value = _b[1]; | ||
return key.startsWith("x-") && value !== undefined; | ||
}))); | ||
}))), { example: input.example, examples: input.examples }); | ||
var visit = function (schema) { | ||
@@ -204,0 +204,0 @@ if (OpenApiTypeChecker_1.OpenApiTypeChecker.isBoolean(schema)) |
@@ -5,2 +5,3 @@ import { OpenApi } from "../OpenApi"; | ||
const convert: (input: SwaggerV2.IDocument) => OpenApi.IDocument; | ||
const convertSchema: (input: SwaggerV2.IJsonSchema) => OpenApi.IJsonSchema; | ||
} |
@@ -38,4 +38,16 @@ "use strict"; | ||
}; | ||
var __values = (this && this.__values) || function(o) { | ||
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; | ||
if (m) return m.call(o); | ||
if (o && typeof o.length === "number") return { | ||
next: function () { | ||
if (o && i >= o.length) o = void 0; | ||
return { value: o && o[i++], done: !o }; | ||
} | ||
}; | ||
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.SwaggerV2Converter = void 0; | ||
var OpenApiTypeChecker_1 = require("../utils/OpenApiTypeChecker"); | ||
var SwaggerV2Converter; | ||
@@ -139,3 +151,3 @@ (function (SwaggerV2Converter) { | ||
description: input.description, | ||
schema: convertSchema(input), | ||
schema: SwaggerV2Converter.convertSchema(input), | ||
required: true, | ||
@@ -147,3 +159,3 @@ }); }; | ||
"application/json": { | ||
schema: convertSchema(input.schema), | ||
schema: SwaggerV2Converter.convertSchema(input.schema), | ||
}, | ||
@@ -166,3 +178,3 @@ }, | ||
"application/json": { | ||
schema: convertSchema(input.schema), | ||
schema: SwaggerV2Converter.convertSchema(input.schema), | ||
example: input.example, | ||
@@ -183,3 +195,3 @@ }, | ||
{ | ||
schema: convertSchema(value), | ||
schema: SwaggerV2Converter.convertSchema(value), | ||
in: "header", | ||
@@ -205,3 +217,3 @@ }, | ||
var _b = __read(_a, 2), key = _b[0], value = _b[1]; | ||
return [key, convertSchema(value)]; | ||
return [key, SwaggerV2Converter.convertSchema(value)]; | ||
})) | ||
@@ -284,3 +296,4 @@ : undefined, | ||
}; | ||
var convertSchema = function (input) { | ||
SwaggerV2Converter.convertSchema = function (input) { | ||
var e_1, _a; | ||
var nullable = { | ||
@@ -291,6 +304,8 @@ value: false, | ||
var union = []; | ||
var attribute = __assign({ title: input.title, description: input.description }, Object.fromEntries(Object.entries(input).filter(function (_a) { | ||
var attribute = __assign(__assign({ title: input.title, description: input.description }, Object.fromEntries(Object.entries(input).filter(function (_a) { | ||
var _b = __read(_a, 2), key = _b[0], value = _b[1]; | ||
return key.startsWith("x-") && value !== undefined; | ||
}))); | ||
}))), { example: input.example, examples: input.examples | ||
? Object.fromEntries(input.examples.map(function (v, i) { return [i.toString(), v]; })) | ||
: undefined }); | ||
var visit = function (schema) { | ||
@@ -324,8 +339,12 @@ var _a, _b, _c, _d; | ||
else | ||
union.push(__assign(__assign(__assign({}, schema), { default: ((_d = schema.default) !== null && _d !== void 0 ? _d : undefined) }), { enum: undefined })); | ||
union.push(__assign(__assign(__assign({}, schema), { default: ((_d = schema.default) !== null && _d !== void 0 ? _d : undefined), examples: schema.examples | ||
? Object.fromEntries(schema.examples.map(function (v, i) { return [i.toString(), v]; })) | ||
: undefined }), { enum: undefined })); | ||
// INSTANCE TYPE CASE | ||
else if (TypeChecker.isArray(schema)) | ||
union.push(__assign(__assign({}, schema), { items: convertSchema(schema.items) })); | ||
union.push(__assign(__assign({}, schema), { items: SwaggerV2Converter.convertSchema(schema.items), examples: schema.examples | ||
? Object.fromEntries(schema.examples.map(function (v, i) { return [i.toString(), v]; })) | ||
: undefined })); | ||
else if (TypeChecker.isObject(schema)) | ||
union.push(__assign(__assign({}, schema), { | ||
union.push(__assign(__assign(__assign({}, schema), { | ||
properties: schema.properties | ||
@@ -339,3 +358,3 @@ ? Object.fromEntries(Object.entries(schema.properties) | ||
var _b = __read(_a, 2), key = _b[0], value = _b[1]; | ||
return [key, convertSchema(value)]; | ||
return [key, SwaggerV2Converter.convertSchema(value)]; | ||
})) | ||
@@ -346,10 +365,16 @@ : undefined, | ||
schema.additionalProperties !== null | ||
? convertSchema(schema.additionalProperties) | ||
? SwaggerV2Converter.convertSchema(schema.additionalProperties) | ||
: schema.additionalProperties | ||
: undefined, | ||
})); | ||
}), { examples: schema.examples | ||
? Object.fromEntries(schema.examples.map(function (v, i) { return [i.toString(), v]; })) | ||
: undefined })); | ||
else if (TypeChecker.isReference(schema)) | ||
union.push(__assign(__assign({}, schema), { $ref: schema.$ref.replace("#/definitions/", "#/components/schemas/") })); | ||
union.push(__assign(__assign({}, schema), { $ref: schema.$ref.replace("#/definitions/", "#/components/schemas/"), examples: schema.examples | ||
? Object.fromEntries(schema.examples.map(function (v, i) { return [i.toString(), v]; })) | ||
: undefined })); | ||
else | ||
union.push(schema); | ||
union.push(__assign(__assign({}, schema), { examples: schema.examples | ||
? Object.fromEntries(schema.examples.map(function (v, i) { return [i.toString(), v]; })) | ||
: undefined })); | ||
}; | ||
@@ -363,2 +388,26 @@ visit(input); | ||
}); | ||
if (union.length === 2 && | ||
union.filter(function (x) { return OpenApiTypeChecker_1.OpenApiTypeChecker.isNull(x); }).length === 1) { | ||
var type = union.filter(function (x) { return OpenApiTypeChecker_1.OpenApiTypeChecker.isNull(x) === false; })[0]; | ||
try { | ||
for (var _b = __values([ | ||
"title", | ||
"description", | ||
"deprecated", | ||
"example", | ||
"examples", | ||
]), _c = _b.next(); !_c.done; _c = _b.next()) { | ||
var key = _c.value; | ||
if (type[key] !== undefined) | ||
delete type[key]; | ||
} | ||
} | ||
catch (e_1_1) { e_1 = { error: e_1_1 }; } | ||
finally { | ||
try { | ||
if (_c && !_c.done && (_a = _b.return)) _a.call(_b); | ||
} | ||
finally { if (e_1) throw e_1.error; } | ||
} | ||
} | ||
return __assign(__assign(__assign({}, (union.length === 0 | ||
@@ -365,0 +414,0 @@ ? { type: undefined } |
@@ -230,9 +230,13 @@ "use strict"; | ||
OpenApiTypeChecker_1.OpenApiTypeChecker.isString(schema)) | ||
union.push(__assign({}, schema)); | ||
union.push(__assign(__assign({}, schema), { examples: schema.examples | ||
? Object.values(schema.examples) | ||
: undefined })); | ||
else if (OpenApiTypeChecker_1.OpenApiTypeChecker.isReference(schema)) | ||
union.push({ $ref: "#/definitions/".concat(schema.$ref.split("/").pop()) }); | ||
else if (OpenApiTypeChecker_1.OpenApiTypeChecker.isArray(schema)) | ||
union.push(__assign(__assign({}, schema), { items: SwaggerV2Downgrader.downgradeSchema(collection)(schema.items) })); | ||
union.push(__assign(__assign({}, schema), { items: SwaggerV2Downgrader.downgradeSchema(collection)(schema.items), examples: schema.examples | ||
? Object.values(schema.examples) | ||
: undefined })); | ||
else if (OpenApiTypeChecker_1.OpenApiTypeChecker.isTuple(schema)) | ||
union.push(__assign(__assign(__assign({}, schema), { items: (function () { | ||
union.push(__assign(__assign(__assign(__assign({}, schema), { items: (function () { | ||
if (schema.additionalItems === true) | ||
@@ -253,3 +257,5 @@ return {}; | ||
additionalItems: undefined, | ||
})); | ||
}), { examples: schema.examples | ||
? Object.values(schema.examples) | ||
: undefined })); | ||
else if (OpenApiTypeChecker_1.OpenApiTypeChecker.isObject(schema)) | ||
@@ -271,3 +277,5 @@ union.push(__assign(__assign({}, schema), { properties: schema.properties | ||
? SwaggerV2Downgrader.downgradeSchema(collection)(schema.additionalProperties) | ||
: schema.additionalProperties, required: schema.required })); | ||
: schema.additionalProperties, required: schema.required, examples: schema.examples | ||
? Object.values(schema.examples) | ||
: undefined })); | ||
else if (OpenApiTypeChecker_1.OpenApiTypeChecker.isOneOf(schema)) | ||
@@ -274,0 +282,0 @@ schema.oneOf.forEach(visit); |
@@ -888,2 +888,10 @@ import { OpenApiV3 } from "./OpenApiV3"; | ||
deprecated?: boolean; | ||
/** | ||
* Example value. | ||
*/ | ||
example?: any; | ||
/** | ||
* List of example values as key-value pairs. | ||
*/ | ||
examples?: Record<string, any>; | ||
} | ||
@@ -890,0 +898,0 @@ } |
@@ -215,2 +215,4 @@ /** | ||
deprecated?: boolean; | ||
example?: any; | ||
examples?: Record<string, any>; | ||
} | ||
@@ -217,0 +219,0 @@ } |
@@ -198,2 +198,4 @@ /** | ||
deprecated?: boolean; | ||
example?: any; | ||
examples?: Record<string, any>; | ||
} | ||
@@ -200,0 +202,0 @@ } |
@@ -177,2 +177,10 @@ import { OpenApi } from "../OpenApi"; | ||
/** | ||
* Whether the function is deprecated or not. | ||
* | ||
* If the `deprecated` is `true`, the function is not recommended to use. | ||
* | ||
* LLM (Large Language Model) may not use the deprecated function. | ||
*/ | ||
deprecated?: boolean | undefined; | ||
/** | ||
* Get the Swagger operation metadata. | ||
@@ -179,0 +187,0 @@ * |
@@ -56,2 +56,10 @@ import { ILlmSchema } from "./ILlmSchema"; | ||
description?: string | undefined; | ||
/** | ||
* Whether the function is deprecated or not. | ||
* | ||
* If the `deprecated` is `true`, the function is not recommended to use. | ||
* | ||
* LLM (Large Language Model) may not use the deprecated function. | ||
*/ | ||
deprecated?: boolean | undefined; | ||
} | ||
@@ -58,0 +66,0 @@ export declare namespace ILlmFunction { |
@@ -338,3 +338,11 @@ /** | ||
deprecated?: boolean; | ||
/** | ||
* Example value. | ||
*/ | ||
example?: any; | ||
/** | ||
* List of example values as key-value pairs. | ||
*/ | ||
examples?: Record<string, any>; | ||
} | ||
} |
@@ -160,2 +160,4 @@ /** | ||
deprecated?: boolean; | ||
example?: any; | ||
examples?: any[]; | ||
} | ||
@@ -162,0 +164,0 @@ } |
{ | ||
"name": "@samchon/openapi", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"description": "OpenAPI definitions and converters for 'typia' and 'nestia'.", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index.js", |
@@ -170,2 +170,3 @@ import { OpenApi } from "../OpenApi"; | ||
})(), | ||
deprecated: operation.deprecated, | ||
route: () => route, | ||
@@ -172,0 +173,0 @@ operation: () => operation, |
import { OpenApi } from "../OpenApi"; | ||
import { OpenApiV3 } from "../OpenApiV3"; | ||
import { OpenApiTypeChecker } from "../utils/OpenApiTypeChecker"; | ||
@@ -260,2 +261,4 @@ export namespace OpenApiV3Converter { | ||
), | ||
example: input.example, | ||
examples: input.examples, | ||
}; | ||
@@ -352,2 +355,18 @@ const visit = (schema: OpenApiV3.IJsonSchema): void => { | ||
}); | ||
if ( | ||
union.length === 2 && | ||
union.filter((x) => OpenApiTypeChecker.isNull(x)).length === 1 | ||
) { | ||
const type: OpenApi.IJsonSchema = union.filter( | ||
(x) => OpenApiTypeChecker.isNull(x) === false, | ||
)[0]; | ||
for (const key of [ | ||
"title", | ||
"description", | ||
"deprecated", | ||
"example", | ||
"examples", | ||
] as const) | ||
if (type[key] !== undefined) delete type[key]; | ||
} | ||
return { | ||
@@ -354,0 +373,0 @@ ...(union.length === 0 |
@@ -191,2 +191,4 @@ import { OpenApi } from "../OpenApi"; | ||
), | ||
example: input.example, | ||
examples: input.examples, | ||
}; | ||
@@ -193,0 +195,0 @@ const visit = (schema: OpenApi.IJsonSchema): void => { |
import { OpenApi } from "../OpenApi"; | ||
import { SwaggerV2 } from "../SwaggerV2"; | ||
import { OpenApiTypeChecker } from "../utils/OpenApiTypeChecker"; | ||
@@ -254,3 +255,5 @@ export namespace SwaggerV2Converter { | ||
const convertSchema = (input: SwaggerV2.IJsonSchema): OpenApi.IJsonSchema => { | ||
export const convertSchema = ( | ||
input: SwaggerV2.IJsonSchema, | ||
): OpenApi.IJsonSchema => { | ||
const nullable: { value: boolean; default?: null } = { | ||
@@ -269,2 +272,6 @@ value: false, | ||
), | ||
example: input.example, | ||
examples: input.examples | ||
? Object.fromEntries(input.examples.map((v, i) => [i.toString(), v])) | ||
: undefined, | ||
}; | ||
@@ -311,2 +318,7 @@ const visit = (schema: SwaggerV2.IJsonSchema): void => { | ||
| undefined as any, | ||
examples: schema.examples | ||
? Object.fromEntries( | ||
schema.examples.map((v, i) => [i.toString(), v]), | ||
) | ||
: undefined, | ||
...{ enum: undefined }, | ||
@@ -319,2 +331,7 @@ }); | ||
items: convertSchema(schema.items), | ||
examples: schema.examples | ||
? Object.fromEntries( | ||
schema.examples.map((v, i) => [i.toString(), v]), | ||
) | ||
: undefined, | ||
}); | ||
@@ -339,2 +356,7 @@ else if (TypeChecker.isObject(schema)) | ||
}, | ||
examples: schema.examples | ||
? Object.fromEntries( | ||
schema.examples.map((v, i) => [i.toString(), v]), | ||
) | ||
: undefined, | ||
}); | ||
@@ -345,4 +367,17 @@ else if (TypeChecker.isReference(schema)) | ||
$ref: schema.$ref.replace("#/definitions/", "#/components/schemas/"), | ||
examples: schema.examples | ||
? Object.fromEntries( | ||
schema.examples.map((v, i) => [i.toString(), v]), | ||
) | ||
: undefined, | ||
}); | ||
else union.push(schema); | ||
else | ||
union.push({ | ||
...schema, | ||
examples: schema.examples | ||
? Object.fromEntries( | ||
schema.examples.map((v, i) => [i.toString(), v]), | ||
) | ||
: undefined, | ||
}); | ||
}; | ||
@@ -359,2 +394,18 @@ | ||
}); | ||
if ( | ||
union.length === 2 && | ||
union.filter((x) => OpenApiTypeChecker.isNull(x)).length === 1 | ||
) { | ||
const type: OpenApi.IJsonSchema = union.filter( | ||
(x) => OpenApiTypeChecker.isNull(x) === false, | ||
)[0]; | ||
for (const key of [ | ||
"title", | ||
"description", | ||
"deprecated", | ||
"example", | ||
"examples", | ||
] as const) | ||
if (type[key] !== undefined) delete type[key]; | ||
} | ||
return { | ||
@@ -361,0 +412,0 @@ ...(union.length === 0 |
@@ -212,3 +212,8 @@ import { OpenApi } from "../OpenApi"; | ||
) | ||
union.push({ ...schema }); | ||
union.push({ | ||
...schema, | ||
examples: schema.examples | ||
? Object.values(schema.examples) | ||
: undefined, | ||
}); | ||
else if (OpenApiTypeChecker.isReference(schema)) | ||
@@ -220,2 +225,5 @@ union.push({ $ref: `#/definitions/${schema.$ref.split("/").pop()}` }); | ||
items: downgradeSchema(collection)(schema.items), | ||
examples: schema.examples | ||
? Object.values(schema.examples) | ||
: undefined, | ||
}); | ||
@@ -247,2 +255,5 @@ else if (OpenApiTypeChecker.isTuple(schema)) | ||
}, | ||
examples: schema.examples | ||
? Object.values(schema.examples) | ||
: undefined, | ||
}); | ||
@@ -267,2 +278,5 @@ else if (OpenApiTypeChecker.isObject(schema)) | ||
required: schema.required, | ||
examples: schema.examples | ||
? Object.values(schema.examples) | ||
: undefined, | ||
}); | ||
@@ -269,0 +283,0 @@ else if (OpenApiTypeChecker.isOneOf(schema)) |
@@ -1111,2 +1111,12 @@ import { OpenApiV3 } from "./OpenApiV3"; | ||
deprecated?: boolean; | ||
/** | ||
* Example value. | ||
*/ | ||
example?: any; | ||
/** | ||
* List of example values as key-value pairs. | ||
*/ | ||
examples?: Record<string, any>; | ||
} | ||
@@ -1113,0 +1123,0 @@ } |
@@ -331,2 +331,4 @@ /** | ||
deprecated?: boolean; | ||
example?: any; | ||
examples?: Record<string, any>; | ||
} | ||
@@ -333,0 +335,0 @@ } |
@@ -291,2 +291,4 @@ /** | ||
deprecated?: boolean; | ||
example?: any; | ||
examples?: Record<string, any>; | ||
} | ||
@@ -293,0 +295,0 @@ } |
@@ -190,2 +190,11 @@ import { OpenApi } from "../OpenApi"; | ||
/** | ||
* Whether the function is deprecated or not. | ||
* | ||
* If the `deprecated` is `true`, the function is not recommended to use. | ||
* | ||
* LLM (Large Language Model) may not use the deprecated function. | ||
*/ | ||
deprecated?: boolean | undefined; | ||
/** | ||
* Get the Swagger operation metadata. | ||
@@ -192,0 +201,0 @@ * |
@@ -61,2 +61,11 @@ import { ILlmSchema } from "./ILlmSchema"; | ||
description?: string | undefined; | ||
/** | ||
* Whether the function is deprecated or not. | ||
* | ||
* If the `deprecated` is `true`, the function is not recommended to use. | ||
* | ||
* LLM (Large Language Model) may not use the deprecated function. | ||
*/ | ||
deprecated?: boolean | undefined; | ||
} | ||
@@ -63,0 +72,0 @@ export namespace ILlmFunction { |
@@ -412,3 +412,13 @@ /** | ||
deprecated?: boolean; | ||
/** | ||
* Example value. | ||
*/ | ||
example?: any; | ||
/** | ||
* List of example values as key-value pairs. | ||
*/ | ||
examples?: Record<string, any>; | ||
} | ||
} |
@@ -234,2 +234,4 @@ /** | ||
deprecated?: boolean; | ||
example?: any; | ||
examples?: any[]; | ||
} | ||
@@ -236,0 +238,0 @@ } |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1138496
19648