Skip to content

Commit 30bc2e1

Browse files
authored
Merge pull request #1438 from simllll/patch-1
fix: ignore undefined inside unions in supportPathDataType
2 parents 6380e48 + d0636df commit 30bc2e1

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

packages/cli/src/metadataGeneration/parameterGenerator.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,8 @@ export class ParameterGenerator {
439439
}
440440

441441
if (parameterType.dataType === 'union') {
442-
return !parameterType.types.map(t => this.supportPathDataType(t)).some(t => t === false);
442+
// skip undefined inside unions
443+
return !parameterType.types.map(t => t.dataType === 'undefined' || this.supportPathDataType(t)).some(t => t === false);
443444
}
444445

445446
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)