@nestia/migrate
Advanced tools
Comparing version 0.13.12 to 0.13.13
@@ -10,2 +10,3 @@ "use strict"; | ||
const MapUtil_1 = require("../utils/MapUtil"); | ||
const StringUtil_1 = require("../utils/StringUtil"); | ||
const MigrateSchemaProgrammer_1 = require("./MigrateSchemaProgrammer"); | ||
@@ -17,4 +18,10 @@ var MigrateDtoProgrammer; | ||
const dict = new Map(); | ||
for (const [key, value] of Object.entries((_a = components.schemas) !== null && _a !== void 0 ? _a : {})) | ||
prepare(dict)(key)((importer) => writeAlias(components)(importer)(key, value)); | ||
for (const [key, value] of Object.entries((_a = components.schemas) !== null && _a !== void 0 ? _a : {})) { | ||
const emendedKey = key | ||
.split("/") | ||
.filter((str) => str.length !== 0) | ||
.map(StringUtil_1.StringUtil.escapeNonVariableSymbols) | ||
.join(""); | ||
prepare(dict)(emendedKey)((importer) => writeAlias(components)(importer)(emendedKey, value)); | ||
} | ||
return dict; | ||
@@ -21,0 +28,0 @@ }; |
@@ -14,2 +14,3 @@ "use strict"; | ||
const OpenApiTypeChecker_1 = require("../utils/OpenApiTypeChecker"); | ||
const StringUtil_1 = require("../utils/StringUtil"); | ||
var MigrateSchemaProgrammer; | ||
@@ -273,6 +274,11 @@ (function (MigrateSchemaProgrammer) { | ||
return TypeFactory_1.TypeFactory.keyword("any"); | ||
const name = schema.$ref.split("/").at(-1); | ||
return name === "" | ||
? TypeFactory_1.TypeFactory.keyword("any") | ||
: importer.dto(schema.$ref.split("/").at(-1)); | ||
const name = schema.$ref | ||
.split("/") | ||
.slice(3) | ||
.filter((str) => str.length !== 0) | ||
.map(StringUtil_1.StringUtil.escapeNonVariableSymbols) | ||
.join(""); | ||
if (name === "") | ||
return TypeFactory_1.TypeFactory.keyword("any"); | ||
return importer.dto(name); | ||
}; | ||
@@ -279,0 +285,0 @@ /* ----------------------------------------------------------- |
@@ -10,2 +10,3 @@ export declare namespace StringUtil { | ||
const escapeDuplicate: (keep: string[]) => (change: string) => string; | ||
const escapeNonVariableSymbols: (str: string) => string; | ||
} |
@@ -44,3 +44,36 @@ "use strict"; | ||
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); | ||
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_"], | ||
]; | ||
//# sourceMappingURL=StringUtil.js.map |
{ | ||
"name": "@nestia/migrate", | ||
"version": "0.13.12", | ||
"version": "0.13.13", | ||
"description": "Migration program from swagger to NestJS", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -21,3 +21,3 @@ # Nestia | ||
> **Note** | ||
> [!NOTE] | ||
> | ||
@@ -24,0 +24,0 @@ > - **Only one line** required, with pure TypeScript type |
@@ -7,2 +7,3 @@ import { OpenApi } from "@samchon/openapi"; | ||
import { MapUtil } from "../utils/MapUtil"; | ||
import { StringUtil } from "../utils/StringUtil"; | ||
import { MigrateImportProgrammer } from "./MigrateImportProgrammer"; | ||
@@ -24,6 +25,12 @@ import { MigrateSchemaProgrammer } from "./MigrateSchemaProgrammer"; | ||
const dict: Map<string, IModule> = new Map(); | ||
for (const [key, value] of Object.entries(components.schemas ?? {})) | ||
prepare(dict)(key)((importer) => | ||
writeAlias(components)(importer)(key, value), | ||
for (const [key, value] of Object.entries(components.schemas ?? {})) { | ||
const emendedKey: string = key | ||
.split("/") | ||
.filter((str) => str.length !== 0) | ||
.map(StringUtil.escapeNonVariableSymbols) | ||
.join(""); | ||
prepare(dict)(emendedKey)((importer) => | ||
writeAlias(components)(importer)(emendedKey, value), | ||
); | ||
} | ||
return dict; | ||
@@ -30,0 +37,0 @@ }; |
@@ -10,2 +10,3 @@ import { OpenApi } from "@samchon/openapi"; | ||
import { OpenApiTypeChecker } from "../utils/OpenApiTypeChecker"; | ||
import { StringUtil } from "../utils/StringUtil"; | ||
import { MigrateImportProgrammer } from "./MigrateImportProgrammer"; | ||
@@ -325,6 +326,10 @@ | ||
return TypeFactory.keyword("any"); | ||
const name: string = schema.$ref.split("/").at(-1)!; | ||
return name === "" | ||
? TypeFactory.keyword("any") | ||
: importer.dto(schema.$ref.split("/").at(-1)!); | ||
const name: string = schema.$ref | ||
.split("/") | ||
.slice(3) | ||
.filter((str) => str.length !== 0) | ||
.map(StringUtil.escapeNonVariableSymbols) | ||
.join(""); | ||
if (name === "") return TypeFactory.keyword("any"); | ||
return importer.dto(name); | ||
}; | ||
@@ -331,0 +336,0 @@ |
@@ -60,2 +60,37 @@ import { NamingConvention } from "typia/lib/utils/NamingConvention"; | ||
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); | ||
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_"], | ||
]; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
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 too big to display
Sorry, the diff of this file is too big to display
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
1501056
16928