Skip to content

Commit

Permalink
fix(): fix aliases issue (plugin)
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilmysliwiec committed Jan 28, 2020
1 parent 9847e4c commit cc93dfa
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
7 changes: 7 additions & 0 deletions lib/plugin/utils/plugin-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
getTypeArguments,
isArray,
isBoolean,
isEnum,
isInterface,
isNumber,
isString
Expand Down Expand Up @@ -69,6 +70,12 @@ export function getTypeReferenceAsString(
) {
return 'Object';
}
if (isEnum(type)) {
return undefined;
}
if (type.aliasSymbol) {
return 'Object';
}
return undefined;
} catch {
return undefined;
Expand Down
11 changes: 10 additions & 1 deletion test/plugin/fixtures/create-cat-alt.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,28 @@ interface Node {
id: number;
}
type AliasedType = {
type: string;
};
type NumberAlias = number;
export class CreateCatDto2 {
name: string;
age: number = 3;
tags: string[];
status: Status = Status.ENABLED;
readonly breed?: string;
nodes: Node[];
alias: AliasedType;
numberAlias: NumberAlias;
nested: {
first: string,
second: number,
status: Status,
tags: string[],
nodes: Node[]
alias: AliasedType,
numberAlias: NumberAlias,
}
}
`;
Expand All @@ -38,7 +47,7 @@ export class CreateCatDto2 {
this.status = Status.ENABLED;
}
static _OPENAPI_METADATA_FACTORY() {
return { name: { required: true, type: () => String }, age: { required: true, type: () => Number, default: 3 }, tags: { required: true, type: () => [String] }, status: { required: true, default: Status.ENABLED, enum: Status }, breed: { required: false, type: () => String }, nodes: { required: true, type: () => [Object] }, nested: { required: true, type: () => ({ first: { required: true, type: () => String }, second: { required: true, type: () => Number }, status: { required: true, enum: Status }, tags: { required: true, type: () => [String] }, nodes: { required: true, type: () => [Object] } }) } };
return { name: { required: true, type: () => String }, age: { required: true, type: () => Number, default: 3 }, tags: { required: true, type: () => [String] }, status: { required: true, default: Status.ENABLED, enum: Status }, breed: { required: false, type: () => String }, nodes: { required: true, type: () => [Object] }, alias: { required: true, type: () => Object }, numberAlias: { required: true, type: () => Number }, nested: { required: true, type: () => ({ first: { required: true, type: () => String }, second: { required: true, type: () => Number }, status: { required: true, enum: Status }, tags: { required: true, type: () => [String] }, nodes: { required: true, type: () => [Object] }, alias: { required: true, type: () => Object }, numberAlias: { required: true, type: () => Number } }) } };
}
}
`;

0 comments on commit cc93dfa

Please sign in to comment.