Setting the name attribute results in a schema change
clintonb opened this issue · 3 comments
clintonb commented
Is there an existing issue for this?
- I have searched the existing issues
Current behavior
Setting the name
attribute on the ApiProperty
decorator changes the generated OpenAPI JSON. For example, say I have a property named lane
. If I do not set the name
attribute, I get:
"lane": {
"$ref": "#/components/schemas/NestedLaneDto"
}
If I do set the attribute, I get:
"lane": {
"allOf": [
{
"$ref": "#/components/schemas/NestedLaneDto"
}
]
}
These are roughly equivalent, but the allOf
declaration can have issues as mentioned in #2948.
Minimum reproduction code
https://gist.github.com/clintonb/16195739bf913e636f9ef4ead4bbbbdb
Steps to reproduce
- Create a DTO that references another type/DTO.
- Set the
name
attribute on theApiProperty
decorator.
Expected behavior
The generated output should not change.
Package version
7.3.1
NestJS version
10.3.0
Node.js version
20.12.2
In which operating systems have you tested?
- macOS
- Windows
- Linux
Other
No response
clintonb commented
Reopening because fixing this exact issue should be easier—require less OpenAPI spec research—than nullable
.