Skip to content

openapi: /v1/opportunities/find + /v1/issue-rag/retrieve missing from spec (MCP tools + schemas already exist) #9310

Description

@JSONbored

⚠️ Definition of Done: this issue must be completed in full, in a single PR. Do not split this
work across multiple PRs, and do not defer any Deliverable below to a follow-up issue. A PR that
satisfies only some of the Deliverables, stubs a required test, or leaves a checkbox
partially-done does NOT resolve this issue and will be closed.

⚠️ Required pattern: mirror how GET /v1/repos/{owner}/{repo}/gate-config/effective is documented
in src/openapi/spec.ts — issue #6611 fixed the exact same class of gap for that route.

Context

src/api/routes.ts defines two discovery-oriented POST routes via named path constants, each backed
by an MCP tool with its own Zod output shape already defined in src/mcp/server.ts:

  • POST /v1/opportunities/find (OPPORTUNITIES_FIND_PATH) → loopover_find_opportunities
    (outputSchema: findOpportunitiesOutputSchema)
  • POST /v1/issue-rag/retrieve (ISSUE_RAG_RETRIEVE_PATH) → loopover_retrieve_issue_context
    (outputSchema: issueRagOutputSchema)

Neither route appears in src/openapi/spec.ts — grep for opportunities/find and issue-rag in
that file returns nothing.

Requirements

  • In src/openapi/schemas.ts, define FindOpportunitiesResponseSchema and
    IssueRagRetrieveResponseSchema as z.object({...}) schemas, using findOpportunitiesOutputSchema
    and issueRagOutputSchema (the raw Zod shapes already validated in src/mcp/server.ts) as the
    field-level source of truth. Add matching request-body schemas mirroring the two tools'
    inputSchema/shape constants.
  • In src/openapi/spec.ts, registry.register both schemas as components, then add registerPath
    entries for both routes.
  • Schema is the contract — regenerate and commit. Run npm run ui:openapi after the edits and
    commit the regenerated apps/loopover-ui/public/openapi.json in this same PR. CI enforces this via
    npm run ui:openapi:check (part of npm run test:ci).

Deliverables

  • FindOpportunitiesResponseSchema and IssueRagRetrieveResponseSchema (plus matching
    request-body schemas) added to src/openapi/schemas.ts.
  • Both routes registered as OpenAPI paths in src/openapi/spec.ts.
  • apps/loopover-ui/public/openapi.json regenerated via npm run ui:openapi and committed.
  • npm run ui:openapi:check passes in CI.

All deliverables are required in this one PR — there is no follow-up issue.

Test Coverage Requirements

99%+ Codecov patch target (codecov/patch, unsharded via npm run test:coverage) on any new schema
helper code. Add a regression test asserting both paths appear in buildOpenApiSpec()'s output with
response schemas whose keys match findOpportunitiesOutputSchema/issueRagOutputSchema.

Expected Outcome

Both discovery routes are documented in GET /openapi.json / apps/loopover-ui/public/openapi.json,
matching what their MCP tools already validate.

Links & Resources

Metadata

Metadata

Assignees

No one assigned

    Labels

    gittensor:bugGittensor-scored bug fix — scores a 0.05x multiplier.help wantedExtra attention is needed

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions