nestia
nestia copied to clipboard
Prioritise custom schema in `TypedException` decorator
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:
current output:
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.
I don't know the exact reason why of the PR bug, but just send a PR to master branch please.
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.