@samchon/openapi
Advanced tools
Comparing version 0.1.23-dev.20240626-4 to 0.1.23-dev.20240626-5
@@ -1,3 +0,3 @@ | ||
export * from "./IMigrateOperation"; | ||
export * from "./IMigrationResult"; | ||
export * from "./IMigrateRoute"; | ||
export * from "./IMigrateResult"; | ||
export * from "./OpenApi"; | ||
@@ -4,0 +4,0 @@ export * from "./SwaggerV2"; |
@@ -17,4 +17,4 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__exportStar(require("./IMigrateOperation"), exports); | ||
__exportStar(require("./IMigrationResult"), exports); | ||
__exportStar(require("./IMigrateRoute"), exports); | ||
__exportStar(require("./IMigrateResult"), exports); | ||
__exportStar(require("./OpenApi"), exports); | ||
@@ -21,0 +21,0 @@ __exportStar(require("./SwaggerV2"), exports); |
@@ -1,5 +0,5 @@ | ||
import { IMigrationResult } from "../IMigrationResult"; | ||
import { IMigrateResult } from "../IMigrateResult"; | ||
import { OpenApi } from "../OpenApi"; | ||
export declare namespace MigrateConverter { | ||
const convert: (document: OpenApi.IDocument) => IMigrationResult; | ||
const convert: (document: OpenApi.IDocument) => IMigrateResult; | ||
} |
@@ -6,3 +6,3 @@ "use strict"; | ||
const MigrateOperationConverter_1 = require("./MigrateOperationConverter"); | ||
const MigrateOperationNamespacer_1 = require("./MigrateOperationNamespacer"); | ||
const MigrateRouteNamespacer_1 = require("./MigrateRouteNamespacer"); | ||
var MigrateConverter; | ||
@@ -17,3 +17,3 @@ (function (MigrateConverter) { | ||
.map((method) => { | ||
const original = collection[method]; | ||
const operation = collection[method]; | ||
const migrated = MigrateOperationConverter_1.MigrateOperationConverter.convert({ | ||
@@ -24,7 +24,9 @@ document, | ||
emendedPath: StringUtil_1.StringUtil.reJoinWithDecimalParameters(path), | ||
original, | ||
operation, | ||
}); | ||
if (Array.isArray(migrated)) { | ||
errors.push({ | ||
original: () => original, | ||
method, | ||
path, | ||
operation: () => operation, | ||
messages: migrated, | ||
@@ -38,5 +40,5 @@ }); | ||
const operations = entire.filter((o) => !!o); | ||
MigrateOperationNamespacer_1.MigrateOperationNamespacer.overwrite(operations); | ||
MigrateRouteNamespacer_1.MigrateRouteNamespacer.overwrite(operations); | ||
return { | ||
operations, | ||
routes: operations, | ||
errors, | ||
@@ -43,0 +45,0 @@ }; |
@@ -1,2 +0,2 @@ | ||
import { IMigrateOperation } from "../IMigrateOperation"; | ||
import { IMigrateRoute } from "../IMigrateRoute"; | ||
import { OpenApi } from "../OpenApi"; | ||
@@ -9,5 +9,5 @@ export declare namespace MigrateOperationConverter { | ||
emendedPath: string; | ||
original: OpenApi.IOperation; | ||
operation: OpenApi.IOperation; | ||
} | ||
const convert: (props: IProps) => IMigrateOperation | string[]; | ||
const convert: (props: IProps) => IMigrateRoute | string[]; | ||
} |
@@ -18,3 +18,3 @@ "use strict"; | ||
schema, | ||
}))(props.original.requestBody); | ||
}))(props.operation.requestBody); | ||
const success = emplaceBodySchema("response")((schema) => emplaceReference({ | ||
@@ -24,3 +24,3 @@ document: props.document, | ||
schema, | ||
}))((_d = (_b = (_a = props.original.responses) === null || _a === void 0 ? void 0 : _a["201"]) !== null && _b !== void 0 ? _b : (_c = props.original.responses) === null || _c === void 0 ? void 0 : _c["200"]) !== null && _d !== void 0 ? _d : (_e = props.original.responses) === null || _e === void 0 ? void 0 : _e.default); | ||
}))((_d = (_b = (_a = props.operation.responses) === null || _a === void 0 ? void 0 : _a["201"]) !== null && _b !== void 0 ? _b : (_c = props.operation.responses) === null || _c === void 0 ? void 0 : _c["200"]) !== null && _d !== void 0 ? _d : (_e = props.operation.responses) === null || _e === void 0 ? void 0 : _e.default); | ||
const failures = []; | ||
@@ -37,3 +37,3 @@ if (body === false) | ||
// FIND TARGET PARAMETERS | ||
const parameters = ((_a = props.original.parameters) !== null && _a !== void 0 ? _a : []).filter((p) => p.in === type); | ||
const parameters = ((_a = props.operation.parameters) !== null && _a !== void 0 ? _a : []).filter((p) => p.in === type); | ||
if (parameters.length === 0) | ||
@@ -130,3 +130,3 @@ return null; | ||
.map((str) => str.substring(1)); | ||
const pathParameters = ((_f = props.original.parameters) !== null && _f !== void 0 ? _f : []).filter((p) => p.in === "path"); | ||
const pathParameters = ((_f = props.operation.parameters) !== null && _f !== void 0 ? _f : []).filter((p) => p.in === "path"); | ||
if (parameterNames.length !== pathParameters.length) | ||
@@ -143,5 +143,5 @@ if (pathParameters.length < parameterNames.length && | ||
pathParameters.sort((a, b) => parameterNames.indexOf(a.name) - parameterNames.indexOf(b.name)); | ||
props.original.parameters = [ | ||
props.operation.parameters = [ | ||
...pathParameters, | ||
...((_g = props.original.parameters) !== null && _g !== void 0 ? _g : []).filter((p) => p.in !== "path"), | ||
...((_g = props.operation.parameters) !== null && _g !== void 0 ? _g : []).filter((p) => p.in !== "path"), | ||
]; | ||
@@ -165,3 +165,3 @@ } | ||
: null, | ||
parameters: ((_h = props.original.parameters) !== null && _h !== void 0 ? _h : []) | ||
parameters: ((_h = props.operation.parameters) !== null && _h !== void 0 ? _h : []) | ||
.filter((p) => p.in === "path") | ||
@@ -195,3 +195,3 @@ .map((p, i) => { | ||
success: success, | ||
exceptions: Object.fromEntries(Object.entries((_j = props.original.responses) !== null && _j !== void 0 ? _j : {}) | ||
exceptions: Object.fromEntries(Object.entries((_j = props.operation.responses) !== null && _j !== void 0 ? _j : {}) | ||
.filter(([key]) => key !== "200" && key !== "201" && key !== "default") | ||
@@ -208,4 +208,4 @@ .map(([key, value]) => { | ||
})), | ||
comment: () => writeDescription(props.original), | ||
original: () => props.original, | ||
comment: () => writeDescription(props.operation), | ||
operation: () => props.operation, | ||
}; | ||
@@ -212,0 +212,0 @@ }; |
@@ -1,2 +0,2 @@ | ||
import { IMigrationResult } from "./IMigrationResult"; | ||
import { IMigrateResult } from "./IMigrateResult"; | ||
import { OpenApiV3 } from "./OpenApiV3"; | ||
@@ -58,3 +58,3 @@ import { OpenApiV3_1 } from "./OpenApiV3_1"; | ||
function downgrade(document: IDocument, version: "3.0"): OpenApiV3.IDocument; | ||
function migrate(document: IDocument): IMigrationResult; | ||
function migrate(document: IDocument): IMigrateResult; | ||
interface IDocument { | ||
@@ -61,0 +61,0 @@ openapi: `3.1.${number}`; |
{ | ||
"name": "@samchon/openapi", | ||
"version": "0.1.23-dev.20240626-4", | ||
"version": "0.1.23-dev.20240626-5", | ||
"description": "OpenAPI definitions and converters for 'typia' and 'nestia'.", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index.js", |
@@ -1,3 +0,3 @@ | ||
export * from "./IMigrateOperation"; | ||
export * from "./IMigrationResult"; | ||
export * from "./IMigrateRoute"; | ||
export * from "./IMigrateResult"; | ||
export * from "./OpenApi"; | ||
@@ -4,0 +4,0 @@ |
@@ -1,12 +0,12 @@ | ||
import { IMigrateOperation } from "../IMigrateOperation"; | ||
import { IMigrationResult } from "../IMigrationResult"; | ||
import { IMigrateRoute } from "../IMigrateRoute"; | ||
import { IMigrateResult } from "../IMigrateResult"; | ||
import { OpenApi } from "../OpenApi"; | ||
import { StringUtil } from "../utils/StringUtil"; | ||
import { MigrateOperationConverter } from "./MigrateOperationConverter"; | ||
import { MigrateOperationNamespacer } from "./MigrateOperationNamespacer"; | ||
import { MigrateRouteNamespacer } from "./MigrateRouteNamespacer"; | ||
export namespace MigrateConverter { | ||
export const convert = (document: OpenApi.IDocument): IMigrationResult => { | ||
const errors: IMigrationResult.IError[] = []; | ||
const entire: Array<IMigrateOperation | null> = Object.entries( | ||
export const convert = (document: OpenApi.IDocument): IMigrateResult => { | ||
const errors: IMigrateResult.IError[] = []; | ||
const entire: Array<IMigrateRoute | null> = Object.entries( | ||
document.paths ?? {}, | ||
@@ -18,4 +18,4 @@ ) | ||
.map((method) => { | ||
const original: OpenApi.IOperation = collection[method]!; | ||
const migrated: IMigrateOperation | string[] = | ||
const operation: OpenApi.IOperation = collection[method]!; | ||
const migrated: IMigrateRoute | string[] = | ||
MigrateOperationConverter.convert({ | ||
@@ -26,7 +26,9 @@ document, | ||
emendedPath: StringUtil.reJoinWithDecimalParameters(path), | ||
original, | ||
operation, | ||
}); | ||
if (Array.isArray(migrated)) { | ||
errors.push({ | ||
original: () => original, | ||
method, | ||
path, | ||
operation: () => operation, | ||
messages: migrated, | ||
@@ -40,8 +42,8 @@ }); | ||
.flat(); | ||
const operations: IMigrateOperation[] = entire.filter( | ||
(o): o is IMigrateOperation => !!o, | ||
const operations: IMigrateRoute[] = entire.filter( | ||
(o): o is IMigrateRoute => !!o, | ||
); | ||
MigrateOperationNamespacer.overwrite(operations); | ||
MigrateRouteNamespacer.overwrite(operations); | ||
return { | ||
operations, | ||
routes: operations, | ||
errors, | ||
@@ -48,0 +50,0 @@ }; |
@@ -1,2 +0,2 @@ | ||
import { IMigrateOperation } from "../IMigrateOperation"; | ||
import { IMigrateRoute } from "../IMigrateRoute"; | ||
import { OpenApi } from "../OpenApi"; | ||
@@ -13,9 +13,9 @@ import { Escaper } from "../utils/Escaper"; | ||
emendedPath: string; | ||
original: OpenApi.IOperation; | ||
operation: OpenApi.IOperation; | ||
} | ||
export const convert = (props: IProps): IMigrateOperation | string[] => { | ||
export const convert = (props: IProps): IMigrateRoute | string[] => { | ||
//---- | ||
// REQUEST AND RESPONSE BODY | ||
//---- | ||
const body: false | null | IMigrateOperation.IBody = emplaceBodySchema( | ||
const body: false | null | IMigrateRoute.IBody = emplaceBodySchema( | ||
"request", | ||
@@ -28,4 +28,4 @@ )((schema) => | ||
}), | ||
)(props.original.requestBody); | ||
const success: false | null | IMigrateOperation.IBody = emplaceBodySchema( | ||
)(props.operation.requestBody); | ||
const success: false | null | IMigrateRoute.IBody = emplaceBodySchema( | ||
"response", | ||
@@ -39,5 +39,5 @@ )((schema) => | ||
)( | ||
props.original.responses?.["201"] ?? | ||
props.original.responses?.["200"] ?? | ||
props.original.responses?.default, | ||
props.operation.responses?.["201"] ?? | ||
props.operation.responses?.["200"] ?? | ||
props.operation.responses?.default, | ||
); | ||
@@ -61,3 +61,3 @@ | ||
const parameters: OpenApi.IOperation.IParameter[] = ( | ||
props.original.parameters ?? [] | ||
props.operation.parameters ?? [] | ||
).filter((p) => p.in === type); | ||
@@ -177,3 +177,3 @@ if (parameters.length === 0) return null; | ||
const pathParameters: OpenApi.IOperation.IParameter[] = ( | ||
props.original.parameters ?? [] | ||
props.operation.parameters ?? [] | ||
).filter((p) => p.in === "path"); | ||
@@ -198,5 +198,5 @@ if (parameterNames.length !== pathParameters.length) | ||
); | ||
props.original.parameters = [ | ||
props.operation.parameters = [ | ||
...pathParameters, | ||
...(props.original.parameters ?? []).filter((p) => p.in !== "path"), | ||
...(props.operation.parameters ?? []).filter((p) => p.in !== "path"), | ||
]; | ||
@@ -221,3 +221,3 @@ } else | ||
: null, | ||
parameters: (props.original.parameters ?? []) | ||
parameters: (props.operation.parameters ?? []) | ||
.filter((p) => p.in === "path") | ||
@@ -247,6 +247,6 @@ .map((p, i) => ({ | ||
: null, | ||
body: body as IMigrateOperation.IBody | null, | ||
success: success as IMigrateOperation.IBody | null, | ||
body: body as IMigrateRoute.IBody | null, | ||
success: success as IMigrateRoute.IBody | null, | ||
exceptions: Object.fromEntries( | ||
Object.entries(props.original.responses ?? {}) | ||
Object.entries(props.operation.responses ?? {}) | ||
.filter( | ||
@@ -263,4 +263,4 @@ ([key]) => key !== "200" && key !== "201" && key !== "default", | ||
), | ||
comment: () => writeDescription(props.original), | ||
original: () => props.original, | ||
comment: () => writeDescription(props.operation), | ||
operation: () => props.operation, | ||
}; | ||
@@ -308,3 +308,3 @@ }; | ||
"x-nestia-encrypted"?: boolean; | ||
}): false | null | IMigrateOperation.IBody => { | ||
}): false | null | IMigrateRoute.IBody => { | ||
if (!meta?.content) return null; | ||
@@ -311,0 +311,0 @@ |
@@ -1,2 +0,2 @@ | ||
import { IMigrationResult } from "./IMigrationResult"; | ||
import { IMigrateResult } from "./IMigrateResult"; | ||
import { OpenApiV3 } from "./OpenApiV3"; | ||
@@ -111,3 +111,3 @@ import { OpenApiV3_1 } from "./OpenApiV3_1"; | ||
export function migrate(document: IDocument): IMigrationResult { | ||
export function migrate(document: IDocument): IMigrateResult { | ||
return MigrateConverter.convert(document); | ||
@@ -114,0 +114,0 @@ } |
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
7440
299805