You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
enumTestEnum{A="A",B="B"}classEnumTest{
@ApiProperty({enum: TestEnum,enumName: 'TestEnum',isArray: true,description: 'testEnum of EnumTest'default: [],})readonlytestEnum: TestEnum[]=[];}classAnotherEnumTest{
@ApiProperty({enum: TestEnum,enumName: 'TestEnum',isArray: true,description: 'testEnum of AnotherEnumTest'})readonlytestEnum: TestEnum[]=[]}
But I got the yaml as below.
components:
schemas:
TestEnum:
type: stringdefault: [] # It cause error on openAPI specification.description: testEnum of AnotherEnumTestenum:
- A
- B# .....EnumTesttype: objectproperties:
testEnum:
type: arrayitems:
$ref: "#/components/schemas/TestEnum"AnotherEnumTesttype: objectproperties:
testEnum:
type: arrayitems:
$ref: "#/components/schemas/TestEnum"
I know that ['description', 'deprecated', 'default'] can be declared as a field of specific properties. I think that It does not seem appropriate to omit these three fields on EnumTest definition and declare metadata of EnumTest's property on TestEnum's schema.
Declare ApiProperty with the same enumName in different classes.
Inside the decorator, we use additionalProperties such as description, default, etc. that go from openAPI schema to enum's.
Values such as description or default that you want to apply to the field of the class to which the API property decorator is applied are applied as the field of the top schema, and if multiple additional fields are attached to the same enumName, this is overwritten.
You'd expect the options in Api Property to be basically a description of the field in that class, but unfortunately it doesn't work that way.
Expected behavior
A class called EnumTest has a property called testEnum, which expects TestEnum to enter the form of an array.
If so, I want the yaml as below.
components:
schemas:
TestEnum:
type: stringenum:
- A
- B# .....EnumTesttype: objectproperties:
testEnum:
type: arraydefault: [],description: testEnum of EnumTestitems:
$ref: "#/components/schemas/TestEnum"AnotherEnumTesttype: objectproperties:
testEnum:
type: arraydefault: []description: testEnum of AnotherEnumTestitems:
$ref: "#/components/schemas/TestEnum"
In my opinion, if we want to field description and default for enum, it looks good to create another field that is isolated from property.
Is there an existing issue for this?
Current behavior
I declared dto as below.
But I got the yaml as below.
I know that
['description', 'deprecated', 'default']
can be declared as a field of specific properties. I think that It does not seem appropriate to omit these three fields on EnumTest definition and declare metadata of EnumTest's property on TestEnum's schema.Minimum reproduction code
https://gist.github.com/0816i/67866e4c94fe0825282b53cde8de3d16
Steps to reproduce
Expected behavior
A class called EnumTest has a property called testEnum, which expects TestEnum to enter the form of an array.
If so, I want the yaml as below.
In my opinion, if we want to field description and default for enum, it looks good to create another field that is isolated from property.
Package version
7.4.2
NestJS version
10.4.1
Node.js version
20.12.0
In which operating systems have you tested?
Other
It relate on #2816
Please reconsider your decision on using the additional field for enum.
The text was updated successfully, but these errors were encountered: