Is there an existing issue for this?
Current behavior
When using the same class name in different dto files, only one of them is correctly set inside components while the others are ignored. Even if it's non-exported class module.
For instance:
// foo.dto.ts
export class CustomResponse {
list: ListedPayload;
}
class ListedPayload {
foo: string;
}
// bar.dto.ts
export class AnotherResponse {
list: ListedPayload;
}
class ListedPayload {
bar: string;
}
This will generate the following schema:
"components": {
"schemas": {
"ListedPayload": {
"type": "object",
"properties": {
"foo": {
"type": "string"
}
},
"required": [
"foo"
]
},
"CustomResponse": {
"type": "object",
"properties": {
"list": {
"$ref": "#/components/schemas/ListedPayload"
}
},
"required": [
"list"
]
},
"AnotherResponse": {
"type": "object",
"properties": {
"list": {
"$ref": "#/components/schemas/ListedPayload"
}
},
"required": [
"list"
]
}
}
}
as you can see, ListedPayload of AnotherResponse does not exist.
Minimum reproduction code
https://stackblitz.com/edit/nestjs-typescript-starter-kl8vww1d?file=src%2Fapp.controller.ts
Steps to reproduce
- npm i & npm start
- go to /api/json
- see reproduction
Expected behavior
Either one of the following:
-
If there's more than one dto with the same name, we could prefix it with the parent class name, so for the previous example we would have CustomResponse_ListedPayload and AnotherResponse_ListedPayload, but this will only work for child dtos.
-
Print some warnings/errors about the existence of duplicate DTOs
Package version
11.1.2
NestJS version
11.0.2
Node.js version
20
In which operating systems have you tested?
Other
No response
Is there an existing issue for this?
Current behavior
When using the same class name in different dto files, only one of them is correctly set inside
componentswhile the others are ignored. Even if it's non-exported class module.For instance:
This will generate the following schema:
as you can see,
ListedPayloadofAnotherResponsedoes not exist.Minimum reproduction code
https://stackblitz.com/edit/nestjs-typescript-starter-kl8vww1d?file=src%2Fapp.controller.ts
Steps to reproduce
Expected behavior
Either one of the following:
If there's more than one dto with the same name, we could prefix it with the parent class name, so for the previous example we would have
CustomResponse_ListedPayloadandAnotherResponse_ListedPayload, but this will only work for child dtos.Print some warnings/errors about the existence of duplicate DTOs
Package version
11.1.2
NestJS version
11.0.2
Node.js version
20
In which operating systems have you tested?
Other
No response