@samchon/openapi
Advanced tools
Comparing version 0.1.23-dev.20240626-6 to 0.1.23-dev.20240627-2
@@ -6,3 +6,3 @@ "use strict"; | ||
const MigrateOperationConverter_1 = require("./MigrateOperationConverter"); | ||
const MigrateRouteNamespacer_1 = require("./MigrateRouteNamespacer"); | ||
const MigrateRouteAccessor_1 = require("./MigrateRouteAccessor"); | ||
var MigrateConverter; | ||
@@ -38,3 +38,3 @@ (function (MigrateConverter) { | ||
const operations = entire.filter((o) => !!o); | ||
MigrateRouteNamespacer_1.MigrateRouteNamespacer.overwrite(operations); | ||
MigrateRouteAccessor_1.MigrateRouteAccessor.overwrite(operations); | ||
return { | ||
@@ -41,0 +41,0 @@ routes: operations, |
export declare namespace StringUtil { | ||
const capitalize: (str: string) => string; | ||
const pascal: (path: string) => string; | ||
const camel: (path: string) => string; | ||
const splitWithNormalization: (path: string) => string[]; | ||
const reJoinWithDecimalParameters: (path: string) => string; | ||
const normalize: (str: string) => string; | ||
const commonPrefix: (strs: string[]) => string; | ||
const escapeDuplicate: (keep: string[]) => (change: string) => string; | ||
const escapeNonVariableSymbols: (str: string) => string; | ||
} |
@@ -12,5 +12,2 @@ "use strict"; | ||
.join(""); | ||
StringUtil.camel = (path) => StringUtil.splitWithNormalization(path) | ||
.map((str, i) => i === 0 ? NamingConvention_1.NamingConvention.camel(str) : NamingConvention_1.NamingConvention.pascal(str)) | ||
.join(""); | ||
StringUtil.splitWithNormalization = (path) => path | ||
@@ -28,61 +25,3 @@ .split("/") | ||
StringUtil.normalize = (str) => str.split(".").join("_").split("-").join("_"); | ||
StringUtil.commonPrefix = (strs) => { | ||
if (strs.length === 0) | ||
return ""; | ||
let prefix = strs[0]; | ||
for (let i = 1; i < strs.length; i++) { | ||
while (strs[i].indexOf(prefix) !== 0) { | ||
prefix = prefix.substring(0, prefix.length - 1); | ||
if (prefix === "") | ||
return ""; | ||
} | ||
} | ||
return prefix | ||
.split("/") | ||
.filter((str) => str[0] !== "{" || str[str.length - 1] === "}") | ||
.join("/"); | ||
}; | ||
StringUtil.escapeDuplicate = (keep) => (change) => keep.includes(change) ? StringUtil.escapeDuplicate(keep)(`_${change}`) : change; | ||
StringUtil.escapeNonVariableSymbols = (str) => { | ||
for (const [before, after] of VARIABLE_REPLACERS) | ||
str = str.split(before).join(after); | ||
for (let i = 0; i <= 9; ++i) | ||
if (str[0] === i.toString()) { | ||
str = "_" + str; | ||
break; | ||
} | ||
str = str.trim(); | ||
if (str === "") | ||
return "_empty_"; | ||
return str; | ||
}; | ||
})(StringUtil || (exports.StringUtil = StringUtil = {})); | ||
const VARIABLE_REPLACERS = [ | ||
["`", "_backquote_"], | ||
["!", "_exclamation_"], | ||
["#", "_hash_"], | ||
["$", "_dollar_"], | ||
["%", "_percent_"], | ||
["^", "_caret_"], | ||
["&", "_and_"], | ||
["*", "_star_"], | ||
["(", "_lparen_"], | ||
[")", "_rparen_"], | ||
["-", "_minus_"], | ||
["+", "_plus_"], | ||
["|", "_or_"], | ||
["{", "_blt_"], | ||
["}", "_bgt_"], | ||
["<", "_lt_"], | ||
[">", "_gt_"], | ||
["[", "_alt_"], | ||
["]", "_agt_"], | ||
[",", "_comma_"], | ||
["'", "_singlequote_"], | ||
['"', "_doublequote_"], | ||
[" ", "_space_"], | ||
["?", "_question_"], | ||
[":", "_colon_"], | ||
[";", "_semicolon_"], | ||
["...", "_rest_"], | ||
]; |
{ | ||
"name": "@samchon/openapi", | ||
"version": "0.1.23-dev.20240626-6", | ||
"version": "0.1.23-dev.20240627-2", | ||
"description": "OpenAPI definitions and converters for 'typia' and 'nestia'.", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index.js", |
@@ -48,3 +48,9 @@ # `@samchon/openapi` | ||
```typescript | ||
import { OpenApi, SwaggerV2, OpenApiV3, OpenApiV3_1 } from "@samchon/openapi"; | ||
import { | ||
OpenApi, | ||
SwaggerV2, | ||
OpenApiV3, | ||
OpenApiV3_1, | ||
IMigrateDocument, | ||
} from "@samchon/openapi"; | ||
@@ -68,2 +74,7 @@ // original Swagger/OpenAPI document | ||
OpenApi.downgrade(OpenApi.convert(v3), "2.0"); | ||
// also supports openapi generator libraries | ||
const migrate: IMigrateDocument = OpenApi.migrate( | ||
OpenApi.convert(input), | ||
); | ||
``` | ||
@@ -70,0 +81,0 @@ |
@@ -6,3 +6,3 @@ import { IMigrateRoute } from "../IMigrateRoute"; | ||
import { MigrateOperationConverter } from "./MigrateOperationConverter"; | ||
import { MigrateRouteNamespacer } from "./MigrateRouteNamespacer"; | ||
import { MigrateRouteAccessor } from "./MigrateRouteAccessor"; | ||
@@ -44,3 +44,3 @@ export namespace MigrateConverter { | ||
); | ||
MigrateRouteNamespacer.overwrite(operations); | ||
MigrateRouteAccessor.overwrite(operations); | ||
return { | ||
@@ -47,0 +47,0 @@ routes: operations, |
@@ -13,9 +13,2 @@ import { NamingConvention } from "typia/lib/utils/NamingConvention"; | ||
export const camel = (path: string) => | ||
splitWithNormalization(path) | ||
.map((str, i) => | ||
i === 0 ? NamingConvention.camel(str) : NamingConvention.pascal(str), | ||
) | ||
.join(""); | ||
export const splitWithNormalization = (path: string) => | ||
@@ -41,18 +34,2 @@ path | ||
export const commonPrefix = (strs: string[]): string => { | ||
if (strs.length === 0) return ""; | ||
let prefix = strs[0]; | ||
for (let i = 1; i < strs.length; i++) { | ||
while (strs[i].indexOf(prefix) !== 0) { | ||
prefix = prefix.substring(0, prefix.length - 1); | ||
if (prefix === "") return ""; | ||
} | ||
} | ||
return prefix | ||
.split("/") | ||
.filter((str) => str[0] !== "{" || str[str.length - 1] === "}") | ||
.join("/"); | ||
}; | ||
export const escapeDuplicate = | ||
@@ -62,45 +39,2 @@ (keep: string[]) => | ||
keep.includes(change) ? escapeDuplicate(keep)(`_${change}`) : change; | ||
export const escapeNonVariableSymbols = (str: string): string => { | ||
for (const [before, after] of VARIABLE_REPLACERS) | ||
str = str.split(before).join(after); | ||
for (let i: number = 0; i <= 9; ++i) | ||
if (str[0] === i.toString()) { | ||
str = "_" + str; | ||
break; | ||
} | ||
str = str.trim(); | ||
if (str === "") return "_empty_"; | ||
return str; | ||
}; | ||
} | ||
const VARIABLE_REPLACERS: [string, string][] = [ | ||
["`", "_backquote_"], | ||
["!", "_exclamation_"], | ||
["#", "_hash_"], | ||
["$", "_dollar_"], | ||
["%", "_percent_"], | ||
["^", "_caret_"], | ||
["&", "_and_"], | ||
["*", "_star_"], | ||
["(", "_lparen_"], | ||
[")", "_rparen_"], | ||
["-", "_minus_"], | ||
["+", "_plus_"], | ||
["|", "_or_"], | ||
["{", "_blt_"], | ||
["}", "_bgt_"], | ||
["<", "_lt_"], | ||
[">", "_gt_"], | ||
["[", "_alt_"], | ||
["]", "_agt_"], | ||
[",", "_comma_"], | ||
["'", "_singlequote_"], | ||
['"', "_doublequote_"], | ||
[" ", "_space_"], | ||
["?", "_question_"], | ||
[":", "_colon_"], | ||
[";", "_semicolon_"], | ||
["...", "_rest_"], | ||
]; |
86
296462
7317