Skip to content

Commit bdc130a

Browse files
Muhammad Salar KhanMuhammad Salar Khan
Muhammad Salar Khan
authored and
Muhammad Salar Khan
committedJan 26, 2024
fix: support type UUID from node's crypto package
1 parent e2b7142 commit bdc130a

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed
 

‎lib/plugin/utils/plugin-utils.ts

+3
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,9 @@ export function getTypeReferenceAsString(
115115
if (type.aliasSymbol) {
116116
return { typeName: 'Object', arrayDepth };
117117
}
118+
if (typeChecker.getApparentType(type).getSymbol().getEscapedName() === 'String') {
119+
return { typeName: String.name, arrayDepth };
120+
}
118121
return { typeName: undefined };
119122
} catch {
120123
return { typeName: undefined };

‎test/plugin/fixtures/create-cat.dto.ts

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export const createCatDtoText = `
2+
import { UUID } from 'crypto';
23
import { IsInt, IsString, IsPositive, IsNegative, Length, Matches, IsIn } from 'class-validator';
34
45
enum Status {
@@ -50,14 +51,18 @@ export class CreateCatDto {
5051
nodes: Node[];
5152
optionalBoolean?: boolean;
5253
date: Date;
53-
54+
5455
twoDimensionPrimitives: string[][];
5556
twoDimensionNodes: OtherNode[][];
5657
5758
@ApiHideProperty()
5859
hidden: number;
5960
6061
static staticProperty: string;
62+
63+
cryptoUUIDProperty: UUID;
64+
65+
arrayOfUUIDs: UUID[];
6166
}
6267
`;
6368

@@ -85,7 +90,7 @@ export class CreateCatDto {
8590
this.status = Status.ENABLED;
8691
}
8792
static _OPENAPI_METADATA_FACTORY() {
88-
return { isIn: { required: true, type: () => String, enum: ['a', 'b'] }, pattern: { required: true, type: () => String, pattern: "/^[+]?abc$/" }, name: { required: true, type: () => String }, age: { required: true, type: () => Number, default: 3, minimum: 0, maximum: 10 }, positive: { required: true, type: () => Number, default: 5, minimum: 1 }, negative: { required: true, type: () => Number, default: -1, maximum: -1 }, lengthMin: { required: true, type: () => String, minLength: 2 }, lengthMinMax: { required: true, type: () => String, minLength: 3, maxLength: 5 }, tags: { required: true, type: () => [String] }, status: { required: true, default: Status.ENABLED, enum: Status }, status2: { required: false, enum: Status }, statusArr: { required: false, enum: Status, isArray: true }, oneValueEnum: { required: false, enum: OneValueEnum }, oneValueEnumArr: { required: false, enum: OneValueEnum }, breed: { required: false, type: () => String, title: "this is breed im comment" }, nodes: { required: true, type: () => [Object] }, optionalBoolean: { required: false, type: () => Boolean }, date: { required: true, type: () => Date }, twoDimensionPrimitives: { required: true, type: () => [[String]] }, twoDimensionNodes: { required: true, type: () => [[OtherNode]] } };
93+
return { isIn: { required: true, type: () => String, enum: ['a', 'b'] }, pattern: { required: true, type: () => String, pattern: "/^[+]?abc$/" }, name: { required: true, type: () => String }, age: { required: true, type: () => Number, default: 3, minimum: 0, maximum: 10 }, positive: { required: true, type: () => Number, default: 5, minimum: 1 }, negative: { required: true, type: () => Number, default: -1, maximum: -1 }, lengthMin: { required: true, type: () => String, minLength: 2 }, lengthMinMax: { required: true, type: () => String, minLength: 3, maxLength: 5 }, tags: { required: true, type: () => [String] }, status: { required: true, default: Status.ENABLED, enum: Status }, status2: { required: false, enum: Status }, statusArr: { required: false, enum: Status, isArray: true }, oneValueEnum: { required: false, enum: OneValueEnum }, oneValueEnumArr: { required: false, enum: OneValueEnum }, breed: { required: false, type: () => String, title: "this is breed im comment" }, nodes: { required: true, type: () => [Object] }, optionalBoolean: { required: false, type: () => Boolean }, date: { required: true, type: () => Date }, twoDimensionPrimitives: { required: true, type: () => [[String]] }, twoDimensionNodes: { required: true, type: () => [[OtherNode]] }, cryptoUUIDProperty: { required: true, type: () => String }, arrayOfUUIDs: { required: true, type: () => [String] } };
8994
}
9095
}
9196
__decorate([

0 commit comments

Comments
 (0)
Please sign in to comment.