Skip to content

fix(specs): emit array schemas for custom array validators - #14265

Merged
ChiragAgg5k merged 1 commit into
mainfrom
fix/spec-array-validator
Oct 8, 2026
Merged

ChiragAgg5k merged 1 commit into
mainfrom
fix/spec-array-validator

Conversation

@ChiragAgg5k

@ChiragAgg5k ChiragAgg5k commented Oct 8, 2026 •

Copy link
Copy Markdown
Member

A param validator outside the spec generator's known list fell through to type: string, even when its getType() is array. The WAF Conditions validator is one of these, so every WAF create/update rule endpoint declared conditions as a string. The generated SDKs then sent a single string where the API expects an array (flagged on appwrite/sdk-for-go#83).

Such a validator now emits type: array. Its items schema is {} because the validator declares no item type. That matches how ArrayList of a mixed validator is emitted, and WAF conditions do accept both condition strings and condition objects.

testCustomArrayValidatorsEmitArraySchemas fails without the change.

Related: appwrite-labs/cloud#6413

A validator outside the known list fell through to a string schema even when getType() said array, so cloud's WAF Conditions param was typed as a string and every SDK sent conditions in the wrong JSON shape.
@luxor-code-review

luxor-code-review Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Review complete. No issues found — approved ✅.


This PR improves OpenAPI3 spec generation: array-typed validators previously emitted type: string; they now emit a valid type: array schema with free-form items, matching how SDK generators expect array parameters to be described. A unit test locks in the new output. All specialized scans and verification came back clean.

Files Change
src/Appwrite/SDK/Specification/Format/OpenAPI3.php Adds a TYPE_ARRAY branch emitting type: array with empty items in the validator switch
tests/unit/SDK/Specification/FormatTest.php Adds unit coverage asserting the array schema is emitted for TYPE_ARRAY validators

Reviewed commit: f7aeae5

@ChiragAgg5k ChiragAgg5k self-assigned this Oct 8, 2026
@ghost

ghost commented Oct 8, 2026

Copy link
Copy Markdown

🟢 Tier S · Ready to merge

The change is localized, and the added test covers the generated schema behavior without revealing a defect.

The OpenAPI generator now emits array schemas for custom validators whose type is array, using an unconstrained item schema when no item validator is available. A regression test verifies the emitted type, items, and default for a custom array validator.

Verdict New comments Fixed Still open
✅ Approved 0 0 0
📂 Walkthrough · 2
File Change
src/Appwrite/SDK/Specification/Format/OpenAPI3.php Recognize array-typed validators in the fallback schema generation and emit an array with unconstrained items.
tests/unit/SDK/Specification/FormatTest.php Add a regression test for custom array validator schemas.

Reviewed f7aeae5 · Details · Comment @hansi-codes review to re-run, or mention @hansi-codes with a question.

@ghost ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Tier S · Looks good to merge. Summary

@github-actions

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown

Security rules

No new WARNING or ERROR findings from security rules.

32 existing findings tracked in .semgrep/baseline.json
  • php.appwrite.guest-write-without-abuse-limit (17)
  • php.appwrite.permissive-write-permission (8)
  • php.appwrite.secret-compare-timing (5)
  • php.appwrite.weak-secret-env-default (2)

Posted by Checks / Rules. Re-runs update this comment in place. Rule details and baseline: .semgrep/README.md.

@github-actions

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown

✨ Benchmark results

Comparing main (before) → fix/spec-array-validator (after).

Metric Before After Change
🚀 Requests/sec 198.57 199.46 ⚪ +0.4%
⏱️ Latency P50 85.79 ms 87.57 ms ⚪ +2.1%
⏱️ Latency P95 207.18 ms 202.64 ms ⚪ -2.2%
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 87.57 202.64 12,540 199.46 -4.54
Account 173.63 322.87 660 11.17 +2.56
TablesDB 86.03 163.46 6,820 111.15 -7.3
Storage 78.21 167.32 3,300 55.83 -2.4
Functions 120.99 239.64 1,760 30.48 -3.29

Top API waits (after)

API request Max wait (ms)
account.name.update 500.78
account.prefs.update 478.07
tablesdb.rows.create 436.76
functions.delete 383.49
storage.files.create 364.86

@ChiragAgg5k
ChiragAgg5k merged commit 6a9cea4 into main Oct 8, 2026
62 checks passed
ChiragAgg5k added a commit that referenced this pull request Oct 8, 2026
Both check a whole array, so #14265 emitted them as arrays with untyped items and the SDKs typed WAF conditions and OAuth2 resource indicators as untyped values. Conditions always holds condition strings; an array-typed Multiple is only used for the resource indicator list, so both get string items in OpenAPI and GraphQL.
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