fix(openapi): document /v1/opportunities/find + /v1/issue-rag/retrieve - #9454
Closed
hurryup52 wants to merge 1 commit into
Closed
fix(openapi): document /v1/opportunities/find + /v1/issue-rag/retrieve#9454hurryup52 wants to merge 1 commit into
hurryup52 wants to merge 1 commit into
Conversation
Both routes were fully implemented and gated correctly but never wired
into the OpenAPI generator, so they were invisible in GET /openapi.json
and the committed apps/loopover-ui/public/openapi.json even though their
MCP tool counterparts (loopover_find_opportunities,
loopover_retrieve_issue_context) already validate full Zod shapes.
Adds FindOpportunitiesRequestSchema/ResponseSchema and
IssueRagRetrieveRequestSchema/ResponseSchema to src/openapi/schemas.ts,
mirroring the MCP tools' own shapes field-for-field
(findOpportunitiesShape/findOpportunitiesOutputSchema and
issueRagShape/issueRagOutputSchema in src/mcp/server.ts) so the contract
can't silently drift from what the tools actually validate. Registers
both response schemas as OpenAPI components and both routes as POST
paths in src/openapi/spec.ts, following the same pattern used for
GET /v1/repos/{owner}/{repo}/gate-config/effective.
Regenerates apps/loopover-ui/public/openapi.json via `npm run
ui:openapi` and extends test/unit/openapi.test.ts with assertions that
both paths are defined and that the response schemas' fields match the
MCP output shapes.
Closes JSONbored#9310
Contributor
|
Important 🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨 ⏳ LoopOver is waiting…LoopOver has seen this pull request and is waiting on CI checks to finish before reviewing it. This comment will update once the review runs. 🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed · 🟨 Waiting |
Contributor
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
Contributor
Author
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #9454 +/- ##
==========================================
+ Coverage 75.51% 75.69% +0.18%
==========================================
Files 275 277 +2
Lines 58032 58480 +448
Branches 6209 6216 +7
==========================================
+ Hits 43820 44267 +447
Misses 13942 13942
- Partials 270 271 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
|
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.
Closes #9310
(Fifth attempt — prior attempts were each auto-closed by the gate for a base-branch conflict in the generated
apps/loopover-ui/public/openapi.json, never a content/review problem. This area of the spec is being actively documented by several parallel contributor PRs for other issues, landing in quick succession. This PR is rebased onto the currentmaintip with all conflicts resolved; no content changes from the prior attempts.)What
/v1/opportunities/find(OPPORTUNITIES_FIND_PATH, backing theloopover_find_opportunitiesMCP tool) and/v1/issue-rag/retrieve(ISSUE_RAG_RETRIEVE_PATH, backingloopover_retrieve_issue_context) are fully implemented and access-gated insrc/api/routes.ts, but were never registered with the OpenAPI generator — grep foropportunities/find/issue-raginsrc/openapi/spec.tspreviously returned nothing, so neither route appeared inGET /openapi.jsonor the committedapps/loopover-ui/public/openapi.json.Changes
src/openapi/schemas.ts: addedFindOpportunitiesRequestSchema/FindOpportunitiesResponseSchemaandIssueRagRetrieveRequestSchema/IssueRagRetrieveResponseSchema. Field shapes mirror the MCP tools' own Zod shapes verbatim (findOpportunitiesShape/findOpportunitiesOutputSchemaandissueRagShape/issueRagOutputSchemainsrc/mcp/server.ts) so the contract can't silently drift from what the tools actually validate — reused the sameMAX_FIND_OPPORTUNITIES_*/MAX_ISSUE_RAG_*/PREFLIGHT_LIMITSconstants those shapes already use.src/openapi/spec.ts: registered both response schemas as named components (FindOpportunitiesResponse,IssueRagRetrieveResponse) and added tworegisterPathPOST entries, following the same pattern used forGET /v1/repos/{owner}/{repo}/gate-config/effective(OpenAPI spec is missing GET /v1/repos/{owner}/{repo}/gate-config/effective (documented sibling: live-gate-thresholds) #6611) and the existing POST-with-body routes (e.g. the incident-reports pair). Response codes (400/401/403) are matched to each route handler's actual behavior inroutes.ts.apps/loopover-ui/public/openapi.json: regenerated vianpm run ui:openapiand committed.npm run ui:openapi:checkpasses.test/unit/openapi.test.ts: added assertions that both paths are defined, that both response schema components are registered, and that their fields (aiPolicyAllowed,retrievedPathCount) match the MCP output shapes — a regression guard against future drift between the two.Verification
npx vitest run test/unit/openapi.test.ts— 9/9 pass (merges cleanly alongside the other recently-landed OpenAPI-documentation tests in this file).npm run ui:openapi:check— passes.npm run typecheck— clean.maintip immediately before opening this PR.