Skip to content
Merged
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
9 changes: 9 additions & 0 deletions packages/api/scripts/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,15 @@ export function sanitizeOpenApiSchema(
sanitized.pattern = UUID_PATTERN;
}

// The spec's `date-time` patterns reject timestamps the Management API
// itself emits: most are Z-anchored, and even the most permissive variant
// rejects offset-less values and the lowercase `t`/`z` RFC 3339 §5.6 allows
// (supabase/cli#6115). Keeping any of them means owning a guess about every
// shape the API may serialize, so keep `format` and drop the pattern.
if (sanitized.type === "string" && sanitized.format === "date-time") {
delete sanitized.pattern;
Comment thread
7ttp marked this conversation as resolved.
}

return sanitized;
}

Expand Down
21 changes: 21 additions & 0 deletions packages/api/scripts/generate.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,27 @@ describe("generate", () => {
);
});

test("drops the spec's Z-only pattern from date-time strings (#6115)", () => {
expect(
renderOpenApiSchema({
type: "string",
format: "date-time",
pattern: "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$",
nullable: true,
}),
).toBe('Schema.Union([Schema.String.annotate({ "format": "date-time" }), Schema.Null])');
});

test("drops even an offset-tolerant date-time pattern (#6115)", () => {
// The spec's most permissive variant still rejects offset-less values and
// the lowercase `t`/`z` RFC 3339 §5.6 allows, so no date-time pattern survives.
const offsetTolerant =
"^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(Z|[+-]\\d{2}:\\d{2})$";
expect(
renderOpenApiSchema({ type: "string", format: "date-time", pattern: offsetTolerant }),
).not.toContain("isPattern");
});

test("accepts booleans for string-encoded boolean query parameters", () => {
expect(
normalizeQueryParameterSchema(
Expand Down
Loading
Loading