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

Prioritise custom schema in TypedException decorator #725

Open
znycheporuk opened this issue Dec 19, 2023 · 2 comments
Open

Prioritise custom schema in TypedException decorator #725

znycheporuk opened this issue Dec 19, 2023 · 2 comments
Assignees
Labels
help wanted Extra attention is needed

Comments

@znycheporuk
Copy link

Bug Report / Improvement

Summary

Right now for 200/201 status codes nestia overrides TypedException decorator data, setting default values instead of provided ones.

Example

  @TypedException<Resources.GetAll>(200, "Get resources")
  @TypedRoute.Get()
  async getResources(
    @TypedQuery() query: ResourceQuery & RequestPagination,
  ): SuccessResponse<Resource> {...}

expected output:
image

current output:
image

Code occuring the bug

It happens because SwaggerSchemaGenerator firstly parses TypedException decorators, then comment tags and previous output is overriden by default values (only 200 status for GET, HEAD, DELETE methods, and 201 for POST, PUT, PATCH), so if you provide TypedException for 200 or 201 status, it will be overriden.

To fix this, all we need to do is to move default checks before the custom ones (move lines 102-155 to line 32) in SwaggerSchemaGenerator.ts

P.S. I tried to create PR, but got permission denied when tried to push new branch to origin.

@samchon
Copy link
Owner

samchon commented Jan 17, 2024

I don't know the exact reason why of the PR bug, but just send a PR to master branch please.

@samchon samchon self-assigned this Jan 17, 2024
@samchon samchon added the help wanted Extra attention is needed label Jan 17, 2024
@znycheporuk
Copy link
Author

Looks like repo is readonly, so I can't create a PR

$ git push --set-upstream origin nestia/sdk/swagger/prefer-custom-schema
ERROR: Permission to samchon/nestia.git denied to znycheporuk.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants