Skip to content

refactor(specs): state the project path binding as x-appwrite.config - #13757

Merged
ChiragAgg5k merged 2 commits into
mainfrom
refactor/path-config-extension
Sep 18, 2026
Merged

ChiragAgg5k merged 2 commits into
mainfrom
refactor/path-config-extension

Conversation

@ChiragAgg5k

@ChiragAgg5k ChiragAgg5k commented Sep 18, 2026 •

Copy link
Copy Markdown
Member

Producer half of removing ProjectPath, for appwrite-labs/cloud#5799. The consumer half shipped in sdk-generator 5.1.0.

Before and after

Generated by running this branch's producer against a replica of Cloud's oauth2.approve route (locationAuth: ['ProjectPath'], session and JWT auth, a project_id path parameter). The "before" column is the same route on main, and matches the published canonical document.

Before

// components.securitySchemes
"ProjectPath": {
  "type": "apiKey",
  "name": "project",
  "description": "Your project ID",
  "in": "query",
  "x-appwrite": {
    "location": "path",
    "param": "project_id",
    "platforms": ["client", "server", "console"],
    "demo": "<YOUR_PROJECT_ID>"
  }
},

// paths./oauth2/{project_id}/approve.post
"security": [ { "ProjectPath": [], "Session": [], "JWT": [] } ],
"parameters": [
  { "name": "project_id", "in": "path", "required": true,
    "description": "Project ID in which OAuth2 client exists.",
    "schema": { "type": "string", "example": "<PROJECT_ID>" } }
],
"x-appwrite": {
  "scope": "oauth2.write", "demo": "oauth2/approve.md", "public": true,
  "rate-limit": 0, "rate-time": 3600, "rate-key": "url:{url},ip:{ip}",
  "platforms": ["client", "server"], "packaging": false,
  "auth": {
    "client": { "ProjectPath": [] },
    "server": { "ProjectPath": [], "Session": [] }
  }
}

After

// components.securitySchemes — no ProjectPath

// paths./oauth2/{project_id}/approve.post
"security": [ { "Session": [], "JWT": [] } ],
"parameters": [
  { "name": "project_id", "in": "path", "required": true,
    "description": "Project ID in which OAuth2 client exists.",
    "schema": { "type": "string", "example": "<PROJECT_ID>" } }
],
"x-appwrite": {
  "scope": "oauth2.write", "demo": "oauth2/approve.md", "public": true,
  "rate-limit": 0, "rate-time": 3600, "rate-key": "url:{url},ip:{ip}",
  "platforms": ["client", "server"], "packaging": false,
  "config": { "project_id": "project" },
  "auth": {
    "client": { "Project": [] },
    "server": { "Project": [], "Session": [] }
  }
}

The parameter is untouched — it was always the honest statement of the binding, and it stays plain OpenAPI so any consumer builds the right URL.

Why

ProjectPath said in: query, name: project for a query string nothing sends; x-appwrite.location: path meant "ignore in: query" and param named the real path parameter. A standard OpenAPI consumer following the declared fields builds the wrong request, and the binding was stated twice — once honestly as a path parameter, once as a fictional query API key.

Three things move:

  • The binding leaves security, which now lists only real authentication. Project is deliberately not added there: these routes do not send X-Appwrite-Project, and listing it would start emitting that header.
  • x-appwrite.config carries it instead — a path parameter filled from client configuration is the one thing OpenAPI cannot express, so it sits in the operation's existing x-appwrite block. No new nesting site: x-appwrite still appears only on operations, aliases and security schemes.
  • Example auth switches to Project, so the generated example still renders setProject('<YOUR_PROJECT_ID>'). The <YOUR_PROJECT_ID> demo entry for ProjectPath is gone with the scheme.

Net across the canonical document: one fake scheme, location and param out; one operation key in.

Route declarations are unchanged

Cloud's OAuth2 routes keep locationAuth: ['ProjectPath']. What changed is the entry behind that name in getKeys() — it is now the marker naming the parameter and the config key, in plain keys, rather than a scheme pretending to be authentication:

'ProjectPath' => [
    'location' => ParameterLocation::PATH->value,
    'param' => 'project_id',
    'config' => 'project',
],

getSecuritySchemes() skips path bindings, since they are not credentials.

Compatibility

sdk-generator 5.1.0 reads x-appwrite.config and normalises the old scheme form into it, so both spellings generate the same SDK — proven by an equivalence test in that release. Cloud should be on 5.1.0 before this merges, since Cloud's installed generator writes the canonical document and its SDK examples.

Testing

testPathBoundProjectBecomesOperationConfig covers the emission: x-appwrite.config is {"project_id": "project"}, security is [{"Session": []}] with no binding entry, example auth is {"Project": []}, and components.securitySchemes has no ProjectPath.

  • vendor/bin/phpunit tests/unit/SDK/Specification/FormatTest.php — 43 tests, 253 assertions, OK
  • composer lint — Pint passed
  • Full unit suite: the 34 errors and 1 failure reproduce identically on a clean main in this environment (Utopia\Http\TrustedHeaders missing from a stale vendor, image/font deps, maxminddb), none from this change

Routes taking the project in the path declared it with `ProjectPath`, a
security scheme saying `in: query, name: project` for a query string nothing
sends, with `location` and `param` redirecting it to the real path parameter.
It is not a credential and it is not query, so a standard OpenAPI consumer
following those fields builds the wrong request.

The operation states it directly instead:

    "x-appwrite": { "config": { "project_id": "project" } }

The binding stays out of `security`, which now lists only real authentication,
and is no longer emitted as a security scheme. Examples keep configuring the
project on the client, so `x-appwrite.auth` lists `Project` and the generated
example still renders `setProject(...)`.

Routes keep declaring it the same way, with `locationAuth: ['ProjectPath']`.
Its entry in `getKeys()` is now the marker naming the parameter and the config
key, in plain keys rather than a scheme pretending to be authentication.

Needs sdk-generator 5.1.0, which reads the operation key and normalises the
scheme form into it, so either spelling generates the same SDK.
@greptile-apps

greptile-apps Bot commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

The PR appears safe to merge, with no outstanding correctness, security, or repository-rule violations identified.

Summary

Refactors project path bindings from fictional OpenAPI security schemes into operation-level x-appwrite.config metadata.

  • Excludes path bindings from generated security schemes and operation security requirements.
  • Preserves project setup in generated example authentication metadata.
  • Updates canonical ProjectPath definitions to identify the path parameter and client configuration key.
  • Revises the regression test to exercise the production key configuration rather than duplicating it.

Reviews (2) · Last reviewed commit: "test: read the path binding from the pro..."

@github-actions

github-actions Bot commented Sep 18, 2026 •

Copy link
Copy Markdown

✨ Benchmark results

Comparing main (before) → refactor/path-config-extension (after).

Metric Before After Change
🚀 Requests/sec 286.31 284.73 ⚪ -0.6%
⏱️ Latency P50 60.22 ms 60.8 ms ⚪ +1%
⏱️ Latency P95 144.28 ms 143.66 ms ⚪ -0.4%
Per-scenario breakdown & investigation details

Metrics below reflect the current branch (after). Δ P95 compares against the base.

Scenario P50 (ms) P95 (ms) Requests RPS Δ P95 (ms)
API total 60.8 143.66 17,556 284.73 -0.62
Account 113.98 215.14 924 15.32 -10.93
TablesDB 58.21 107.96 9,548 156.94 -2.95
Storage 56.82 129.83 4,620 77.81 -0.56
Functions 89.76 177.53 2,464 42.1 -3.83

Top API waits (after)

API request Max wait (ms)
account.name.update 447.89
functions.variables.delete 325.43
account.prefs.update 318.76
functions.create 301.57
tablesdb.rows.create 299.73

@ChiragAgg5k
ChiragAgg5k merged commit 1a6b930 into main Sep 18, 2026
51 checks passed
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.

2 participants