Repository navigation
feat: emit a canonical OpenAPI document covering every SDK platform - #13512
Conversation
The Specs task writes open-api3-<version>.json alongside the per-platform files: every route any platform offers, every method alias variant, all response models, the union of tags and of security schemes. The generator selects a platform from x-appwrite.platforms since 4.8.0; what it could not select was x-appwrite.auth, whose value differs per platform, so the canonical document keys auth by platform and each security scheme lists the platforms whose SDK offers it. The per-platform documents are unchanged apart from that scheme-level platforms list, which is why they stay byte-identical for the SDKs generated from them. Related to CLO-4377.
Greptile SummaryThis PR adds a canonical OpenAPI document containing the union of the client, server, and console SDK surfaces while retaining the existing platform-specific documents.
Confidence Score: 5/5The PR appears safe to merge; no actionable correctness, security, or repository-rule violations remain. The canonical generation path consistently preserves platform membership, authentication selection, alias variants, and security-scheme annotations, while platform-specific output retains its previous filtering semantics. Important Files Changed
Reviews (4): Last reviewed commit: "Merge branch 'main' into feat/canonical-..." | Re-trigger Greptile |
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
4.9.0 reads x-appwrite.auth keyed by platform, which the canonical document emits.
What does this PR do?
The Specs task now writes one canonical OpenAPI document per version,
open-api3-<version>.json, alongside the existing-client,-serverand-consolefiles. It covers every route any SDK platform offers, every method alias variant, all response models, and the union of tags and security schemes. sdk-generator 4.8.0 already selects a platform fromx-appwrite.platforms(appwrite/sdk-generator#1880); this document is what it selects from.The one thing the generator could not select by platform was
x-appwrite.auth, the credentials an SDK example configures, because its value differs per platform. In the canonical document it is keyed by platform; appwrite/sdk-generator#1881 readsauth[platform]and keeps reading the flat form.Spec changes
Canonical document only
Operation and alias
authkeyed by platform.PATCH /presences/{presenceId}shows both, including the twoupdatealias variants that differ inrequired:Security schemes are the union of the platforms' key sets in
getPlatforms()order, first definition wins.All documents
Each security scheme lists the platforms whose SDK offers it. This is the only change to the per-platform files:
"Key": { "type": "apiKey", "name": "X-Appwrite-Key", "in": "header", "x-appwrite": { + "platforms": ["server", "console"], "demo": "<YOUR_API_KEY>" } }Code changes
Specs::action()loops[...platforms, null]; thenullpass is the canonical document: routes with any platform, all alias variants, models without the console-onlyisPublicfilter, services whose platforms intersect the known ones. Filename suffix is omitted, and--git=yescopies the canonical file with the PR platforms' files.Formattakes the full per-platform key map and per-platform auth counts, and a nullable platform.getSecuritySchemes()returns the document's schemes withx-appwrite.platforms.OpenAPI3::getExampleAuth()computes today's slice once per platform and returns it flat for a platform document, keyed for the canonical one. Route inclusion and alias inclusion accept "any platform" when the platform is null.Validation
vendor/bin/phpunit tests/unit/SDK: 36 tests, 192 assertions, including two new canonical-document tests (keyed auth per platform, alias variants across platforms, scheme platforms and union order). Pint and Rector clean.php app/cli.php specs --version=latest --mode=normal --git=noon this branch versusmain:mainafter removing the new schemeplatformslists.auth[platform]matches the platform document's flatauthfor all 1,336 operation/platform pairs; every alias variant matches.main's documents:Client.*files differ, in the order of the header setters, because the union follows the client's scheme order. Content is the same.Follow-ups
Specssubclass adds amanagerplatform whoseKeyscheme is a bearer token, not theX-Appwrite-Keyheader. In a union the first definition wins, so the canonical document would describe manager'sKeywrongly. Rename that scheme on the cloud side before the canonical document is used for a manager SDK. The cloud specs workflow also needs to copyopen-api3-<version>.json.Related to CLO-4377.