`extends` broken for DTOs
See original GitHub issueusing extends
in DTO classes appears to be broken between 1.2.2 and 1.3.0.
minimal example:
class foo {
@ApiModelPropertyOptional()
public prop?: string;
};
class bar extends foo {
@ApiModelPropertyOptional()
public otherProp?: string;
}
@Controller("leads")
@ApiProduces("application/json; charset=utf-8")
export class LeadsController {
constructor() {}
@Get()
@ApiResponse({ status: 200, type: bar })
public find(): bar {
return {
prop: "asdf",
otherProp: "asdf"
}
}
}
using this controller, I get an error in swagger-ui: Uncaught ReferenceError: foo is not defined.
The generated swagger actually looks correct:
"paths": {
"/leads": {
"get": {
"responses": {
"200": {
"description": "",
"schema": {
"$ref": "#/definitions/bar"
}
}
},
"produces": [
"application/json"
],
"consumes": [
"application/json"
]
}
}
},
"definitions": {
"bar": {
"type": "object",
"properties": {
"prop": {
"type": "string"
},
"otherProp": {
"type": "string"
}
}
}
}
but when swagger ui tries to consume it, it looks like this:
None of the recent changes look immediately obvious as the problem - any ideas?
Issue Analytics
- State:
- Created 5 years ago
- Reactions:3
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Domain Object extends Data Transfer Object
Main purpose of using DTO is to pass it to View. I've extended it in Customer class not to have duplication of properties....
Read more >DTO Inheritance not working properly Nestjs · Issue #1067 ...
I am trying to Implement inheritance in my DTOs and validate the derived classes. The inheritance is fully working with a factory class, ......
Read more >Use composition and inheritance for DTOs
I use inheritance with DTOs inside the same layer or same context. A DTO will never inherit from a POCO, a BLL DTO...
Read more >Rethinking the Java DTO
A DTO is a server-side value object which stores data using the presentation layer representation. We separate DTOs into those received by the ......
Read more >Complexity, Services and Role of DTOs | Documentation
I'd typically use discrete DTOs for Service Responses as it allows freely extending existing Services to return extra data or metadata without breaking...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Got the exact same problem with v2.0.0
Fixed in
2.0.1