nestia icon indicating copy to clipboard operation
nestia copied to clipboard

Prioritise custom schema in `TypedException` decorator

Open znycheporuk opened this issue 6 months ago • 2 comments

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.

znycheporuk avatar Dec 19 '23 22:12 znycheporuk

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

samchon avatar Jan 17 '24 16:01 samchon

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.

znycheporuk avatar Jan 22 '24 08:01 znycheporuk