Skip to content

feat: select the SDK platform from x-appwrite.platforms - #1880

Merged
ChiragAgg5k merged 2 commits into
mainfrom
feat/native-platform-selection
Sep 7, 2026
Merged

ChiragAgg5k merged 2 commits into
mainfrom
feat/native-platform-selection

Conversation

@ChiragAgg5k

Copy link
Copy Markdown
Member

Summary

Appwrite publishes one OpenAPI document per SDK platform, and the generator trusts each document to be pre-filtered. appwrite/appwrite#13502 made the operation-level x-appwrite.platforms the effective SDK availability and gave every method alias its own list. This PR teaches the generator to select from that metadata, which is the generator half of consolidating the three documents into one.

  • Operations, method aliases in x-appwrite.methods[], and security schemes whose x-appwrite.platforms exclude sdk.platform are skipped. A missing list, or generating without a platform, means available everywhere. Unknown names such as Cloud's manager never match.
  • Filtering a security scheme also removes it from the client's global header setters and from every operation's security requirement, so a client SDK generated from a document that also carries Key does not grow a setKey().
  • example.php sets the platform for every target, as the SDKs task in appwrite/appwrite already does.

x-appwrite.auth is left as is. It is a per-platform slice of the security requirement, and how a canonical document expresses it is a separate decision on the appwrite side.

Testing pattern

tests/e2e/Base.php mixed three kinds of assertion: runtime behaviour compared against expectedOutput, greps of the generated tree for zz* fixture tokens, and unit checks of Language methods. This PR splits them.

  • tests/generation/GenerationTest.php is a new suite that generates the fixture for every language and platform with no Docker and checks the trees against declarative tables. Excluded fixtures must never appear, platform-bound fixtures must appear on their platforms alone, enums must be declared, Go model comments must not carry HTML entities. The enum unit checks move here and run once per language instead of once per Docker job.
  • tests/e2e/ keeps only runtime behaviour.
  • The fixture gains a console-only operation, an alias with a client variant and a server variant, and a server-only security scheme, plus the accurate platforms lists the e2e tests already relied on.

Generated trees under tests/generation/sdks/ are ignored by git, phpcs, rector and PHPUnit discovery. CI gains a Checks / Generation job.

Validation

  • Regenerated all 24 targets from the current cloud latest client, server and console documents before and after: byte-identical on every platform.
  • vendor/bin/phpunit --testsuite Generation: 81 tests, 908 assertions, 4 skipped (languages without enums).
  • vendor/bin/phpunit tests/e2e/PHP85Test.php: passed.
  • composer lint, composer refactor:check, composer lint-twig: clean.

Related to CLO-4377.

Appwrite publishes one OpenAPI document per SDK platform, with the generator trusting each to be pre-filtered. appwrite/appwrite#13502 made the operation-level `x-appwrite.platforms` the effective availability and gave every method alias its own list, which lets one canonical document drive all three platforms once the generator selects from it.

The generator now skips operations, aliases and security schemes whose `platforms` exclude `sdk.platform`. A missing list, or no platform, means available everywhere, and unknown names such as Cloud's `manager` never match. `example.php` sets the platform for every target, as production already does. Regenerating every target from the current client, server and console documents is byte-identical.

Shape checks move out of the Docker e2e tests into a `Generation` suite that generates the fixture for every language and platform and checks the trees against declarative tables: excluded fixtures never appear, platform-bound fixtures appear on their platforms alone, enums are declared, Go model comments carry no HTML entities. The e2e suite keeps only runtime behavior.

Related to CLO-4377.
@greptile-apps

greptile-apps Bot commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds platform-aware generation based on x-appwrite.platforms metadata and separates generated-tree assertions from runtime end-to-end tests.

  • Filters operations, aliases, security schemes, global headers, and client methods for the selected SDK platform.
  • Invalidates platform-dependent caches when an SDK instance changes platform.
  • Adds a generation test suite covering all languages and platforms, with explicit exceptions for targets that do not render certain constructs.
  • Updates fixtures, CI, PHPUnit configuration, and generated-output exclusions for the new suite.

Confidence Score: 5/5

The PR appears safe to merge; the previous platform-cache, client-method filtering, and fixture-coverage concerns are resolved in the current code.

Platform changes now invalidate every platform-dependent cache, client-level methods honor operation availability, and generation tests require platform-bound fixtures to appear on their applicable targets. The previous threads were also manually resolved.

Important Files Changed

Filename Overview
src/SDK/SDK.php Implements consistent platform filtering for operations, aliases, security schemes, headers, and client methods, including complete platform-cache invalidation.
tests/generation/GenerationTest.php Adds cross-language generation assertions and now requires expected platform-specific fixtures to be present unless the target is explicitly marked as not rendering them.
tests/resources/spec-openapi3.json Extends the shared fixture with platform-specific operations, aliases, and a security scheme used by generation tests.
tests/e2e/Base.php Removes generated-tree and language-unit assertions that have been moved into the dedicated generation suite.
.github/workflows/ci.yml Adds a standalone CI job for the generation test suite.

Reviews (2): Last reviewed commit: "fix: reset platform caches and filter cl..." | Re-trigger Greptile

Comment thread src/SDK/SDK.php Resolved
Comment thread src/SDK/SDK.php Resolved
Comment thread tests/generation/GenerationTest.php Resolved
setPlatform() now clears the operation, service and model caches so a reused SDK instance does not carry the previous platform's selection, and the client-method collector honours x-appwrite.platforms like every other path. The generation suite requires platform-bound fixtures to appear unless a target is listed as not rendering them.
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