feat: mount chat API routes under /api/v2 (#28496)

## Stack context

This is the base of a 3-PR stack promoting the chat API from
`/api/experimental` to `/api/v2`: server compatibility mounts (this PR),
codersdk promotion (#28497), and frontend path updates (#28498).

## Summary

Double-mount the stable chat and MCP handlers under `/api/v2` while
retaining the existing experimental routes for the one-release
compatibility window decided in CODAGT-921. CODAGT-922 tracks removing
the compatibility mounts.

The shared route builders preserve existing authentication and
middleware behavior. Experiment-gated, debug, tombstone, and legacy
default-organization model routes remain experimental-only. Signed file
URLs, external OAuth callback URLs, and mixed-version replica relays
also remain on the experimental prefix during the transition.

Update Swagger and the generated API reference for the promoted routes,
including the workspace lookup and a runnable raw-body chat file upload
example. Retain internal endpoints outside the published reference,
share chat-file rate limits across both prefixes, enable CORS for the v2
MCP routes, and cover dual mounts plus exclusions with compatibility
tests. Remote dogfood UAT passed for the promoted chat, model, MCP, and
file flows.

> [!NOTE]
> Xum acted on Mike's behalf in this pull request.
<!-- xum-attribution: model=claude-fable-5 thinking=high -->
This commit is contained in:
Michael Suchacz
2026-08-26 16:17:06 +02:00
committed by GitHub
parent 0c0e605521
commit 351bb14032
27 changed files with 8686 additions and 4537 deletions
@@ -1,8 +1,8 @@
# Example request using curl
{{ const rawBodyFile = data.operation['x-apidocgen'] && data.operation['x-apidocgen'].rawBodyFile; }}# Example request using curl
curl -X {{=data.methodUpper}} http://coder-server:8080{{=data.url}}{{=data.requiredQueryString}}{{?data.allHeaders.length}} \{{?}}
{{~data.allHeaders :p:index}}{{
if (p.name == "Content-Type" && p.exampleValues.object == "application/x-www-form-urlencoded") {
continue;
}
}} -H '{{=p.name}}: {{=p.exampleValues.object}}'{{?index < data.allHeaders.length-1}} \
{{?}}{{~}}
}} -H '{{=p.name}}: {{=p.exampleValues.object}}'{{?index < data.allHeaders.length-1 || rawBodyFile}} \
{{?}}{{~}}{{?rawBodyFile}} --data-binary '@{{=rawBodyFile}}'{{?}}
@@ -45,7 +45,7 @@
{{= renderDescription(data)}}
{{? data.operation.requestBody}}
{{? data.operation.requestBody && !(data.operation['x-apidocgen'] && data.operation['x-apidocgen'].rawBodyFile)}}
> Body parameter
{{? data.bodyParameter.exampleValues.description }}