Skip to content

Commit

Permalink
Fix HttpMigration.application() for void return typed operations.
Browse files Browse the repository at this point in the history
  • Loading branch information
samchon committed Oct 8, 2024
1 parent 4c57bd0 commit 140b407
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@samchon/openapi",
"version": "1.1.0",
"version": "1.1.1",
"description": "OpenAPI definitions and converters for 'typia' and 'nestia'.",
"main": "./lib/index.js",
"module": "./lib/index.mjs",
Expand Down
6 changes: 3 additions & 3 deletions src/converters/MigrateRouteConverter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ export namespace MigrateRouteConverter {
]),
required: [
...primitives.filter((p) => p.required).map((p) => p.name!),
...(dto ? dto.required ?? [] : []),
...(dto ? (dto.required ?? []) : []),
],
},
];
Expand Down Expand Up @@ -368,7 +368,7 @@ export namespace MigrateRouteConverter {
);
if (json) {
const { schema } = json[1];
return schema || from === "request"
return schema || from === "response"
? {
type: "application/json",
name: "body",
Expand All @@ -390,7 +390,7 @@ export namespace MigrateRouteConverter {
);
if (query) {
const { schema } = query[1];
return schema || from === "request"
return schema || from === "response"
? {
type: "application/x-www-form-urlencoded",
name: "body",
Expand Down
3 changes: 3 additions & 0 deletions test/controllers/AppController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ export class AppController {
},
};
}

@TypedRoute.Get("nothing")
public nothing(): void {}
}

interface IQuery {
Expand Down
18 changes: 18 additions & 0 deletions test/features/migrate/test_http_migrate_route_return_type_void.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { TestValidator } from "@nestia/e2e";
import {
HttpMigration,
IHttpMigrateApplication,
IHttpMigrateRoute,
OpenApi,
} from "@samchon/openapi";

import swagger from "../../swagger.json";

export const test_http_migrate_route_return_type_void = (): void => {
const document: OpenApi.IDocument = OpenApi.convert(swagger as any);
const app: IHttpMigrateApplication = HttpMigration.application(document);
const route: IHttpMigrateRoute | undefined = app.routes.find(
(r) => r.path === "/nothing" && r.method === "get",
);
TestValidator.equals("exists")(!!route)(true);
};
16 changes: 15 additions & 1 deletion test/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
}
],
"info": {
"version": "1.0.5",
"version": "1.1.1-dev.20241008-2",
"title": "@samchon/openapi",
"description": "OpenAPI definitions and converters for 'typia' and 'nestia'.",
"license": {
Expand Down Expand Up @@ -374,6 +374,20 @@
}
}
}
},
"/nothing": {
"get": {
"tags": [],
"parameters": [],
"responses": {
"200": {
"description": "",
"content": {
"application/json": {}
}
}
}
}
}
},
"components": {
Expand Down

0 comments on commit 140b407

Please sign in to comment.