-
Notifications
You must be signed in to change notification settings - Fork 578
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: ensure compatibility with Swagger response schema and fix the pa…
…rsing of enum types (#4083) * fix: swagger schema and enum value * fix: build * fix: test
- Loading branch information
1 parent
898a6a7
commit 1dc6803
Showing
10 changed files
with
170 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/swagger/src/decorators/api-exclude-controller.decorator.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import { getEnumValues } from "../src/common/enum.utils"; | ||
|
||
describe('/test/util.test.ts', () => { | ||
it('test enum get values', () => { | ||
enum StatusEnum { | ||
Disabled, | ||
Enabled, | ||
} | ||
|
||
expect(getEnumValues(StatusEnum)).toEqual([0, 1]); | ||
|
||
enum StatusEnum2 { | ||
Disabled = 'disabled', | ||
Enabled = 'enabled', | ||
} | ||
|
||
expect(getEnumValues(StatusEnum2)).toEqual(['disabled', 'enabled']); | ||
|
||
enum StatusEnum3 { | ||
Disabled = 1, | ||
Enabled = 2, | ||
} | ||
|
||
expect(getEnumValues(StatusEnum3)).toEqual([1, 2]); | ||
|
||
enum StatusEnum4 { | ||
Disabled = 'disabled', | ||
Enabled = 2, | ||
} | ||
|
||
expect(getEnumValues(StatusEnum4)).toEqual(['disabled', 2]); | ||
|
||
enum StatusEnum5 { | ||
Disabled = 2, | ||
Enabled = 'enabled', | ||
} | ||
|
||
expect(getEnumValues(StatusEnum5)).toEqual([2, 'enabled']); | ||
|
||
enum StatusEnum6 { | ||
Disabled = '1', | ||
Enabled = 2, | ||
} | ||
|
||
expect(getEnumValues(StatusEnum6)).toEqual(['1', 2]); | ||
|
||
enum StatusEnum7 { | ||
Disabled = 3, | ||
Enabled, | ||
} | ||
|
||
expect(getEnumValues(StatusEnum7)).toEqual([3, 4]); | ||
|
||
enum StatusEnum8 { | ||
Disabled = 1, | ||
Enabled = 1, | ||
} | ||
|
||
expect(getEnumValues(StatusEnum8)).toEqual([1]); | ||
|
||
expect(getEnumValues('test')).toEqual([]); | ||
expect(getEnumValues([1])).toEqual([1]); | ||
expect(getEnumValues([])).toEqual([]); | ||
}); | ||
|
||
}); |