Conversation
Greptile SummaryThe PR publishes the rswag-generated public OpenAPI document through JSON and YAML discovery endpoints and advertises it through page metadata, robots.txt, and documentation.
Confidence Score: 4/5The unsupported query-string authentication contract should be corrected before merging so generated clients do not fail when accessing private user statistics. Five newly annotated operations advertise ApiKeyAuth, but their shared controller path accepts API keys only from the Authorization Bearer header, causing conforming clients that choose the query scheme to receive authorization or lookup failures. Files Needing Attention: spec/requests/api/v1/stats_spec.rb, swagger/v1/swagger.yaml Important Files Changed
Prompt To Fix All With AI### Issue 1
spec/requests/api/v1/stats_spec.rb:93
**Query API key is unsupported**
When a generated client selects `ApiKeyAuth` for one of these five stats operations, it sends `?api_key=...`, but `StatsController#set_user` accepts API keys only from the Bearer header. The query key is ignored, causing private-user requests to return 403 or `my` lookups to return 404 despite following the published authentication contract; remove `ApiKeyAuth` from these declarations or update the shared authentication path to accept query keys.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Reviews (1): Last reviewed commit: "enhance openapi docs" | Re-trigger Greptile |
| get('Get user heartbeat spans') do | ||
| tags 'Stats' | ||
| description 'Returns heartbeat spans for a user, useful for visualizations. Accessible anonymously when the target user has public stats lookup enabled; otherwise the requester must be the user (authenticated via the User API Key).' | ||
| security [ {}, { Bearer: [] }, { ApiKeyAuth: [] } ] |
There was a problem hiding this comment.
When a generated client selects ApiKeyAuth for one of these five stats operations, it sends ?api_key=..., but StatsController#set_user accepts API keys only from the Bearer header. The query key is ignored, causing private-user requests to return 403 or my lookups to return 404 despite following the published authentication contract; remove ApiKeyAuth from these declarations or update the shared authentication path to accept query keys.
Prompt To Fix With AI
This is a comment left during a code review.
Path: spec/requests/api/v1/stats_spec.rb
Line: 93
Comment:
**Query API key is unsupported**
When a generated client selects `ApiKeyAuth` for one of these five stats operations, it sends `?api_key=...`, but `StatsController#set_user` accepts API keys only from the Bearer header. The query key is ignored, causing private-user requests to return 403 or `my` lookups to return 404 despite following the published authentication contract; remove `ApiKeyAuth` from these declarations or update the shared authentication path to accept query keys.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.
Summary of the problem
API clients and agents need a machine-readable description of the public API. The canonical location is
/openapi.json, but there are also conventional aliases at/openapi.yaml,/api/openapi.json, and/api/openapi.yaml. The document is generated from the existing rswag spec, so it is always up to date.Describe your changes
New endpoints (app/controllers/openapi_controller.rb, config/routes.rb)
Discovery
<link rel="service-desc" href="/openapi.json">and<link rel="service-doc" href="/api-docs">in the shared layout head (RFC 8631) — emitted on every page/api/)/openapi.jsonSpec quality fixes (needed for the published document to be valid and useful)
Screenshots / Media
n/a