Skip to content

Commit

Permalink
Merge pull request #846 from samchon/features/m
Browse files Browse the repository at this point in the history
Discard swagger v2 supporting from `@nestia/migrate`.
  • Loading branch information
samchon authored Mar 25, 2024
2 parents d4ab886 + 92f36c8 commit 5062796
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 240 deletions.
222 changes: 0 additions & 222 deletions packages/migrate/assets/input/swaggerv2.0.json

This file was deleted.

5 changes: 1 addition & 4 deletions packages/migrate/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nestia/migrate",
"version": "0.11.1",
"version": "0.11.3",
"description": "Migration program from swagger to NestJS",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
Expand Down Expand Up @@ -45,7 +45,6 @@
"@types/express": "^4.17.21",
"@types/inquirer": "^9.0.7",
"@types/node": "^20.3.3",
"@types/swagger2openapi": "^7.0.4",
"dotenv": "^16.3.1",
"dotenv-expand": "^10.0.0",
"rimraf": "^5.0.1",
Expand All @@ -56,12 +55,10 @@
"typescript-transform-paths": "^3.4.6"
},
"dependencies": {
"@apiture/openapi-down-convert": "^0.13.0",
"commander": "10.0.0",
"inquirer": "8.2.5",
"openapi-types": "^12.1.3",
"prettier": "^3.2.5",
"swagger2openapi": "^7.0.8",
"tstl": "^2.5.13",
"typescript": "^5.4.2",
"typia": "^5.5.7"
Expand Down
11 changes: 4 additions & 7 deletions packages/migrate/src/MigrateApplication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,18 @@ import { MigrateNestProgrammer } from "./programmers/MigrateNestProgrammer";
import { IMigrateFile } from "./structures/IMigrateFile";
import { IMigrateProgram } from "./structures/IMigrateProgram";
import { ISwagger } from "./structures/ISwagger";
import { ISwaggerV20 } from "./structures/ISwaggerV20";
import { ISwaggerV31 } from "./structures/ISwaggerV31";
import { OpenApiConverter } from "./utils/OpenApiConverter";

export class MigrateApplication {
private constructor(public readonly swagger: ISwagger) {}

public static async create(
swagger: ISwagger | ISwaggerV20 | ISwaggerV31,
swagger: ISwagger | ISwaggerV31,
): Promise<IValidation<MigrateApplication>> {
swagger = typia.is<ISwaggerV20.IVersion>(swagger)
? await OpenApiConverter.v2_0(swagger)
: typia.is<ISwaggerV31.IVersion>(swagger)
? OpenApiConverter.v3_1(swagger)
: swagger;
swagger = typia.is<ISwaggerV31.IVersion>(swagger)
? OpenApiConverter.v3_1(swagger)
: swagger;
const result = typia.validate<ISwagger>(swagger);
if (result.success === false) return result;
return {
Expand Down
12 changes: 6 additions & 6 deletions packages/migrate/src/utils/OpenApiConverter.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import V2_0Converter from "swagger2openapi";
// import V2_0Converter from "swagger2openapi";
import typia from "typia";

import { ISwagger } from "../structures/ISwagger";
import { ISwaggerV20 } from "../structures/ISwaggerV20";
// import { ISwaggerV20 } from "../structures/ISwaggerV20";
import { ISwaggerV31 } from "../structures/ISwaggerV31";
import { Converter as V3_1Converter } from "./openapi-down-convert/converter";

export namespace OpenApiConverter {
export const v2_0 = async (swagger: ISwaggerV20): Promise<ISwagger> => {
const output = await V2_0Converter.convertObj(swagger, {});
return typia.assert<ISwagger>(output.openapi);
};
// export const v2_0 = async (swagger: ISwaggerV20): Promise<ISwagger> => {
// const output = await V2_0Converter.convertObj(swagger, {});
// return typia.assert<ISwagger>(output.openapi);
// };

export const v3_1 = (swagger: ISwaggerV31): ISwagger => {
const converter = new V3_1Converter(swagger);
Expand Down
2 changes: 1 addition & 1 deletion website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"@mui/icons-material": "5.15.6",
"@mui/material": "5.15.6",
"@mui/system": "5.15.6",
"@nestia/migrate": "^0.11.1",
"@nestia/migrate": "^0.11.3",
"@stackblitz/sdk": "^1.9.0",
"js-yaml": "^4.1.0",
"next": "14.1.0",
Expand Down
4 changes: 4 additions & 0 deletions website/pages/docs/editor.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ import { Callout } from 'nextra-theme-docs'
import EditorMovie from "../../src/movies/editor/EditorMovie";

## TypeScript Swagger Editor
<Callout>
Supports OpenAPI v3.0 / v3.1
</Callout>

<EditorMovie mode="sdk" />

> Put your `swagger.json` file, then "TypeScript Swagger Editor" be opened.
Expand Down
4 changes: 4 additions & 0 deletions website/pages/docs/migrate.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ import EditorMovie from "../../src/movies/editor/EditorMovie";

# Migration from Swagger
## Outline
<Callout>
Supports OpenAPI v3.0 / v3.1
</Callout>

```bash filename="Terminal" copy showLineNumbers {}
npx @nestia/migrate
```
Expand Down

0 comments on commit 5062796

Please sign in to comment.