Skip to content

Commit d0636df

Browse files
committed
test: add test and simplify condition
1 parent 53e7b60 commit d0636df

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

packages/cli/src/metadataGeneration/parameterGenerator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ export class ParameterGenerator {
440440

441441
if (parameterType.dataType === 'union') {
442442
// skip undefined inside unions
443-
return !parameterType.types.map(t => t.dataType === 'undefined' ? true : this.supportPathDataType(t)).some(t => t === false);
443+
return !parameterType.types.map(t => t.dataType === 'undefined' || this.supportPathDataType(t)).some(t => t === false);
444444
}
445445

446446
return false;

tests/fixtures/controllers/getController.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,11 @@ export class GetTestController extends Controller {
327327
public async getIndexedValueGeneric(): Promise<IndexedValueGeneric<IndexedValueTypeReference>> {
328328
return 'FOO';
329329
}
330+
331+
@Get('UnionTypeWithDefault')
332+
public async getUnionTypeWithDefault(@Query() unionType: 'a' | 'b' | undefined = 'a'): Promise<void> {
333+
return;
334+
}
330335
}
331336

332337
export interface ErrorResponse {

0 commit comments

Comments
 (0)