fix: add google discovery media upload operations#1271
Conversation
Greptile SummaryThis PR adds Google Discovery media upload support by generating a separate OpenAPI operation (e.g.,
Confidence Score: 5/5The change is self-contained, adding new schema fields and a new operation-builder function without modifying any existing logic. The new buildDiscoveryMediaUploadOperation mirrors the structure of buildDiscoveryOperation closely, guards all optional fields before access, and is exercised by two integration tests that validate the full pipeline down to bodyBase64 extraction. The upload URL uses rootUrl (not baseUrl), which is correct for the /upload/ Google endpoint pattern. No existing code paths were altered. No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Discovery method loop] --> B{supportsMediaUpload == true\nAND mediaUpload defined?}
B -- No --> C[Skip media upload]
B -- Yes --> D{simple protocol path present?}
D -- No --> C
D -- Yes --> E[buildDiscoveryMediaUploadOperation]
E --> F[Merge doc-level params\n+ method-level params]
F --> G[Inject uploadType=media\nquery parameter]
G --> H[Build operation:\noperationId toolPathMedia\npathTemplate = simple upload path\nbody = application/octet-stream]
H --> I[normalizeDiscoveryPathTemplate\non upload path]
I --> J[uniquePathKey to avoid conflicts]
J --> K[Register in paths map]
A --> L[buildDiscoveryOperation - original unchanged]
L --> M[Register in paths map]
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
A[Discovery method loop] --> B{supportsMediaUpload == true\nAND mediaUpload defined?}
B -- No --> C[Skip media upload]
B -- Yes --> D{simple protocol path present?}
D -- No --> C
D -- Yes --> E[buildDiscoveryMediaUploadOperation]
E --> F[Merge doc-level params\n+ method-level params]
F --> G[Inject uploadType=media\nquery parameter]
G --> H[Build operation:\noperationId toolPathMedia\npathTemplate = simple upload path\nbody = application/octet-stream]
H --> I[normalizeDiscoveryPathTemplate\non upload path]
I --> J[uniquePathKey to avoid conflicts]
J --> K[Register in paths map]
A --> L[buildDiscoveryOperation - original unchanged]
L --> M[Register in paths map]
Reviews (3): Last reviewed commit: "fix: add google discovery media upload o..." | Re-trigger Greptile |
ed452f0 to
a947d90
Compare
a947d90 to
e1c04cd
Compare
|
thanks! |
Summary
Fix Google Discovery media upload modeling so upload-capable methods expose a binary request body instead of metadata-only JSON.
supportsMediaUploadandmediaUploadfrom Google Discovery method definitions.files.createMediaandfiles.updateMedia./upload/....files.createMediaisPOSTandfiles.updateMediaisPATCH.uploadType=mediaand anapplication/octet-streamrequest body, which is exposed asbodyBase64by existing OpenAPI extraction.Why
Drive
files.createadvertised media upload support, but Executor generated only the metadata JSON operation. Calling it withuploadType=mediahad no binary/media body path and produced 0-byte Drive files.Validation
bun run --cwd packages/plugins/google test -- src/sdk/discovery.test.tsbun run --cwd packages/plugins/google testbun run --cwd packages/plugins/openapi test -- src/sdk/non-json-body.test.ts src/sdk/index.test.tsbun run formatbun run format:checkbun run lintbunx tsgo --noEmitgit diff --check