You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat(specs): add standard OpenAPI request examples - #13918
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 transactionvalue:
commit: truerollback:
summary: Roll back the transactionvalue:
rollback: true
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:
{
"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:
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.
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.
[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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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,operationsordraft.Changes
requestExamplesfield to Appwrite's internal SDKMethodmetadata and emit it underrequestBody.content[mediaType].examples.x-appwriteor the SDK alias extension.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:
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
queriesparameter onDELETE /tablesdb/{databaseId}/tables/{tableId}/rowsnow has a single schema-level example, using existing exporter support: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
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_APP_SDK_PREVIEW=enabled.exampleandexamplesfields differ, including no changes tox-appwrite.openapi-spec-validator==0.7.2: zero OpenAPI 3.0 validation errors.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.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.