Skip to content

feat(sdk): support PDF response content type - #13504

Merged
ChiragAgg5k merged 3 commits into
mainfrom
feat/sdk-pdf-content-type
Sep 6, 2026
Merged

ChiragAgg5k merged 3 commits into
mainfrom
feat/sdk-pdf-content-type

Conversation

@ChiragAgg5k

Copy link
Copy Markdown
Member

What does this PR do?

Adds ContentType::PDF = 'application/pdf' to the SDK metadata enum.

PDF endpoints can now declare contentType: ContentType::PDF with a Response::MODEL_NONE response. The existing OpenAPI generator emits the precise binary contract:

responses:
  '200':
    description: File
    content:
      application/pdf:
        schema:
          type: string
          format: binary

This is needed for Cloud invoice download/view specifications, whose runtime responses are PDFs. Their older PaymentMethod/JSON metadata was masked by the removed x-appwrite.type override. A generic ContentType::ANY is compatible with binary inference, but application/pdf is the accurate permanent declaration.

This PR only adds the enum value and regression coverage. It does not modify endpoint runtime behavior, Cloud dependency pins, or Cloud invoice declarations. Cloud can adopt ContentType::PDF after updating its server-ce dependency.

Tests

  • Parameterized the existing binary-response specification test for PNG and PDF, asserting the exact response content map, including the media type and string/binary schema.
  • Before adding the enum, the new PDF case fails with Undefined constant Appwrite\SDK\ContentType::PDF.
  • vendor/bin/phpunit tests/unit/SDK: 34 tests, 172 assertions passed.
  • composer lint src/Appwrite/SDK/ContentType.php tests/unit/SDK/Specification/FormatTest.php: passed.
  • git diff --check: passed.

@greptile-apps

greptile-apps Bot commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

Adds an application/pdf SDK content type and regression coverage confirming that PDF responses generate an OpenAPI string/binary schema.

  • Introduces ContentType::PDF.
  • Parameterizes binary-response coverage for PNG and PDF.
  • Does not change endpoint runtime behavior.

Confidence Score: 5/5

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

The new PDF enum value reaches the existing generic binary schema generation path, and the regression test verifies the complete media-type response map using a supported test pattern.

Important Files Changed

Filename Overview
src/Appwrite/SDK/ContentType.php Adds the PDF media type to the SDK content-type enum; existing generic binary-response generation handles it correctly.
tests/unit/SDK/Specification/FormatTest.php Extends the binary OpenAPI response test with PNG and PDF cases using the repository’s established PHPUnit data-provider pattern.

Reviews (2): Last reviewed commit: "test: yield binary response data provide..." | Re-trigger Greptile

@github-actions

github-actions Bot commented Sep 6, 2026 •

Copy link
Copy Markdown

✨ Benchmark results

Comparing main (before) → feat/sdk-pdf-content-type (after).

Metric Before After Change
🚀 Requests/sec 204.8 205.12 ⚪ +0.2%
⏱️ Latency P50 87.39 ms 87.2 ms ⚪ -0.2%
⏱️ Latency P95 190 ms 189.93 ms ⚪ 0%
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.2 189.93 12,711 205.12 -0.08
Account 153.64 280.41 669 11.1 -16.22
TablesDB 88.29 161.58 6,913 113.08 -3.73
Storage 72.2 156.74 3,345 57.25 -3.15
Functions 116.16 218.71 1,784 31.2 +7.16

Top API waits (after)

API request Max wait (ms)
account.prefs.update 474.15
functions.variables.update 437.35
tablesdb.rows.delete 430.46
functions.create 421.96
storage.files.create 397.28

@ChiragAgg5k
ChiragAgg5k merged commit bd66764 into main Sep 6, 2026
167 of 171 checks passed
@ChiragAgg5k
ChiragAgg5k deleted the feat/sdk-pdf-content-type branch September 6, 2026 18:09
@ChiragAgg5k ChiragAgg5k mentioned this pull request Sep 10, 2026
2 of 4 tasks
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