Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting the name attribute results in a schema change #2951

Open
2 of 4 tasks
clintonb opened this issue May 16, 2024 · 2 comments
Open
2 of 4 tasks

Setting the name attribute results in a schema change #2951

clintonb opened this issue May 16, 2024 · 2 comments

Comments

@clintonb
Copy link
Contributor

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

Setting the name attribute on the ApiProperty decorator changes the generated OpenAPI JSON. For example, say I have a property named lane. If I do not set the name attribute, I get:

"lane": {
  "$ref": "#/components/schemas/NestedLaneDto"
}

If I do set the attribute, I get:

"lane": {
  "allOf": [
    {
      "$ref": "#/components/schemas/NestedLaneDto"
    }
  ]
}

These are roughly equivalent, but the allOf declaration can have issues as mentioned in #2948.

Minimum reproduction code

https://gist.github.com/clintonb/16195739bf913e636f9ef4ead4bbbbdb

Steps to reproduce

  1. Create a DTO that references another type/DTO.
  2. Set the name attribute on the ApiProperty decorator.

Expected behavior

The generated output should not change.

Package version

7.3.1

NestJS version

10.3.0

Node.js version

20.12.2

In which operating systems have you tested?

  • macOS
  • Windows
  • Linux

Other

No response

@clintonb
Copy link
Contributor Author

The root cause is the same as #2948. Moving the discussion there.

@clintonb clintonb closed this as not planned Won't fix, can't repro, duplicate, stale May 16, 2024
@clintonb clintonb reopened this May 16, 2024
@clintonb
Copy link
Contributor Author

Reopening because fixing this exact issue should be easier—require less OpenAPI spec research—than nullable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant