question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Nested objects not working (in certain pattern)

See original GitHub issue

I’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.

  1. buyers[] -> buyer_contact_person - Not Okay Screenshot 2020-05-06 at 11 16 42 AM

  2. buyers[] -> buyer_contact_person[] - Okay Screenshot 2020-05-06 at 11 17 19 AM

  3. buyers -> buyer_contact_person - Okay Screenshot 2020-05-06 at 11 35 08 AM

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:closed
  • Created 3 years ago
  • Comments:13 (1 by maintainers)

github_iconTop GitHub Comments

8reactions
manuelnuccicommented, Oct 9, 2020

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.

1reaction
minenkomcommented, Jul 9, 2020

Is this solved?? I faced this issue @nestjs/common: "^6.7.2",,,

I’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.

  1. buyers[] -> buyer_contact_person - Not Okay
Screenshot 2020-05-06 at 11 16 42 AM
  1. buyers[] -> buyer_contact_person[] - Okay
Screenshot 2020-05-06 at 11 17 19 AM
  1. buyers -> buyer_contact_person - Okay
Screenshot 2020-05-06 at 11 35 08 AM

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

Hi, as a workaround you can remove description for this field. More info here https://github.com/nestjs/swagger/pull/842

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found