Skip to content

feat(api): serve every API path under /api/v1 and deprecate the unversioned paths - #1005

Merged
rubenvdlinde merged 11 commits into
developmentfrom
quality/api-v1-larpinq
Nov 13, 2026
Merged

rubenvdlinde merged 11 commits into
developmentfrom
quality/api-v1-larpinq

Conversation

@rubenvdlinde

@rubenvdlinde rubenvdlinde commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

What

Larpinq's own JSON API now follows the NL API Design Rules that hold for every endpoint, using the scheme OpenRegister introduced (ConductionNL/openregister#9985 for problem details, ConductionNL/openregister#9995 for /api/v1 paths), adapted to the fleet's ApiContractMiddleware.

  • Versioned paths (/core/uri-version): appinfo/routes.php passes its table through ApiPathAliases::withVersionedAliases(), which adds a /api/v1/ twin of every unversioned API route with the same controller, requirements and defaults, under a v1 postfix. The twins come right after the last route the app already declares under /api/v1/ (so those keep their paths) and before everything else (so no /api/{slug} route or catch-all can answer a /api/v1/ request).
  • Deprecation (/core/deprecation-schedule): a response on an unversioned path keeps its answer and gains Deprecation: @1794441600 (2026-11-12) and Link: </index.php/apps/larpinq/api/v1/...>; rel="successor-version".
  • Problem details (RFC 9457) and API-Version on every API response, by ApiContractMiddleware, registered first so it sees the final response of every other middleware. Error bodies keep every member they had.
  • External protocol paths stay excluded, as decided: the health check and the Prometheus metrics. They get no alias, no deprecation, no version header and no problem details rewrite (lib/Middleware/Support/StandardProtocolPaths.php).
  • openapi.json (new): OpenAPI 3.0.3, server https://{host}/index.php/apps/larpinq/api/v1, 38 operations drawn from appinfo/routes.php and the controllers (docblocks, signatures, status codes, auth attributes), served at GET /api/v1/openapi.json (public, Access-Control-Allow-Origin: *).
  • openspec/specs/api-contract/spec.md describes the contract.

Tests

  • ApiContractMiddlewareTest: version header, problem details, deprecation and successor headers, no deprecation on a versioned path, protocol paths untouched.
  • ApiPathAliasesTest: successors; alias placement; the API fallback gets no alias; route parity: every deprecated route of the shipped table has a /api/v1/ twin with the same name, requirements and defaults, and a request on the twin's path reaches it (the router is simulated in declaration order); no alias takes a request meant for a declared versioned route.
  • OpenApiDocumentTest: the server is versioned, and openapi.json and routes.php describe the same versioned operations, both ways.
  • OpenApiControllerTest: the document is served publicly with CORS, 404 when missing.

Verified locally

  • hydra/scripts/diff-check.sh --base origin/development: php -l, phpcs, phpstan and phpunit green on the changed files.
  • composer check:strict once: lint, phpcs, phpstan and the full PHPUnit suite green; phpmd and psalm red on inherited findings only (StaticAccess in lib/Listener and lib/Service, psalm UndefinedMethod in lib/Listener/PreWriteEvent.php:75). The diff check reran green after the later commits on this branch.
  • Checker CLI (npm run scan:local -- <checkout> --register --api-spec openapi.json): openapi pass before and after; adrvalidator fail (1 error: include-major-version-in-uri) before, pass after (Spectral with the ADR ruleset: 0 errors, 0 warnings).
  • In larpinq the API-Version header, the problem details and the published OpenAPI document already existed (fix(deps): update transitive packages with high and critical advisories #999 and before); this PR adds the versioned paths, the deprecation headers and the protocol-path exclusion to that middleware, and three AppHost store operations the document lacked.

Notes

  • Assumption: the deprecation date is the day this lands (2026-11-12); no sunset date is announced yet.
  • The alias, protocol-path and middleware code is the same across the fleet apps that get this change. It could move to nextcloud-vue's PHP side or a common package later; for now each app carries its own copy so none depends on another app's internals.
  • openapi.json is generated from the routes and controllers, so response schemas are generic ({}); it describes paths, parameters, auth, status codes and media types, not body shapes.

This change was prepared with AI assistance (Claude Code) and reviewed before submission.

…sioned paths

Every route under /api/ is now also served under /api/v1/, with the same
controller, requirements and defaults. The unversioned paths keep answering
as before and announce their successor with a Deprecation header
(@1794441600, 2026-11-12) and a Link header with rel="successor-version".

The API contract middleware leaves standard protocol paths (health check,
Prometheus metrics) alone: no alias, no version header, no problem details
rewrite. openapi.json names /api/v1 as its server and now also describes the
AppHost store routes, so it covers every versioned route.

Tests pin the aliases (a twin for every unversioned route, no alias taking a
request meant for another route) and keep openapi.json and routes.php in step.

Assisted-by: ClaudeCode:claude-opus-5-5
…iddleware

Assisted-by: ClaudeCode:claude-opus-5-5
…lback

A route the app already declares at a /api/v1/ path keeps it, and the API
fallback (a single placeholder after /api/ that spans segments) gets no
alias, because an alias placed before the versioned routes would take
their requests.

Assisted-by: ClaudeCode:claude-opus-5-5
The aliases now come right after the last route the app already declares
under /api/v1/, so a declared versioned route keeps answering its paths.
An unversioned path whose versioned form such a route answers with
something else keeps no successor (ApiPathAliases::WITHOUT_SUCCESSOR), so
it is not announced as deprecated. The tests check that every deprecated
route's twin is reachable, simulating the router in declaration order.

Assisted-by: ClaudeCode:claude-opus-5-5
…he exceptions

Assisted-by: ClaudeCode:claude-opus-5-5
…equired in the test route table

Assisted-by: ClaudeCode:claude-opus-5-5
…clares

Assisted-by: ClaudeCode:claude-opus-5-5
Assisted-by: ClaudeCode:claude-opus-5-5
…ent protocol paths under their base

The pattern constants are typed non-empty for psalm, ApiPathAliases::RENAMED
can give a versioned path a kebab-case name (none here), and the document
test accepts protocol paths described under their unversioned base.

Assisted-by: ClaudeCode:claude-opus-5-5
Only the /api/v1 alias and the deprecation headers skip the standard
protocol paths; the API contract they had before still applies.

Assisted-by: ClaudeCode:claude-opus-5-5
@rubenvdlinde
rubenvdlinde merged commit 1137ab6 into development Nov 13, 2026
6 of 8 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

Quality Report — ConductionNL/larpinq @ e2fec13

Check PHP Vue Security License Tests
lint ✅
phpcs ✅
phpmd ❌
psalm ❌
phpstan ✅
phpmetrics ✅
eslint ✅
stylelint ✅
build ✅
check-specs ✅
test-l10n ✅
format ❌
check-l10n-js ❌
check-schema-l10n ✅
composer ❌ ✅ 110/110
npm ✅ ✅ 640/640
app:check-code ⏭️
info.xml ✅
REUSE ❌
lockfile sync ✅
PHPUnit ❌ 681/697
Newman ✅ 50/50
Playwright ⏭️ deferred: E2E runs locally and on the promotion path only. This pull request targets development, so the suite is asked once per promotion into beta and main rather than once per push per open pull request. Run it locally with npx playwright test, or from the Actions tab on a branch with no open pull request into development.
Hydra gates ❌

Quality workflow — 2026-11-15 02:18 UTC

Download the full PDF report from the workflow artifacts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant