feat(auth): document refresh endpoint response dto#368
Merged
vic-Gray merged 2 commits intoMay 29, 2026
Conversation
Add token_type field to TokenResponseDto and the refresh() service method. The OAuth 2.0 convention requires token_type: 'Bearer' in token responses so that consumers know how to send the token in the Authorization header. Previously this field was absent from both the service response and the DTO, leaving API consumers to infer the token type from convention alone. Changes: - TokenResponseDto: add token_type field with ApiProperty decorator documenting its value and usage - auth.service.ts refresh(): return token_type: 'Bearer' alongside access_token; also add explicit User | null type annotation to fix a pre-existing build error in the resetPassword method - auth.controller.ts: add missing @apiresponse({ status: 400 }) decorator to the refresh endpoint; Prettier formatting applied - auth.service.spec.ts: assert token_type === 'Bearer' in the refresh success test; fix resetPassword tests to use find mock instead of the incorrect findOne mock Fixes code-flexing#317 Fixes #614
|
@Depo-dev is attempting to deploy a commit to the vic's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
@Depo-dev Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The
POST /auth/refreshendpoint'sTokenResponseDtowas missing thetoken_typefield. Per OAuth 2.0 convention (RFC 6750), token responses should includetoken_type: "Bearer"so that consumers know how to send the token in theAuthorizationheader. Without it, API consumers had to infer the token type from convention alone, with no contract to rely on.DTO Changes Made
dto/auth-response.dto.ts—TokenResponseDtotoken_type: stringfield with full@ApiPropertydecorator documenting its value ("Bearer") and purposeauth.service.ts—refresh()method{ access_token, token_type: 'Bearer' }so the actual response matches the DTO contractUser | nullannotation on theresetPasswordloop accumulator (was causingTS2322understrictNullChecks)auth.controller.ts—POST /auth/refresh@ApiResponse({ status: 400 })decorator to document validation errors whenrefresh_tokenis missing or malformed (consistent with how/registerdocuments its 400 responses)Swagger / Response-field Verification
Before this change, the Swagger schema for
POST /auth/refreshshowed onlyaccess_token. After, it shows bothaccess_tokenandtoken_type, and the service response matches the schema exactly.Tests Added/Updated
auth.service.spec.tsAdded assertion:
expect(result).toHaveProperty('token_type', 'Bearer')to the refresh success testFixed
resetPasswordtests to usefindmock (was incorrectly mockingfindOne)npx jest auth.service.spec.ts— 12/12 passingnpm run build— cleanFixes #317
Fixes #614