Fix auth token response docs#249
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Updates the auth API’s documented/contracted responses so login returns tokens at the top level and the session endpoint returns a profile object.
Changes:
- Adjust login response shape to expose
access_token/refresh_tokenat the top level (removing nestedsessionin docs/spec). - Update
/api/auth/sessiondocs/spec to describe returninguser+profile. - Update login route test expectations to match the new response shape.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| src/app/docs/api/api-docs-content.tsx | Updates rendered API docs examples for login and session endpoints. |
| src/app/api/auth/login/route.test.ts | Updates tests to assert tokens are returned at the top level. |
| public/openapi.json | Updates OpenAPI schemas/descriptions to match the new auth responses. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| response: `{ | ||
| "message": "Login successful", | ||
| "user": { "id": "uuid", "email": "you@example.com" }, | ||
| "session": { | ||
| "access_token": "eyJhbGciOi...", | ||
| "refresh_token": "abc123...", | ||
| "expires_in": 3600, | ||
| "token_type": "bearer" | ||
| } | ||
| "access_token": "eyJhbGciOi...", | ||
| "refresh_token": "abc123..." | ||
| }`, |
| "get": { | ||
| "tags": ["Auth"], | ||
| "summary": "Get current session", | ||
| "description": "Returns the current authenticated user and session info.", | ||
| "description": "Returns the current authenticated user and profile.", | ||
| "operationId": "getSession", | ||
| "security": [{ "bearerAuth": [] }, { "apiKey": [] }], |
| "properties": { | ||
| "message": { "type": "string" }, | ||
| "user": { "type": "object" }, | ||
| "session": { | ||
| "type": "object", | ||
| "properties": { | ||
| "access_token": { "type": "string" }, | ||
| "refresh_token": { "type": "string" }, | ||
| "expires_in": { "type": "integer" }, | ||
| "token_type": { "type": "string" } | ||
| } | ||
| } | ||
| "access_token": { "type": "string" }, | ||
| "refresh_token": { "type": "string" } | ||
| } |
| "properties": { | ||
| "user": { "type": "object" }, | ||
| "session": { "type": "object" } | ||
| "profile": { "type": "object" } |
Greptile SummaryThis PR aligns the REST docs, OpenAPI schema, and tests with the actual login route behavior, which already returns
Confidence Score: 5/5Documentation-only sync; no runtime logic changed, all three files correctly reflect the existing route implementations. The login route and session route already returned the documented shapes before this PR. Every change here is a doc/schema/test fix that brings the written contract in line with the running code, verified by new test assertions that pass against the unchanged implementation. No files require special attention beyond the minor Important Files Changed
Sequence DiagramsequenceDiagram
participant Client
participant LoginRoute as POST /api/auth/login
participant Supabase
Client->>LoginRoute: "{ email, password }"
LoginRoute->>Supabase: signInWithPassword(email, password)
Supabase-->>LoginRoute: "{ user, session: { access_token, refresh_token } }"
LoginRoute-->>Client: "200 { message, user, access_token, refresh_token }"
Note over LoginRoute,Client: top-level tokens (no session wrapper)
Client->>+LoginRoute: GET /api/auth/session (Bearer token)
LoginRoute->>Supabase: getUser()
Supabase-->>LoginRoute: "{ user }"
LoginRoute->>Supabase: "profiles.select(*).eq(id, user.id)"
Supabase-->>LoginRoute: profile
LoginRoute-->>Client: "200 { user, profile }"
Note over LoginRoute,Client: profile object (no session wrapper)
Reviews (2): Last reviewed commit: "Fix auth token response docs" | Re-trigger Greptile |
f46fecb to
fe1d9f4
Compare
|
Thanks for the review pass. I addressed the automated notes in the latest push:
Validation: pnpm vitest run src/app/api/auth/login/route.test.ts src/app/api/openapi.json/spec.test.tsResult: 14 tests passed. |
Summary
access_token/refresh_tokenat the top level forPOST /api/auth/login/api/auth/sessiondocs/schema to describe the returnedprofileobject instead of a nestedsessionsessionobjectFixes #248.
Validation
pnpm vitest run src/app/api/auth/login/route.test.ts src/app/api/openapi.json/spec.test.ts