Nested objects not working (in certain pattern)
See original GitHub issueI’m submitting a…
[ ] Regression
[X] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.
Current behavior
The “An object inside an array of object” structure isn’t presenting properly (both Example Values and Schema sections).
Here is my code structure:
// NewBookingDto.ts
export class NewBookingDto {
@ApiProperty({
description: "List of buyers",
type: [BuyerDto],
})
buyers: BuyerDto[];
}
...
// BuyerDto.ts
export class BuyerDto {
@ApiProperty({
description: "List of buyers' contact person",
type: BuyerContactPersonDto, // <-- Not okay; [BuyerContactPersonDto] <-- okay
})
buyer_contact_person: BuyerContactPersonDto;
}
I tried three nested structure, only first structure not working properly.
-
buyers[] -> buyer_contact_person - Not Okay
-
buyers[] -> buyer_contact_person[] - Okay
-
buyers -> buyer_contact_person - Okay
Expected behavior
It should works like other nested patterns.
Environment
Nest version:
"@nestjs/common": "^6.7.2",
"@nestjs/core": "^6.7.2",
"@nestjs/swagger": "^4.5.4"
For Tooling issues:
- Node version: v12.16.1
- Platform: MacOS
Issue Analytics
- State:
- Created 3 years ago
- Comments:13 (1 by maintainers)
Top Results From Across the Web
Crockford's Prototypal inheritance - Issues with nested objects
So I've tried using this in a project I'm working on, and I noticed an issue when attempting to inherit from objects that...
Read more >How to handle a bunch of nested ValueObjects?
I'm writing a PHP web application (or actually a Symfony module). One part of it is a nested structure of ValueObject s (meaning:...
Read more >Nested query | Elasticsearch Guide [8.5] | Elastic
Wraps another query to search nested fields. The nested query searches nested field objects as if they were indexed as separate documents.
Read more >Query nested objects in a document with unknown key
Hi,. I have a collection with many documents that do have a “item” property where the value is an object with key-value-pairs:
Read more >Object Fields VS. Nested Field Types in Elasticsearch - Opster
The problem with using object fields. To demonstrate the use of object fields vs. nested field types, we'll first index some documents.
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
I don’t know why this issue was closed but the problem persists. As @huypvw stated, the problem appears at the third level of a nested object.
Removing
description
property from @ApiProperty() seems to do the trick. A proper fix should be made.Hi, as a workaround you can remove
description
for this field. More info here https://github.com/nestjs/swagger/pull/842