Skip to content

Commit 449a949

Browse files
committed
do not require schema version on manifest handler
1 parent 126493d commit 449a949

File tree

3 files changed

+15
-108
lines changed

3 files changed

+15
-108
lines changed

.changeset/silent-walls-heal.md

-92
This file was deleted.

src/handlers/actions/manifest-action-handler.test.ts

+9-6
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ describe("ManifestActionHandler", () => {
3939
expect(manifestFactory).toHaveBeenCalledWith({
4040
appBaseUrl: "http://example.com",
4141
request: {},
42-
schemaVersion: 3.20,
42+
schemaVersion: 3.2,
4343
});
4444
});
4545

@@ -64,18 +64,21 @@ describe("ManifestActionHandler", () => {
6464
expect(result.status).toBe(405);
6565
expect(result.body).toBe("Method not allowed");
6666
expect(manifestFactory).not.toHaveBeenCalled();
67-
})
67+
});
6868

69-
it("should return 400 when receives null schema version header from unsupported legacy Saleor version", async () => {
69+
/**
70+
* api/manifest endpoint is GET and header should be optional. It can be used to install the app eventually,
71+
* but also to preview the manifest from the plain GET request
72+
*/
73+
it("should NOT return 400 when receives null schema version header from unsupported legacy Saleor version", async () => {
7074
adapter.getHeader = vi.fn().mockReturnValue(null);
7175
const handler = new ManifestActionHandler(adapter);
7276

7377
const manifestFactory = vi.fn().mockResolvedValue(mockManifest);
7478

7579
const result = await handler.handleAction({ manifestFactory });
7680

77-
expect(result.status).toBe(400);
78-
expect(result.body).toBe("Missing schema version header");
79-
expect(manifestFactory).not.toHaveBeenCalled();
81+
expect(result.status).toBe(200);
82+
expect(manifestFactory).toHaveBeenCalled();
8083
});
8184
});

src/handlers/actions/manifest-action-handler.ts

+6-10
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,12 @@ export type CreateManifestHandlerOptions<T> = {
1414
manifestFactory(context: {
1515
appBaseUrl: string;
1616
request: T;
17-
/** Added in Saleor 3.15 */
18-
schemaVersion: number;
17+
/**
18+
* Schema version is optional. During installation, Saleor will send it,
19+
* so manifest can be generated according to the version. But it may
20+
* be also requested from plain GET from the browser, so it may not be available
21+
*/
22+
schemaVersion?: number;
1923
}): AppManifest | Promise<AppManifest>;
2024
};
2125

@@ -36,14 +40,6 @@ export class ManifestActionHandler<I> implements ActionHandlerInterface {
3640
return invalidMethodResponse;
3741
}
3842

39-
if (!schemaVersion) {
40-
return {
41-
status: 400,
42-
bodyType: "string",
43-
body: "Missing schema version header",
44-
};
45-
}
46-
4743
try {
4844
const manifest = await options.manifestFactory({
4945
appBaseUrl: baseURL,

0 commit comments

Comments
 (0)