Skip to content

Custom type is not retained as type, but rewritten as allOf: - $ref: ... breaking nullable: true spec in @ApiProperty #2948

@gregoryorton-ws

Description

@gregoryorton-ws

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

Custom type is not retained as type, but rewritten as allOf: - $ref: ... breaking nullable: true spec in @ApiProperty

In @ApiProperty when using something like:

@ApiProperty({ nullable: true, type: MyCustomDto })
readonly myVar: MyCustomDto | null;
...

the rendered openapi.yaml is like:

myVar:
  nullable: true
  allOf:
     - $ref: "#/components/schemas/MyCustomDto"

tools like Redoc.ly then start to throw errors:

image

Minimum reproduction code

https://nothing.com

Steps to reproduce

see above

Expected behavior

myVar:
  type: object
  properties:
    id:
      type: integer

Package version

7.3.0

NestJS version

10.3.3

Node.js version

20

In which operating systems have you tested?

  • macOS
  • Windows
  • Linux

Other

maybe related: #2645
maybe related: #2646

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions