Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fix-google-photos-upload-path.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@executor-js/plugin-openapi": patch
---

Use the versioned Google Photos raw upload endpoint so generated upload tools send media to `/v1/uploads` instead of the invalid `/uploads` path.
36 changes: 36 additions & 0 deletions packages/plugins/openapi/src/providers/google/discovery.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,42 @@ it.effect("marks Google Discovery media-download methods as binary responses", (
}),
);

it.effect("uses the versioned Google Photos raw upload endpoint", () =>
Effect.gen(function* () {
const result = yield* convertGoogleDiscoveryToOpenApi({
discoveryUrl: "https://www.googleapis.com/discovery/v1/apis/photoslibrary/v1/rest",
// @effect-diagnostics-next-line preferSchemaOverJson:off
documentText: JSON.stringify({
name: "photoslibrary",
version: "v1",
title: "Google Photos Library API",
rootUrl: "https://photoslibrary.googleapis.com/",
servicePath: "",
auth: {
oauth2: {
scopes: {
"https://www.googleapis.com/auth/photoslibrary.appendonly": {
description: "Upload to Google Photos",
},
},
},
},
resources: {},
schemas: {},
}),
});

const spec = decodeConvertedSpec(result.specText);
const upload = spec.paths["/v1/uploads"]?.post;
expect(upload).toMatchObject({
operationId: "photoslibrary.mediaItems.upload",
"x-executor-toolPath": "photoslibrary.mediaItems.upload",
"x-executor-pathTemplate": "/v1/uploads",
servers: [{ url: "https://photoslibrary.googleapis.com/" }],
});
}),
);

it.effect("supplies documented scopes when Picker Discovery omits auth metadata", () =>
Effect.gen(function* () {
const result = yield* convertGoogleDiscoveryToOpenApi({
Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/openapi/src/providers/google/discovery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -829,7 +829,7 @@ const GOOGLE_OAUTH_SECURITY_SCHEME = "googleOAuth2";
const GOOGLE_PHOTOS_LIBRARY_SERVICE = "photoslibrary";
const GOOGLE_PHOTOS_APPENDONLY_SCOPE = "https://www.googleapis.com/auth/photoslibrary.appendonly";
const GOOGLE_PHOTOS_UPLOAD_TOOL_PATH = "photoslibrary.mediaItems.upload";
const GOOGLE_PHOTOS_UPLOAD_PATH = "/uploads";
const GOOGLE_PHOTOS_UPLOAD_PATH = "/v1/uploads";

const isGooglePhotosService = (service: string): boolean =>
service === GOOGLE_PHOTOS_LIBRARY_SERVICE || service === GOOGLE_PHOTOS_PICKER_SERVICE;
Expand Down