Feat | Add OpenAPI documentation for OAuth2StreamChatSSOApiController#110
Feat | Add OpenAPI documentation for OAuth2StreamChatSSOApiController#110matiasperrone-exo wants to merge 1 commit intomainfrom
Conversation
293ea4b to
eb2e34e
Compare
68506be to
dcd7a93
Compare
eb2e34e to
e541410
Compare
dcd7a93 to
a259529
Compare
9935b59 to
487b12f
Compare
487b12f to
b7a20f4
Compare
…iController v1 routes
b7a20f4 to
77482f2
Compare
📝 WalkthroughWalkthroughThis pull request adds OpenAPI/Swagger documentation to a Stream Chat SSO API endpoint. Three new or modified files introduce OpenAPI annotations and schema definitions for the Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
📝 Coding Plan
Comment |
|
📘 OpenAPI / Swagger preview ➡️ https://OpenStackweb.github.io/openstackid/openapi/pr-110/ This page is automatically updated on each push to this PR. |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@app/Http/Controllers/Api/OAuth2/OAuth2StreamChatSSOApiController.php`:
- Around line 66-92: The OpenAPI responses for 404 and 412 in
OAuth2StreamChatSSOApiController.php are missing JSON content schemas while the
controller actually returns JSON via error404() and error412(); update the
OA\Response entries for HttpResponse::HTTP_NOT_FOUND and
HttpResponse::HTTP_PRECONDITION_FAILED to include a content: new
OA\JsonContent(...) that matches the real payload (e.g., a simple {"message":
"..."} schema for 404 and a {"message":"Validation Failed","errors":[...]}
validation-error schema for 412), or reference existing components like
StreamChatUserProfile for 200 and a shared ErrorResponse / ValidationError
schema if available, so the OpenAPI docs accurately reflect the returned JSON
bodies.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 4eee0347-ea24-47d2-b759-1ba3fae79c44
📒 Files selected for processing (3)
app/Http/Controllers/Api/OAuth2/OAuth2StreamChatSSOApiController.phpapp/Swagger/Models/StreamChatUserProfileSchema.phpapp/Swagger/Security/OAuth2StreamChatSSOApiControllerSecuritySchema.php
| responses: [ | ||
| new OA\Response( | ||
| response: HttpResponse::HTTP_OK, | ||
| description: 'OK', | ||
| content: new OA\JsonContent(ref: '#/components/schemas/StreamChatUserProfile') | ||
| ), | ||
| new OA\Response( | ||
| response: HttpResponse::HTTP_NOT_FOUND, | ||
| description: 'Not Found' | ||
| ), | ||
| new OA\Response( | ||
| response: HttpResponse::HTTP_PRECONDITION_FAILED, | ||
| description: 'Validation Error' | ||
| ), | ||
| new OA\Response( | ||
| response: HttpResponse::HTTP_INTERNAL_SERVER_ERROR, | ||
| description: 'Server Error' | ||
| ), | ||
| new OA\Response( | ||
| response: HttpResponse::HTTP_UNAUTHORIZED, | ||
| description: 'Unauthorized - invalid or missing token' | ||
| ), | ||
| new OA\Response( | ||
| response: HttpResponse::HTTP_FORBIDDEN, | ||
| description: 'Forbidden - insufficient scope' | ||
| ), | ||
| ] |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "=== Response helpers used by OAuth2StreamChatSSOApiController ==="
rg -n -C4 'class\s+OAuth2ProtectedController\b|function\s+(ok|error404|error412|error500)\s*\(' --glob '*.php'
echo
echo "=== Stream Chat SSO payload serialization ==="
rg -n -C4 'IStreamChatSSOService|class\s+.*StreamChat.*|function\s+getUserProfile\s*\(|function\s+serialize\s*\(' --glob '*.php'Repository: OpenStackweb/openstackid
Length of output: 35631
🏁 Script executed:
sed -n '94,115p' app/Http/Controllers/Api/OAuth2/OAuth2StreamChatSSOApiController.phpRepository: OpenStackweb/openstackid
Length of output: 691
Add content specifications to 404 and 412 responses.
Line 97 returns the serialized profile directly via ok(), but lines 101 and 106 emit structured JSON through error412() and error404() respectively. The OpenAPI documentation currently omits content for the 404 and 412 responses, though they do emit JSON bodies:
- 404 returns
{"message": "..."}viaerror404() - 412 returns
{"message": "Validation Failed", "errors": [...]}viaerror412()
Update the 404 and 412 response definitions to specify their actual JSON content schemas, or verify the 200 response schema correctly describes the flat profile object.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@app/Http/Controllers/Api/OAuth2/OAuth2StreamChatSSOApiController.php` around
lines 66 - 92, The OpenAPI responses for 404 and 412 in
OAuth2StreamChatSSOApiController.php are missing JSON content schemas while the
controller actually returns JSON via error404() and error412(); update the
OA\Response entries for HttpResponse::HTTP_NOT_FOUND and
HttpResponse::HTTP_PRECONDITION_FAILED to include a content: new
OA\JsonContent(...) that matches the real payload (e.g., a simple {"message":
"..."} schema for 404 and a {"message":"Validation Failed","errors":[...]}
validation-error schema for 412), or reference existing components like
StreamChatUserProfile for 200 and a shared ErrorResponse / ValidationError
schema if available, so the OpenAPI docs accurately reflect the returned JSON
bodies.
Task:
Ref: https://app.clickup.com/t/86b8e6jxy
Summary by CodeRabbit