diff --git a/src/__tests__/api.test.ts b/src/__tests__/api.test.ts
index 0645f00..71e0f9c 100644
--- a/src/__tests__/api.test.ts
+++ b/src/__tests__/api.test.ts
@@ -626,6 +626,26 @@ describe("OpenAPI spec", () => {
expect(paths).toContain("/v1/convert/markdown");
expect(paths).toContain("/health");
});
+
+ it("PdfOptions schema includes all valid format values and waitUntil field", async () => {
+ const res = await fetch(`${BASE}/openapi.json`);
+ const spec = await res.json();
+
+ const pdfOptions = spec.components.schemas.PdfOptions;
+ expect(pdfOptions).toBeDefined();
+
+ // Check that all 11 format values are included
+ const expectedFormats = ["Letter", "Legal", "Tabloid", "Ledger", "A0", "A1", "A2", "A3", "A4", "A5", "A6"];
+ expect(pdfOptions.properties.format.enum).toEqual(expectedFormats);
+
+ // Check that waitUntil field exists with correct enum values
+ expect(pdfOptions.properties.waitUntil).toBeDefined();
+ expect(pdfOptions.properties.waitUntil.enum).toEqual(["load", "domcontentloaded", "networkidle0", "networkidle2"]);
+
+ // Check that headerTemplate and footerTemplate descriptions mention 100KB limit
+ expect(pdfOptions.properties.headerTemplate.description).toContain("100KB");
+ expect(pdfOptions.properties.footerTemplate.description).toContain("100KB");
+ });
});
describe("404 handler", () => {
diff --git a/src/swagger.ts b/src/swagger.ts
index 60994f5..9d48267 100644
--- a/src/swagger.ts
+++ b/src/swagger.ts
@@ -47,7 +47,7 @@ const options: swaggerJsdoc.Options = {
properties: {
format: {
type: "string",
- enum: ["A4", "Letter", "Legal", "A3", "A5", "Tabloid"],
+ enum: ["Letter", "Legal", "Tabloid", "Ledger", "A0", "A1", "A2", "A3", "A4", "A5", "A6"],
default: "A4",
description: "Page size. Ignored if width/height are set.",
},
@@ -76,13 +76,18 @@ const options: swaggerJsdoc.Options = {
default: "document.pdf",
description: "Suggested filename for the PDF download",
},
+ waitUntil: {
+ type: "string",
+ enum: ["load", "domcontentloaded", "networkidle0", "networkidle2"],
+ description: "Wait condition for page rendering before PDF generation.",
+ },
headerTemplate: {
type: "string",
- description: "HTML template for the page header. Requires displayHeaderFooter: true. Use these CSS classes for dynamic values: date, title, url, pageNumber, totalPages. Example: ' / '",
+ description: "HTML template for the page header. Requires displayHeaderFooter: true. Use these CSS classes for dynamic values: date, title, url, pageNumber, totalPages. Maximum size: 100KB. Example: ' / '",
},
footerTemplate: {
type: "string",
- description: "HTML template for the page footer. Requires displayHeaderFooter: true. Supports the same CSS classes as headerTemplate.",
+ description: "HTML template for the page footer. Requires displayHeaderFooter: true. Supports the same CSS classes as headerTemplate. Maximum size: 100KB.",
},
displayHeaderFooter: {
type: "boolean",