Skip to content

feat(specs): add standard OpenAPI request examples - #13918

Merged
ChiragAgg5k merged 3 commits into
mainfrom
fix/openapi-request-examples
Sep 26, 2026
Merged

ChiragAgg5k merged 3 commits into
mainfrom
fix/openapi-request-examples

Conversation

@ChiragAgg5k

@ChiragAgg5k ChiragAgg5k commented Sep 26, 2026 •

Copy link
Copy Markdown
Member

Summary

Publish complete request examples using standard OpenAPI fields, so SDK generators can consume meaningful inputs without hardcoding database, messaging or transaction behavior.

Follow-up to #13909 and appwrite/sdk-generator#1940. Parameter-level examples alone cannot describe a complete body containing optional inputs such as commit, data, operations or draft.

Changes

  • Add an optional requestExamples field to Appwrite's internal SDK Method metadata and emit it under requestBody.content[mediaType].examples.
  • Collect examples from eligible method descriptors for shared endpoints, respecting platform visibility and rejecting conflicting example names. Nothing is added to x-appwrite or the SDK alias extension.
  • Add 27 named body examples across 23 operations:
    • Commit and rollback, separately, for all four database families.
    • Stage transaction operations with a nonempty operations payload.
    • Update/upsert documents and rows with data; bulk updates include explicit ID selection.
    • Create email, SMS and push drafts without recipients or delivery.
  • Add explicit ID-query examples to all four bulk-delete operations through existing parameter-schema example support. Each filter is emitted only once; there is no general query-example promotion or timezone change.

Complete request examples are limited to operations where required-only inputs would be invalid or unsafe: transaction actions, updates/upserts and message drafts. Operations already demonstrated adequately by individual field examples are left alone.

Request schemas, requiredness, defaults, authentication, existing extensions and handlers are unchanged. No generated JSON or new/modified tests are committed.

Generated examples

Commit or roll back a transaction

Previously the spec only contained individual property examples. The generated media type now also contains two complete, mutually exclusive request examples:

# PATCH /tablesdb/transactions/{transactionId}
requestBody:
  content:
    application/json:
      schema: # existing schema, unchanged
        # ...
      examples:
        commit:
          summary: Commit the transaction
          value:
            commit: true
        rollback:
          summary: Roll back the transaction
          value:
            rollback: true

Update selected rows

{
  "updateSelected": {
    "summary": "Update explicitly selected rows",
    "value": {
      "data": {"username": "walter.obrien"},
      "queries": ["{\"method\":\"equal\",\"attribute\":\"$id\",\"values\":[\"<ROW_ID>\"]}"]
    }
  }
}

This is emitted at requestBody.content.application/json.examples, not as a vendor extension.

Delete selected rows

The optional queries parameter on DELETE /tablesdb/{databaseId}/tables/{tableId}/rows now has a single schema-level example, using existing exporter support:

schema:
  type: array
  items:
    type: string
  default: []
  example:
    - '{"method":"equal","attribute":"$id","values":["<ROW_ID>"]}'

A limit alone is not used as record selection.

Create an email draft

{
  "draft": {
    "summary": "Create an email draft without sending it",
    "value": {
      "messageId": "<MESSAGE_ID>",
      "subject": "Welcome",
      "content": "Welcome to our app.",
      "draft": true
    }
  }
}

Verification

  • Generated normal and preview canonical/client/server/console specs with the real CLI task, using appwrite/appwrite:2.3.0, --network none, and the worktree mounted at /usr/src/code:
    • php app/cli.php specs --version=latest --mode=normal --git=no
    • Repeated with _APP_SDK_PREVIEW=enabled.
  • Independently generated the same eight documents before editing. Recursive comparison confirms only example and examples fields differ, including no changes to x-appwrite.
  • Validated all eight documents with openapi-spec-validator==0.7.2: zero OpenAPI 3.0 validation errors.
  • Validated all added named-body and bulk-delete query example values against their schemas using openapi-schema-validator==0.6.3: 224 validations across eight documents, no exceptions or mismatches. Also checked complete required-body fields, separate commit/rollback choices, nonempty operations, drafts, ID filters and four-dimensional vector payloads.
  • php vendor/bin/phpunit tests/unit/SDK/Specification/FormatTest.php — 43 tests, 253 assertions passed.
  • PHPStan on all 29 changed PHP files — passed, including a rerun on the narrowed exporter.
  • Pint on all changed PHP files and git diff --check — passed.

The previous query-example promotion and accompanying timezone correction have been removed from this PR. Existing unrelated field examples are unchanged; validation of example values is scoped to the examples added here.

Live API mutations were not exercised. IDs and collection/table-specific fields must be adapted to real resources; vector creation examples assume a four-dimensional collection. No UI screenshots apply.

Follow-up

Generic parser/generator consumption is separate: prefer explicit body examples, include explicit optional query examples, and retain required-parameter fallback where examples are absent. This PR supplies the metadata but does not by itself change generated CLI scenarios. Standard OpenAPI does not correlate named body and query examples or assign them to SDK aliases; no naming convention or new extension is introduced to pretend otherwise.

@greptile-apps

greptile-apps Bot commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Low risk] Adds example request payloads to API documentation specs.

The PR appears safe to merge based on the reviewed changes.

Summary

The PR adds named OpenAPI request-body examples for transaction actions, database updates and upserts, and message drafts, plus ID-selection examples for bulk-delete query parameters. The changes since the previous review remove general query-example promotion and revert its associated timezone adjustment.

Reviews (3) · Last reviewed commit: "refactor(specs): limit example changes t..."

greptile-apps[bot]
greptile-apps Bot previously approved these changes Sep 26, 2026
@github-actions

github-actions Bot commented Sep 26, 2026 •

Copy link
Copy Markdown

✨ Benchmark results

Comparing main (before) → fix/openapi-request-examples (after).

Metric Before After Change
🚀 Requests/sec 195.67 194.46 ⚪ -0.6%
⏱️ Latency P50 88.56 ms 89.79 ms ⚪ +1.4%
⏱️ Latency P95 210.05 ms 204.99 ms ⚪ -2.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 89.79 204.99 12,426 194.46 -5.06
Account 161.5 317.72 654 11 +19.37
TablesDB 87.82 159.78 6,758 108.91 +5.49
Storage 81.81 181.77 3,270 53.75 -1.05
Functions 126.05 248.19 1,744 29.24 -16.91

Top API waits (after)

API request Max wait (ms)
account.name.update 623
functions.create 615.1
functions.variables.update 542.55
functions.variables.create 493.39
functions.delete 481.81

@greptile-apps
greptile-apps Bot dismissed their stale review September 26, 2026 14:28

Dismissed because a newer commit was pushed; Greptile will re-review the current head.

@ChiragAgg5k
ChiragAgg5k merged commit ee19d6d into main Sep 26, 2026
50 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.

1 participant