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

Swagger is not showing extended properties #2946

Open
2 of 4 tasks
kasir-barati opened this issue May 10, 2024 · 7 comments
Open
2 of 4 tasks

Swagger is not showing extended properties #2946

kasir-barati opened this issue May 10, 2024 · 7 comments

Comments

@kasir-barati
Copy link

kasir-barati commented May 10, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

Extending a class with custom properties does not work.

DTO: https://github.com/kasir-barati/you-say/blob/main/apps/backend/src/modules/post/dto/find-all-query.dto.ts#L8

Generated swagger docs:

image

Similar past issue: #518

Minimum reproduction code

https://github.com/kasir-barati/you-say

Steps to reproduce

  1. npm ci
  2. cp .env.example .env
  3. npx nx dev backend

Open your browser and go to localhost:3001/docs

Expected behavior

Show both properties, extended one from PaginationDto and custom one (createdAt).

Package version

7.3.1

NestJS version

10.3.7

Node.js version

20.10.0

In which operating systems have you tested?

  • macOS
  • Windows
  • Linux

Other

No response

@kasir-barati
Copy link
Author

Right now - trying to fix this issue - I'll upgrade packages version to see if that can help. Although I am skeptical about it.

@kasir-barati
Copy link
Author

kasir-barati commented May 10, 2024

Faced tons of dependency conflicts :/.

code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: you-say@0.0.1
npm ERR! Found: eslint@9.2.0
npm ERR! node_modules/eslint
npm ERR!   dev eslint@"9.2.0" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer eslint@"^8.56.0" from @typescript-eslint/parser@7.8.0
npm ERR! node_modules/@typescript-eslint/parser
npm ERR!   dev @typescript-eslint/parser@"7.8.0" from the root project
npm ERR!   peer @typescript-eslint/parser@"^6.13.2 || ^7.0.0" from @nx/eslint-plugin@19.0.2
npm ERR!   node_modules/@nx/eslint-plugin
npm ERR!     dev @nx/eslint-plugin@"19.0.2" from the root project
npm ERR! 
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR! 
npm ERR! 
npm ERR! For a full report see:
npm ERR! /home/kasir/.npm/_logs/2024-05-10T11_04_49_215Z-eresolve-report.txt

npm ERR! A complete log of this run can be found in: /home/kasir/.npm/_logs/2024-05-10T11_04_49_215Z-debug-0.log

Probably not the smartest move I could make 😅.

Also it did not change @nestjs/swagger version but did change some other packages. Still evaluating it. If it did not work, will undo changes since they are really big and I am in the middle of something 🙂.

@kasir-barati
Copy link
Author

kasir-barati commented May 10, 2024

It broke my Dockerfile like I suspected. So for now I am back to normal -- I reverted package.json and package-lock.json.

@kasir-barati
Copy link
Author

That's weird, I just noticed that according to Git it was part of the doc but for some reason it was removed and when I added new prop to @ApiPorperty decorator it just recreated it in openApi.json file :/

image
Is it really confusing since here I am creating the openApi.json file and I cannot shake the feeling that something is not right with @nestjs/swagger. I mean this helper function utilizes createSwaggerConfiguration and there we are only using DocumentBuilder to build the open API specification 😖.

Not sure what is wrong, but all of that aside we still have this behavior of swagger missing extended props.

@kasir-barati
Copy link
Author

But before adding example it was removed completely :/.

@kasir-barati
Copy link
Author

Here is my broken pipeline: https://github.com/kasir-barati/you-say/actions/runs/9023506806/job/24795454676

Not sure why but it is clear that the integration test failed due to the fact that openApi.json had not limit and page this time around while a few weeks or days ago it was passing.

@kasir-barati
Copy link
Author

Feel free to close this issue if it did not happen to you. It happened in my local env and pipeline once but I am not sure why and how adding a simple example kasir-barati/you-say@b902305 fixed the issue.

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