Skip to content

Commit

Permalink
Merge pull request #881 from samchon/features/any
Browse files Browse the repository at this point in the history
Support `anyOf` and `webhook` types in the `@nestia/migrate`
  • Loading branch information
samchon committed Apr 21, 2024
2 parents 3e75834 + 411deee commit 7cb7bb6
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 13 deletions.
50 changes: 50 additions & 0 deletions packages/migrate/assets/input/v3.1/webhook.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"openapi": "3.1.0",
"info": {
"title": "Webhook Example",
"version": "1.0.0"
},
"webhooks": {
"newPet": {
"post": {
"requestBody": {
"description": "Information about a new pet in the system",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Pet"
}
}
}
},
"responses": {
"200": {
"description": "Return a 200 status to indicate that the data was received successfully"
}
}
}
}
},
"components": {
"schemas": {
"Pet": {
"required": [
"id",
"name"
],
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
},
"tag": {
"type": "string"
}
}
}
}
}
}
6 changes: 3 additions & 3 deletions packages/migrate/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nestia/migrate",
"version": "0.13.8",
"version": "0.13.9",
"description": "Migration program from swagger to NestJS",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
Expand Down Expand Up @@ -58,12 +58,12 @@
"typescript-transform-paths": "^3.4.6"
},
"dependencies": {
"@samchon/openapi": "^0.1.18",
"@samchon/openapi": "^0.1.19",
"commander": "10.0.0",
"inquirer": "8.2.5",
"prettier": "^3.2.5",
"tstl": "^3.0.0",
"typescript": "^5.4.3",
"typescript": "^5.4.5",
"typia": "^6.0.3"
},
"files": [
Expand Down
22 changes: 14 additions & 8 deletions packages/migrate/src/analyzers/MigrateControllerAnalyzer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ export namespace MigrateControllerAnalyzer {
const endpoints: Map<string, IEntry[]> = new Map();

// GATHER ROUTES
for (const [path, collection] of Object.entries(
props.document.paths ?? {},
)) {
for (const [path, collection] of [
...Object.entries(props.document.paths ?? {}),
...Object.entries(props.document.webhooks ?? {}),
]) {
if (collection === undefined) continue;

// PREPARE DIRECTORIES
Expand All @@ -42,11 +43,16 @@ export namespace MigrateControllerAnalyzer {
path,
method,
})(value as OpenApi.IOperation);
if (r === null) continue;
routes.push({
endpoint: value as OpenApi.IOperation,
route: r,
});
if (
r !== null &&
routes.find(
(x) => x.route.method === r.method && x.route.path === r.path,
) === undefined
)
routes.push({
endpoint: value as OpenApi.IOperation,
route: r,
});
}
}

Expand Down
4 changes: 2 additions & 2 deletions 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.13.8",
"@nestia/migrate": "^0.13.9",
"@samchon/openapi": "^0.1.18",
"@stackblitz/sdk": "^1.9.0",
"js-yaml": "^4.1.0",
Expand All @@ -43,6 +43,6 @@
"gh-pages": "^5.0.0",
"next-sitemap": "^4.2.3",
"rimraf": "^5.0.0",
"typescript": "^5.4.2"
"typescript": "^5.4.5"
}
}

0 comments on commit 7cb7bb6

Please sign in to comment.