diff --git a/adapter/supabase.go b/adapter/supabase.go new file mode 100644 index 0000000..d6cb188 --- /dev/null +++ b/adapter/supabase.go @@ -0,0 +1,90 @@ +package adapter + +import ( + "context" + "encoding/json" + "fmt" + "time" + + "github.com/patch-it-dev/patch-it-plugins/fetch" +) + +// Variables, not constants, only so tests can point them at a local server. +var ( + // supabaseCommitsURL lists the commits that changed the Management API + // spec in supabase/supabase, newest first; with per_page=1, the newest. + supabaseCommitsURL = "https://api.github.com/repos/supabase/supabase/commits?path=apps/docs/spec/api_v1_openapi.json&per_page=1" + // supabaseCommitURL is one commit, for its date. + supabaseCommitURL = "https://api.github.com/repos/supabase/supabase/commits/%s" + // supabaseSpecURLTemplate is the Management API spec (api.supabase.com) + // at one commit. Supabase serves it live at + // https://api.supabase.com/api/v1-json, which has no versions; the docs + // copy in supabase/supabase is the same spec, committed when it changes + // (90 commits from 2024-05-31 to 2026-11-18), and a commit never changes. + supabaseSpecURLTemplate = "https://raw.githubusercontent.com/supabase/supabase/%s/apps/docs/spec/api_v1_openapi.json" +) + +// Supabase adapts the Supabase Management API spec in supabase/supabase for +// the openapi plugin. The repo tags no spec releases, so a tag here is the +// commit that last changed the spec. +type Supabase struct{} + +var _ Adapter = Supabase{} + +func (Supabase) API() string { return "supabase" } + +// LatestTag is the SHA of the newest commit that changed the spec. +func (Supabase) LatestTag(ctx context.Context) (string, error) { + body, err := fetch.Get(ctx, supabaseCommitsURL, githubHeaders()) + if err != nil { + return "", fmt.Errorf("looking up supabase's latest spec commit: %w", err) + } + var commits []struct { + SHA string `json:"sha"` + } + if err := json.Unmarshal(body, &commits); err != nil { + return "", fmt.Errorf("parsing github commits response: %w", err) + } + if len(commits) == 0 || commits[0].SHA == "" { + return "", fmt.Errorf("github lists no commit that changed the supabase spec") + } + return commits[0].SHA, nil +} + +// Fetch downloads the spec at commit sha. +// +// Version is the commit's date (YYYY-MM-DD): the Management API has no +// version of its own (`/v1`, info.version a fixed "1.0.0", checked +// 2026-11-19), so the date the spec changed is the closest thing to "the API +// version the change arrived in". +func (Supabase) Fetch(ctx context.Context, sha string) (Spec, error) { + meta, err := fetch.Get(ctx, fmt.Sprintf(supabaseCommitURL, sha), githubHeaders()) + if err != nil { + return Spec{}, fmt.Errorf("looking up supabase spec commit %s: %w", sha, err) + } + var commit struct { + SHA string `json:"sha"` + Commit struct { + Committer struct { + Date time.Time `json:"date"` + } `json:"committer"` + } `json:"commit"` + } + if err := json.Unmarshal(meta, &commit); err != nil { + return Spec{}, fmt.Errorf("parsing github commit %s: %w", sha, err) + } + if commit.SHA == "" || commit.Commit.Committer.Date.IsZero() { + return Spec{}, fmt.Errorf("github commit %s has no sha or date", sha) + } + // Pin to the full SHA even when given a short one: the citation must + // name exactly one document. + url := fmt.Sprintf(supabaseSpecURLTemplate, commit.SHA) + body, err := fetch.Get(ctx, url, nil) // raw.githubusercontent.com needs no auth + if err != nil { + return Spec{}, fmt.Errorf("fetching supabase spec %s: %w", sha, err) + } + if !json.Valid(body) { + return Spec{}, fmt.Errorf("supabase spec %s is not valid json", sha) + } + return Spec{Content: body, Version: commit.Commit.Committer.Date.UTC().Format("2006-01-02"), SourceURL: url}, nil +} diff --git a/adapter/supabase_test.go b/adapter/supabase_test.go new file mode 100644 index 0000000..96ddea2 --- /dev/null +++ b/adapter/supabase_test.go @@ -0,0 +1,90 @@ +package adapter + +import ( + "context" + "net/http" + "net/http/httptest" + "strings" + "testing" +) + +// fakeSupabaseGitHub serves the commits list, one commit, and specs by path. +func fakeSupabaseGitHub(t *testing.T, commitsJSON string, commits, specs map[string]string) *httptest.Server { + t.Helper() + srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + switch { + case r.URL.Path == "/commits": + w.Write([]byte(commitsJSON)) + case strings.HasPrefix(r.URL.Path, "/commits/"): + body, ok := commits[strings.TrimPrefix(r.URL.Path, "/commits/")] + if !ok { + http.Error(w, `{"message":"No commit found"}`, http.StatusUnprocessableEntity) + return + } + w.Write([]byte(body)) + default: + body, ok := specs[r.URL.Path] + if !ok { + http.NotFound(w, r) + return + } + w.Write([]byte(body)) + } + })) + t.Cleanup(srv.Close) + oldList, oldOne, oldSpec := supabaseCommitsURL, supabaseCommitURL, supabaseSpecURLTemplate + supabaseCommitsURL = srv.URL + "/commits" + supabaseCommitURL = srv.URL + "/commits/%s" + supabaseSpecURLTemplate = srv.URL + "/%s/spec.json" + t.Cleanup(func() { supabaseCommitsURL, supabaseCommitURL, supabaseSpecURLTemplate = oldList, oldOne, oldSpec }) + return srv +} + +const fullSHA = "eb21ae25f7954ea1e5db34209ff69fce597b0ae3" + +func TestSupabaseLatestTagIsTheNewestSpecCommit(t *testing.T) { + fakeSupabaseGitHub(t, `[{"sha":"`+fullSHA+`"},{"sha":"older"}]`, nil, nil) + tag, err := Supabase{}.LatestTag(context.Background()) + if err != nil || tag != fullSHA { + t.Errorf("got %q, %v; want %s", tag, err, fullSHA) + } +} + +func TestSupabaseLatestTagRejectsNoCommit(t *testing.T) { + fakeSupabaseGitHub(t, `[]`, nil, nil) + if _, err := (Supabase{}).LatestTag(context.Background()); err == nil { + t.Error("no commit: want an error") + } +} + +// The version is the commit's date, since the Management API has none (its +// info.version is a fixed 1.0.0); the source is pinned to the full SHA even +// when a short one is asked for, and the content is passed through. +func TestSupabaseFetchPinsTheFullSHAAndDatesByCommit(t *testing.T) { + const body = `{"openapi":"3.0.0","info":{"version":"1.0.0"},"paths":{}}` + srv := fakeSupabaseGitHub(t, "", map[string]string{ + "eb21ae25": `{"sha":"` + fullSHA + `","commit":{"committer":{"date":"2026-06-29T08:15:50Z"}}}`, + }, map[string]string{"/" + fullSHA + "/spec.json": body}) + spec, err := Supabase{}.Fetch(context.Background(), "eb21ae25") + if err != nil { + t.Fatal(err) + } + if spec.Version != "2026-06-29" || spec.SourceURL != srv.URL+"/"+fullSHA+"/spec.json" || string(spec.Content) != body { + t.Errorf("got version %q, url %s, content %s", spec.Version, spec.SourceURL, spec.Content) + } +} + +func TestSupabaseFetchFailures(t *testing.T) { + commit := `{"sha":"` + fullSHA + `","commit":{"committer":{"date":"2026-06-29T08:15:50Z"}}}` + for name, c := range map[string]struct{ commits, specs map[string]string }{ + "unknown commit": {nil, nil}, + "commit without date": {map[string]string{"x": `{"sha":"` + fullSHA + `"}`}, nil}, + "spec missing": {map[string]string{"x": commit}, nil}, + "invalid json": {map[string]string{"x": commit}, map[string]string{"/" + fullSHA + "/spec.json": ""}}, + } { + fakeSupabaseGitHub(t, "", c.commits, c.specs) + if _, err := (Supabase{}).Fetch(context.Background(), "x"); err == nil { + t.Errorf("%s: want an error", name) + } + } +} diff --git a/diff/diff.go b/diff/diff.go index eb312f6..0e53200 100644 --- a/diff/diff.go +++ b/diff/diff.go @@ -105,6 +105,14 @@ type Options struct { // deprecated, for a spec that often says so in words and not in the // `deprecated` flag. Nil reads only the flag. DeprecatedSummary func(summary string) bool + + // QuoteDeprecatedOperation makes a deprecation by the flag cite the whole + // operation, not the bare `true`: for a spec that says why in the + // operation's description ("This endpoint is deprecated - use the deploy + // endpoint"). The excerpt is the operation serialized with sorted keys, so + // `deprecated` comes before `description` and survives the 2,000-character + // cut (only a `callbacks` key would sort ahead of it). + QuoteDeprecatedOperation bool } // OperationDeprecated reports whether an operation object is marked @@ -281,9 +289,12 @@ func (d *differ) paths(oldPaths, newPaths map[string]any) { d.add(w, OperationRemoved, "", true, oldOp) default: if !d.opts.OperationDeprecated(oldOp) && d.opts.OperationDeprecated(newOp) { - if truthy(newOp["deprecated"]) { + switch { + case truthy(newOp["deprecated"]) && d.opts.QuoteDeprecatedOperation: + d.add(w, OperationDeprecated, "", false, newOp) + case truthy(newOp["deprecated"]): d.add(w.child("deprecated"), OperationDeprecated, "", false, newOp["deprecated"]) - } else { + default: // Said in words: the summary is the evidence. d.add(w.child("summary"), OperationDeprecated, "", false, newOp["summary"]) } diff --git a/diff/options_test.go b/diff/options_test.go index 8b9e4ed..b819ac7 100644 --- a/diff/options_test.go +++ b/diff/options_test.go @@ -116,3 +116,19 @@ func TestPathTemplatesAmbiguousFallsBackToExactPaths(t *testing.T) { t.Errorf("got %v, want GET /d/{name} removed", got) } } + +// With QuoteDeprecatedOperation, a deprecation by the flag cites the whole +// operation, where the vendor says why; without, the bare `true`. +func TestQuoteDeprecatedOperation(t *testing.T) { + oldSpec := mustParse(t, pathsSpec(`"/f":{"post":{"description":"Creates a function."}}`)) + newSpec := mustParse(t, pathsSpec(`"/f":{"post":{"deprecated":true,"description":"This endpoint is deprecated - use the deploy endpoint."}}`)) + got := ChangesWith(oldSpec, newSpec, Options{QuoteDeprecatedOperation: true}) + op, _ := got[0].Node.(map[string]any) + if len(got) != 1 || got[0].Kind != OperationDeprecated || got[0].Pointer != "/paths/~1f/post" || op["description"] != "This endpoint is deprecated - use the deploy endpoint." { + t.Errorf("got %+v, want one operation_deprecated citing the operation", got) + } + got = Changes(oldSpec, newSpec) + if len(got) != 1 || got[0].Pointer != "/paths/~1f/post/deprecated" || got[0].Node != true { + t.Errorf("without the option: %+v, want the flag cited", got) + } +} diff --git a/docs/plugins.md b/docs/plugins.md index 1347fbe..9a84e15 100644 --- a/docs/plugins.md +++ b/docs/plugins.md @@ -14,6 +14,7 @@ The table between the `plugins:start` and `plugins:end` markers is also publishe | [`github`](https://github.com/patch-it-dev/patch-it-plugins/blob/main/providers/github.md) | GitHub | REST API changes between dated API versions | `openapi` | [github/rest-api-description](https://github.com/github/rest-api-description) | live | | [`gitlab`](https://github.com/patch-it-dev/patch-it-plugins/blob/main/providers/gitlab.md) | GitLab | REST API changes between releases, request side only (what callers send) | `openapi` | [gitlab-org/gitlab `doc/api/openapi`](https://gitlab.com/gitlab-org/gitlab/-/tree/master/doc/api/openapi) | live | | [`vercel`](https://github.com/patch-it-dev/patch-it-plugins/blob/main/providers/vercel.md) | Vercel | REST API operations deprecated, and deprecated operations removed, between SDK releases of the spec | `openapi` | [vercel/sdk](https://github.com/vercel/sdk) (`vercel-spec.json`) | paused: merged, not in a tagged release yet, so patch-it's hosted ingestion service doesn't run it | +| [`supabase`](https://github.com/patch-it-dev/patch-it-plugins/blob/main/providers/supabase.md) | Supabase | Management API operations deprecated, and deprecated operations removed, between commits of the spec | `openapi` | [supabase/supabase](https://github.com/supabase/supabase) (`apps/docs/spec/api_v1_openapi.json`) | paused: merged, not in a tagged release yet, so patch-it's hosted ingestion service doesn't run it | | [`openai-models`](https://github.com/patch-it-dev/patch-it-plugins/blob/main/providers/openai-models.md) | OpenAI | Model deprecations and shutdown dates (Chat Completions and Responses text models) | `retirements` | [OpenAI deprecations](https://developers.openai.com/api/docs/deprecations) | live | | [`anthropic-models`](https://github.com/patch-it-dev/patch-it-plugins/blob/main/providers/anthropic-models.md) | Anthropic | Model deprecations and retirement dates (Messages API models) | `retirements` | [Anthropic model deprecations](https://platform.claude.com/docs/en/about-claude/model-deprecations) | live | | [`anthropic`](https://github.com/patch-it-dev/patch-it-plugins/blob/main/providers/anthropic.md) | Anthropic | Parameters removed from `messages.create()` and friends in the Python SDK 1.0 | `migrationguide` | [anthropic-sdk-python MIGRATION.md](https://github.com/anthropics/anthropic-sdk-python/blob/v1.0.0/MIGRATION.md) | live | diff --git a/plugins/openapi/openapi.go b/plugins/openapi/openapi.go index 0ce8267..92d15a9 100644 --- a/plugins/openapi/openapi.go +++ b/plugins/openapi/openapi.go @@ -1,5 +1,5 @@ // Package openapi is the source plugin for an API that publishes an OpenAPI -// spec per release (Stripe, Datadog, GitLab, GitHub, Vercel): fetch the newest spec, +// spec per release (Stripe, Datadog, GitLab, GitHub, Vercel, Supabase): fetch the newest spec, // diff it against the last one seen, normalize the changes into events, and // attach migration hints from the API's changelog when it has one. It can also // replay two given releases. @@ -33,6 +33,9 @@ func init() { // No Hints: Vercel's changelog is product news, not keyed by API change. // Only operation deprecations and removals are kept: see vercelKeep. plugin.Register(Plugin{Adapter: adapter.Vercel{}, Diff: vercelDiff, Keep: vercelKeep}) + // No Hints: Supabase's changelog is platform news, not keyed by + // operation. Only operation deprecations and removals: see supabase.go. + plugin.Register(Plugin{Adapter: adapter.Supabase{}, Diff: supabaseDiff, Keep: supabaseKeep}) } // requestSide keeps the changes to what callers send. GitLab's response diff --git a/plugins/openapi/registered_test.go b/plugins/openapi/registered_test.go index 8ede23e..355db8c 100644 --- a/plugins/openapi/registered_test.go +++ b/plugins/openapi/registered_test.go @@ -8,7 +8,7 @@ import ( ) func TestRegistersItself(t *testing.T) { - for _, a := range []adapter.Adapter{adapter.Stripe{}, adapter.Datadog{}, adapter.GitLab{}, adapter.GitHub{}, adapter.Vercel{}} { + for _, a := range []adapter.Adapter{adapter.Stripe{}, adapter.Datadog{}, adapter.GitLab{}, adapter.GitHub{}, adapter.Vercel{}, adapter.Supabase{}} { kittest.Registered(t, Plugin{Adapter: a}) } } diff --git a/plugins/openapi/supabase.go b/plugins/openapi/supabase.go new file mode 100644 index 0000000..840261f --- /dev/null +++ b/plugins/openapi/supabase.go @@ -0,0 +1,28 @@ +package openapi + +import "github.com/patch-it-dev/patch-it-plugins/diff" + +// supabaseDiff is how the Supabase Management API spec says what it says: +// +// - Deprecations use the `deprecated` flag, and the description sometimes +// says why ("This endpoint is deprecated - use the deploy endpoint."), so +// the event quotes the whole operation, not the bare `true`. +// - Path parameters get renamed, and that isn't a change for callers: +// /v1/branches/{branch_id}/merge became .../{branch_id_or_ref}/merge on +// 2025-09-11. +var supabaseDiff = diff.Options{PathTemplates: true, QuoteDeprecatedOperation: true} + +// supabaseKeep keeps operation deprecations, and removals of operations the +// old spec had marked deprecated. In the spec's history (90 commits, +// 2024-05-31 to 2026-11-18) that's 2 events: POST /v1/projects/{ref}/functions +// deprecated on 2025-02-19, GET /v1/projects/{ref}/analytics/endpoints/logs.all +// on 2026-06-29. Everything else is dropped: +// +// - 22 operations left the spec, none of them deprecated first: 14 +// analytics warehouse operations on 2024-07-15, 7 path-parameter renames +// (which PathTemplates pairs up anyway), and one that came back 12 +// days later. Without credentials every route answers 401, so whether a +// removed one still works can't be checked from outside. +// - Request and response property changes, new operations: not changes a +// caller has to fix, or not ones the spec's history shows reliably. +var supabaseKeep = deprecationsOnly(supabaseDiff) diff --git a/plugins/openapi/supabase_test.go b/plugins/openapi/supabase_test.go new file mode 100644 index 0000000..b6c549f --- /dev/null +++ b/plugins/openapi/supabase_test.go @@ -0,0 +1,180 @@ +package openapi + +import ( + "context" + "fmt" + "os" + "strings" + "testing" + + "github.com/patch-it-dev/patch-it-plugins/adapter" + "github.com/patch-it-dev/patch-it-plugins/event" + "github.com/patch-it-dev/patch-it-plugins/kit/kittest" +) + +// supabaseCommits are the spec commits saved under testdata/ (trimmed to the +// operations involved, values unchanged; checked 2026-11-19): short SHA -> +// full SHA and committer date. The source is Prettier-formatted (minified +// before 2025), so the excerpts are re-indented, not copied line for line. +var supabaseCommits = map[string][2]string{ + "57d668c6": {"57d668c6ce265d40cdc009ecadf8e3d80d17a310", "2025-02-10"}, + "bf04ff66": {"bf04ff6681062bde3edf9d646054b9a8b2ef286c", "2025-02-19"}, + "693bdc38": {"693bdc38d045353e5782f86febff4fddc82bb93a", "2026-06-22"}, + "eb21ae25": {"eb21ae25f7954ea1e5db34209ff69fce597b0ae3", "2026-06-29"}, + "8aef4a08": {"8aef4a08bf56e1e0e1eb8af316f7f0b2bcfd2e88", "2024-07-08"}, + "90b71e3e": {"90b71e3e42c5f933013e1a62acdc37c07e9378d7", "2024-07-15"}, + "de806266": {"de806266717abddb08e285f9dd6d17ad7d262b34", "2025-08-04"}, + "a5fc0527": {"a5fc0527045daaafd2a661146cac0b430adad20b", "2025-09-11"}, +} + +// fakeSupabaseAdapter serves the saved copies, cited by the real URL each was +// copied from, as adapter.Supabase.Fetch cites it. +type fakeSupabaseAdapter struct{ latest string } + +func (fakeSupabaseAdapter) API() string { return "supabase" } + +func (f fakeSupabaseAdapter) LatestTag(context.Context) (string, error) { return f.latest, nil } + +func (fakeSupabaseAdapter) Fetch(_ context.Context, tag string) (adapter.Spec, error) { + c, ok := supabaseCommits[tag] + if !ok { + return adapter.Spec{}, fmt.Errorf("no saved copy for %s", tag) + } + body, err := os.ReadFile(supabaseFile(tag)) + if err != nil { + return adapter.Spec{}, err + } + return adapter.Spec{Content: body, Version: c[1], SourceURL: supabaseURL(tag)}, nil +} + +func supabaseFile(tag string) string { return "testdata/supabase-" + tag + ".json" } + +func supabaseURL(tag string) string { + return "https://raw.githubusercontent.com/supabase/supabase/" + supabaseCommits[tag][0] + "/apps/docs/spec/api_v1_openapi.json" +} + +// supabasePlugin is the plugin exactly as registered, over the saved copies. +func supabasePlugin(latest string) Plugin { + return Plugin{Adapter: fakeSupabaseAdapter{latest: latest}, Diff: supabaseDiff, Keep: supabaseKeep} +} + +// The golden test: the two operations Supabase deprecated in the +// Management API spec's history. On 2025-02-19, POST +// /v1/projects/{ref}/functions ("This endpoint is deprecated - use the deploy +// endpoint."), here as a daily ingest. On 2026-06-29, GET +// /v1/projects/{ref}/analytics/endpoints/logs.all, the replay fixture: the +// flag alone, no reason yet. (On 2026-09-30 its description became "This +// endpoint has been removed and always responds with `410 Gone`", with the +// operation still in the spec: a change of words, which no diff sees.) +func TestSupabaseGolden(t *testing.T) { + ctx := context.Background() + s := openStore(t) + env := vercelEnv(s) + for _, tag := range []string{"57d668c6", "bf04ff66"} { + if rejected, err := kittest.Run(ctx, env, s, supabasePlugin(tag)); err != nil || rejected { + t.Fatalf("run %s: rejected=%v err=%v", tag, rejected, err) + } + } + if rejected, err := kittest.Replay(ctx, env, s, supabasePlugin(""), "693bdc38", "eb21ae25"); err != nil || rejected { + t.Fatalf("replay: rejected=%v err=%v", rejected, err) + } + + events := kittest.Stored(t, s) + want := map[string]string{ + "POST /v1/projects/{ref}/functions 2025-02-19": "bf04ff66", + "GET /v1/projects/{ref}/analytics/endpoints/logs.all 2026-06-29": "eb21ae25", + } + if len(events) != len(want) { + for _, e := range events { + t.Logf("got: %s", e.Description) + } + t.Fatalf("stored %d events, want %d", len(events), len(want)) + } + for _, e := range events { + tag, ok := want[e.Subject.Operation+" "+e.Version] + if !ok { + t.Errorf("unexpected event %s %s", e.Subject.Operation, e.Version) + continue + } + if e.ChangeType != event.ChangeTypeDeprecation || e.Breaking { + t.Errorf("%s: %s, want deprecation", e.Subject.Operation, e.ChangeType) + } + if e.SourceURL != supabaseURL(tag) { + t.Errorf("%s: source_url %s, want %s", e.Subject.Operation, e.SourceURL, supabaseURL(tag)) + } + // The whole operation is quoted, so the reason is in the excerpt. + if node := jsonNode(t, supabaseFile(tag), e.SourcePointer); node != e.SourceExcerpt && !truncated(e.SourceExcerpt, node) { + t.Errorf("%s: excerpt doesn't match %s#%s", e.Subject.Operation, tag, e.SourcePointer) + } + if !strings.Contains(e.SourceExcerpt, `"deprecated":true`) { + t.Errorf("%s: excerpt lacks the flag: %.200s", e.Subject.Operation, e.SourceExcerpt) + } + if tag == "bf04ff66" && !strings.Contains(e.SourceExcerpt, "This endpoint is deprecated - use the deploy endpoint.") { + t.Errorf("%s: excerpt lacks Supabase's reason: %.200s", e.Subject.Operation, e.SourceExcerpt) + } + } + kittest.Golden(t, "testdata/golden/supabase.json", events) +} + +// The pinned drop test. On 2024-07-15 the 14 analytics warehouse operations +// left the spec without ever being marked deprecated. Nothing says they were +// shut down, and without credentials every route answers 401, so it can't +// be checked: no event. +func TestSupabaseDropsRemovalsThatWerentDeprecated(t *testing.T) { + ctx := context.Background() + s := openStore(t) + if rejected, err := kittest.Replay(ctx, vercelEnv(s), s, supabasePlugin(""), "8aef4a08", "90b71e3e"); err != nil || rejected { + t.Fatalf("replay: rejected=%v err=%v", rejected, err) + } + if events := kittest.Stored(t, s); len(events) != 0 { + t.Fatalf("stored %d events, want none", len(events)) + } + // Without the filter the same pair reports all 14 removals. + s = openStore(t) + p := supabasePlugin("") + p.Keep = nil + if _, err := kittest.Replay(ctx, vercelEnv(s), s, p, "8aef4a08", "90b71e3e"); err != nil { + t.Fatal(err) + } + var removals int + for _, e := range kittest.Stored(t, s) { + if strings.Contains(e.Subject.Operation, "/analytics/warehouse/") && e.ChangeType == event.ChangeTypeBreaking { + removals++ + } + } + if removals != 14 { + t.Errorf("unfiltered: %d warehouse removals, want 14", removals) + } +} + +// On 2025-09-11 the /v1/branches/{branch_id} operations became +// /v1/branches/{branch_id_or_ref}: the same URLs. No event; by exact path, +// they'd read as removed. +func TestSupabaseBranchParameterRenameIsNoChange(t *testing.T) { + ctx := context.Background() + s := openStore(t) + p := supabasePlugin("") + p.Keep = nil // even unfiltered: the operations are paired, not removed + if _, err := kittest.Replay(ctx, vercelEnv(s), s, p, "de806266", "a5fc0527"); err != nil { + t.Fatal(err) + } + for _, e := range kittest.Stored(t, s) { + if e.ChangeType == event.ChangeTypeBreaking && strings.Contains(e.Description, "removed") && strings.Contains(e.Subject.Operation, "{branch_id}") { + t.Errorf("by template: %s", e.Description) + } + } + s = openStore(t) + p.Diff.PathTemplates = false + if _, err := kittest.Replay(ctx, vercelEnv(s), s, p, "de806266", "a5fc0527"); err != nil { + t.Fatal(err) + } + var removed int + for _, e := range kittest.Stored(t, s) { + if strings.HasPrefix(e.Description, "Operation ") && strings.HasSuffix(e.Description, " removed.") && strings.Contains(e.Subject.Operation, "{branch_id}") { + removed++ + } + } + if removed == 0 { + t.Error("by exact path no {branch_id} operation reads as removed; the fixture no longer shows the rename") + } +} diff --git a/plugins/openapi/testdata/README.md b/plugins/openapi/testdata/README.md index 9849764..acc1d11 100644 --- a/plugins/openapi/testdata/README.md +++ b/plugins/openapi/testdata/README.md @@ -11,5 +11,11 @@ Each pair is a real breaking change between two releases of a provider's own spe | `vercel-v1.18.6.json`, `vercel-v1.18.7.json` | https://raw.githubusercontent.com/vercel/sdk/v1.18.6/vercel-spec.json (and `v1.18.7`) | 2026-11-18 | Apache-2.0 (vercel/sdk) | `"/v4/domains/price": {` (in v1.18.6, gone in v1.18.7) | | `vercel-v1.6.2.json`, `vercel-v1.6.3.json` | https://raw.githubusercontent.com/vercel/sdk/v1.6.2/vercel-spec.json (and `v1.6.3`) | 2026-11-18 | Apache-2.0 (vercel/sdk) | `"/v1/log-drains": {` (in v1.6.2, gone in v1.6.3 without being deprecated, back in v1.15.0): the drop test | | `vercel-v1.28.64.json`, `vercel-v1.28.65.json` | https://raw.githubusercontent.com/vercel/sdk/v1.28.64/vercel-spec.json (and `v1.28.65`) | 2026-11-18 | Apache-2.0 (vercel/sdk) | `"/v2/sandboxes/drives/{nameOrId}": {` (`DELETE` moved here from `.../{name}` in v1.28.65) | +| `supabase-57d668c6.json`, `supabase-bf04ff66.json` | https://raw.githubusercontent.com/supabase/supabase/57d668c6ce265d40cdc009ecadf8e3d80d17a310/apps/docs/spec/api_v1_openapi.json (and `bf04ff6681062bde3edf9d646054b9a8b2ef286c`) | 2026-11-19 | Apache-2.0 (supabase/supabase) | "This endpoint is deprecated - use the deploy endpoint." (`POST /v1/projects/{ref}/functions`, new in `bf04ff66`) | +| `supabase-693bdc38.json`, `supabase-eb21ae25.json` | https://raw.githubusercontent.com/supabase/supabase/693bdc38d045353e5782f86febff4fddc82bb93a/apps/docs/spec/api_v1_openapi.json (and `eb21ae25f7954ea1e5db34209ff69fce597b0ae3`) | 2026-11-19 | Apache-2.0 (supabase/supabase) | `"deprecated": true` on `GET /v1/projects/{ref}/analytics/endpoints/logs.all` (new in `eb21ae25`) | +| `supabase-8aef4a08.json`, `supabase-90b71e3e.json` | https://raw.githubusercontent.com/supabase/supabase/8aef4a08bf56e1e0e1eb8af316f7f0b2bcfd2e88/apps/docs/spec/api_v1_openapi.json (and `90b71e3e42c5f933013e1a62acdc37c07e9378d7`) | 2026-11-19 | Apache-2.0 (supabase/supabase) | `/v1/projects/{ref}/analytics/warehouse/...` (14 operations in `8aef4a08`, none deprecated, all gone in `90b71e3e`): the drop test | +| `supabase-de806266.json`, `supabase-a5fc0527.json` | https://raw.githubusercontent.com/supabase/supabase/de806266717abddb08e285f9dd6d17ad7d262b34/apps/docs/spec/api_v1_openapi.json (and `a5fc0527045daaafd2a661146cac0b430adad20b`) | 2026-11-19 | Apache-2.0 (supabase/supabase) | `/v1/branches/{branch_id}` (in `de806266`), `/v1/branches/{branch_id_or_ref}` (in `a5fc0527`) | + +The Supabase copies keep each value unchanged but are re-indented: the source is Prettier-formatted (objects on one line where they fit), and minified on one line before 2025. Stripe's spec isn't saved here: its tests use small specs written inline. diff --git a/plugins/openapi/testdata/golden/supabase.json b/plugins/openapi/testdata/golden/supabase.json new file mode 100644 index 0000000..dbe6909 --- /dev/null +++ b/plugins/openapi/testdata/golden/supabase.json @@ -0,0 +1,44 @@ +[ + { + "id": 1, + "fingerprint": "sha256:880606fe624faa3f49480e13588a19e93562091d5a8f40c2a097f36fb329a604", + "api": "supabase", + "version": "2025-02-19", + "previous_version": "2025-02-10", + "change_type": "deprecation", + "breaking": false, + "subject": { + "type": "api_operation", + "kind": "operation", + "side": "request", + "operation": "POST /v1/projects/{ref}/functions" + }, + "description": "Operation POST /v1/projects/{ref}/functions marked deprecated.", + "source_url": "https://raw.githubusercontent.com/supabase/supabase/bf04ff6681062bde3edf9d646054b9a8b2ef286c/apps/docs/spec/api_v1_openapi.json", + "source_pointer": "/paths/~1v1~1projects~1{ref}~1functions/post", + "source_excerpt": "{\"deprecated\":true,\"description\":\"This endpoint is deprecated - use the deploy endpoint. Creates a function and adds it to the specified project.\",\"operationId\":\"v1-create-a-function\",\"parameters\":[{\"description\":\"Project ref\",\"in\":\"path\",\"name\":\"ref\",\"required\":true,\"schema\":{\"maxLength\":20,\"minLength\":20,\"type\":\"string\"}},{\"in\":\"query\",\"name\":\"slug\",\"required\":false,\"schema\":{\"pattern\":\"/^[A-Za-z0-9_-]+$/\",\"type\":\"string\"}},{\"in\":\"query\",\"name\":\"name\",\"required\":false,\"schema\":{\"type\":\"string\"}},{\"in\":\"query\",\"name\":\"verify_jwt\",\"required\":false,\"schema\":{\"type\":\"boolean\"}},{\"in\":\"query\",\"name\":\"import_map\",\"required\":false,\"schema\":{\"type\":\"boolean\"}},{\"in\":\"query\",\"name\":\"entrypoint_path\",\"required\":false,\"schema\":{\"type\":\"string\"}},{\"in\":\"query\",\"name\":\"import_map_path\",\"required\":false,\"schema\":{\"type\":\"string\"}}],\"requestBody\":{\"content\":{\"application/json\":{\"schema\":{\"$ref\":\"#/components/schemas/V1CreateFunctionBody\"}},\"application/vnd.denoland.eszip\":{\"schema\":{\"$ref\":\"#/components/schemas/V1CreateFunctionBody\"}}},\"required\":true},\"responses\":{\"201\":{\"content\":{\"application/json\":{\"schema\":{\"$ref\":\"#/components/schemas/FunctionResponse\"}}},\"description\":\"\"},\"403\":{\"description\":\"\"},\"500\":{\"description\":\"Failed to create project's function\"}},\"security\":[{\"bearer\":[]}],\"summary\":\"Create a function\",\"tags\":[\"Edge Functions\"]}", + "confidence": 1, + "detected_at": "2026-11-14T12:00:00Z" + }, + { + "id": 2, + "fingerprint": "sha256:9cdc7164ed43b50e19c232e8af7f43c3fbfe87aa18b96bf5e62d7e59ee47c7b0", + "api": "supabase", + "version": "2026-06-29", + "previous_version": "2026-06-22", + "change_type": "deprecation", + "breaking": false, + "subject": { + "type": "api_operation", + "kind": "operation", + "side": "request", + "operation": "GET /v1/projects/{ref}/analytics/endpoints/logs.all" + }, + "description": "Operation GET /v1/projects/{ref}/analytics/endpoints/logs.all marked deprecated.", + "source_url": "https://raw.githubusercontent.com/supabase/supabase/eb21ae25f7954ea1e5db34209ff69fce597b0ae3/apps/docs/spec/api_v1_openapi.json", + "source_pointer": "/paths/~1v1~1projects~1{ref}~1analytics~1endpoints~1logs.all/get", + "source_excerpt": "{\"deprecated\":true,\"description\":\"Executes a SQL query on the project's logs.\\n\\nEither the `iso_timestamp_start` and `iso_timestamp_end` parameters must be provided.\\nIf both are not provided, only the last 1 minute of logs will be queried.\\nThe timestamp range must be no more than 24 hours and is rounded to the nearest minute. If the range is more than 24 hours, a validation error will be thrown.\\n\\nNote: Unless the `sql` parameter is provided, only edge_logs will be queried. See the [log query docs](/docs/guides/telemetry/logs?queryGroups=product\\u0026product=postgres\\u0026queryGroups=source\\u0026source=edge_logs#querying-with-the-logs-explorer:~:text=logs%20from%20the-,Sources,-drop%2Ddown%3A) for all available sources.\\n\",\"operationId\":\"v1-get-project-logs-all\",\"parameters\":[{\"description\":\"Project ref\",\"in\":\"path\",\"name\":\"ref\",\"required\":true,\"schema\":{\"example\":\"abcdefghijklmnopqrst\",\"maxLength\":20,\"minLength\":20,\"pattern\":\"^[a-z]+$\",\"type\":\"string\"}},{\"description\":\"Custom SQL query to execute on the logs. See [querying logs](/docs/guides/telemetry/logs?queryGroups=product\\u0026product=postgres\\u0026queryGroups=source\\u0026source=edge_logs#querying-with-the-logs-explorer) for more details.\",\"in\":\"query\",\"name\":\"sql\",\"required\":false,\"schema\":{\"type\":\"string\"}},{\"in\":\"query\",\"name\":\"iso_timestamp_start\",\"required\":false,\"schema\":{\"example\":\"2025-03-01T00:00:00Z\",\"format\":\"date-time\",\"type\":\"string\"}},{\"in\":\"query\",\"name\":\"iso_timestamp_end\",\"required\":false,\"schema\":{\"example\":\"2025-03-01T23:59:59Z\",\"format\":\"date-time\",\"type\":\"string\"}}],\"responses\":{\"200\":{\"content\":{\"application/json\":{\"schema\":{\"$ref\":\"#/components/schemas/AnalyticsResponse\"}}},\"description\":\"\"},\"401\":{\"description\":\"Unauthorized\"},\"402\":{\"description\":\"Usage exceeded. Enable additional usage to continue querying\"},\"403\":{\"description\":\"Forbidden action\"},\"429\":{\"description\":\"Rate limit exceeded\"}},\"security\":[{\"bearer\":[]},{\"fga_permissions\":[\"analytics_logs_read\"]}],\"summary\":\"Gets pr…", + "confidence": 1, + "detected_at": "2026-11-14T12:00:00Z" + } +] diff --git a/plugins/openapi/testdata/supabase-57d668c6.json b/plugins/openapi/testdata/supabase-57d668c6.json new file mode 100644 index 0000000..0a902a8 --- /dev/null +++ b/plugins/openapi/testdata/supabase-57d668c6.json @@ -0,0 +1,178 @@ +{ + "openapi": "3.0.0", + "info": { + "title": "Supabase API (v1)", + "description": "Supabase API generated from the OpenAPI specification.
Visit [https://supabase.com/docs](https://supabase.com/docs) for a complete documentation.", + "version": "1.0.0", + "contact": {} + }, + "paths": { + "/v1/projects/{ref}/functions": { + "get": { + "operationId": "v1-list-all-functions", + "summary": "List all functions", + "description": "Returns all functions you've previously added to the specified project.", + "parameters": [ + { + "name": "ref", + "required": true, + "in": "path", + "description": "Project ref", + "schema": { + "minLength": 20, + "maxLength": 20, + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/FunctionResponse" + } + } + } + } + }, + "403": { + "description": "" + }, + "500": { + "description": "Failed to retrieve project's functions" + } + }, + "tags": [ + "Edge Functions" + ], + "security": [ + { + "bearer": [] + } + ] + }, + "post": { + "operationId": "v1-create-a-function", + "summary": "Create a function", + "description": "Creates a function and adds it to the specified project.", + "parameters": [ + { + "name": "ref", + "required": true, + "in": "path", + "description": "Project ref", + "schema": { + "minLength": 20, + "maxLength": 20, + "type": "string" + } + }, + { + "name": "slug", + "required": false, + "in": "query", + "schema": { + "pattern": "/^[A-Za-z0-9_-]+$/", + "type": "string" + } + }, + { + "name": "name", + "required": false, + "in": "query", + "schema": { + "type": "string" + } + }, + { + "name": "verify_jwt", + "required": false, + "in": "query", + "schema": { + "type": "boolean" + } + }, + { + "name": "import_map", + "required": false, + "in": "query", + "schema": { + "type": "boolean" + } + }, + { + "name": "entrypoint_path", + "required": false, + "in": "query", + "schema": { + "type": "string" + } + }, + { + "name": "import_map_path", + "required": false, + "in": "query", + "schema": { + "type": "string" + } + }, + { + "name": "compute_multiplier", + "required": false, + "in": "query", + "schema": { + "minimum": 1, + "maximum": 4, + "type": "number" + } + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/V1CreateFunctionBody" + } + }, + "application/vnd.denoland.eszip": { + "schema": { + "$ref": "#/components/schemas/V1CreateFunctionBody" + } + } + } + }, + "responses": { + "201": { + "description": "", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/FunctionResponse" + } + } + } + }, + "403": { + "description": "" + }, + "500": { + "description": "Failed to create project's function" + } + }, + "tags": [ + "Edge Functions" + ], + "security": [ + { + "bearer": [] + } + ] + } + } + } +} diff --git a/plugins/openapi/testdata/supabase-693bdc38.json b/plugins/openapi/testdata/supabase-693bdc38.json new file mode 100644 index 0000000..c75d575 --- /dev/null +++ b/plugins/openapi/testdata/supabase-693bdc38.json @@ -0,0 +1,106 @@ +{ + "openapi": "3.0.0", + "info": { + "title": "Supabase API (v1)", + "description": "Supabase API generated from the OpenAPI specification.
Visit [https://supabase.com/docs](https://supabase.com/docs) for a complete documentation.", + "version": "1.0.0", + "contact": {} + }, + "paths": { + "/v1/projects/{ref}/analytics/endpoints/logs.all": { + "get": { + "description": "Executes a SQL query on the project's logs.\n\nEither the `iso_timestamp_start` and `iso_timestamp_end` parameters must be provided.\nIf both are not provided, only the last 1 minute of logs will be queried.\nThe timestamp range must be no more than 24 hours and is rounded to the nearest minute. If the range is more than 24 hours, a validation error will be thrown.\n\nNote: Unless the `sql` parameter is provided, only edge_logs will be queried. See the [log query docs](/docs/guides/telemetry/logs?queryGroups=product&product=postgres&queryGroups=source&source=edge_logs#querying-with-the-logs-explorer:~:text=logs%20from%20the-,Sources,-drop%2Ddown%3A) for all available sources. \n", + "operationId": "v1-get-project-logs", + "parameters": [ + { + "name": "ref", + "required": true, + "in": "path", + "description": "Project ref", + "schema": { + "minLength": 20, + "maxLength": 20, + "pattern": "^[a-z]+$", + "example": "abcdefghijklmnopqrst", + "type": "string" + } + }, + { + "name": "sql", + "required": false, + "in": "query", + "description": "Custom SQL query to execute on the logs. See [querying logs](/docs/guides/telemetry/logs?queryGroups=product&product=postgres&queryGroups=source&source=edge_logs#querying-with-the-logs-explorer) for more details.", + "schema": { + "type": "string" + } + }, + { + "name": "iso_timestamp_start", + "required": false, + "in": "query", + "schema": { + "format": "date-time", + "example": "2025-03-01T00:00:00Z", + "type": "string" + } + }, + { + "name": "iso_timestamp_end", + "required": false, + "in": "query", + "schema": { + "format": "date-time", + "example": "2025-03-01T23:59:59Z", + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AnalyticsResponse" + } + } + } + }, + "401": { + "description": "Unauthorized" + }, + "403": { + "description": "Forbidden action" + }, + "429": { + "description": "Rate limit exceeded" + } + }, + "security": [ + { + "bearer": [] + }, + { + "fga_permissions": [ + "analytics_logs_read" + ] + } + ], + "summary": "Gets project's logs", + "tags": [ + "Analytics" + ], + "x-badges": [ + { + "name": "OAuth scope: analytics:read", + "position": "after" + } + ], + "x-endpoint-owners": [ + "analytics" + ], + "x-oauth-scope": "analytics:read" + } + } + } +} diff --git a/plugins/openapi/testdata/supabase-8aef4a08.json b/plugins/openapi/testdata/supabase-8aef4a08.json new file mode 100644 index 0000000..d4f5daf --- /dev/null +++ b/plugins/openapi/testdata/supabase-8aef4a08.json @@ -0,0 +1,509 @@ +{ + "openapi": "3.0.0", + "info": { + "title": "Supabase API (v1)", + "description": "", + "version": "1.0.0", + "contact": {} + }, + "paths": { + "/v1/projects/{ref}/analytics/warehouse/tenant": { + "get": { + "operationId": "v1-provision-a-warehouse-tenant", + "summary": "Gets project's warehouse tenant from logflare", + "parameters": [ + { + "name": "ref", + "required": true, + "in": "path", + "description": "Project ref", + "schema": { + "minLength": 20, + "maxLength": 20, + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/LFUser" + } + } + } + }, + "403": { + "description": "" + }, + "500": { + "description": "Failed to fetch or provision warehouse tenant" + } + }, + "tags": [ + "analytics" + ], + "security": [ + { + "bearer": [] + } + ] + } + }, + "/v1/projects/{ref}/analytics/warehouse/collections": { + "get": { + "operationId": "v1-list-all-warehouse-collections", + "summary": "Lists project's warehouse collections from logflare", + "parameters": [ + { + "name": "ref", + "required": true, + "in": "path", + "description": "Project ref", + "schema": { + "minLength": 20, + "maxLength": 20, + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/LFSource" + } + } + } + } + }, + "403": { + "description": "" + }, + "500": { + "description": "Failed to fetch warehouse collections" + } + }, + "tags": [ + "analytics" + ], + "security": [ + { + "bearer": [] + } + ] + }, + "post": { + "operationId": "v1-create-a-warehouse-collection", + "summary": "Create a warehouse collection", + "parameters": [], + "responses": { + "201": { + "description": "", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/LFSource" + } + } + } + }, + "403": { + "description": "" + }, + "500": { + "description": "Failed to create warehouse collection" + } + }, + "tags": [ + "analytics" + ], + "security": [ + { + "bearer": [] + } + ] + } + }, + "/v1/projects/{ref}/analytics/warehouse/collections/{token}": { + "get": { + "operationId": "v1-get-a-warehouse-collection", + "summary": "Get a warehouse collection", + "parameters": [], + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/LFSource" + } + } + } + }, + "403": { + "description": "" + }, + "500": { + "description": "Failed to fetch warehouse collection" + } + }, + "tags": [ + "analytics" + ], + "security": [ + { + "bearer": [] + } + ] + }, + "patch": { + "operationId": "v1-update-a-warehouse-collection", + "summary": "Update a warehouse collection", + "parameters": [], + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/LFSource" + } + } + } + }, + "403": { + "description": "" + }, + "500": { + "description": "Failed to update warehouse collection" + } + }, + "tags": [ + "analytics" + ], + "security": [ + { + "bearer": [] + } + ] + }, + "delete": { + "operationId": "v1-delete-a-warehouse-collection", + "summary": "Delete a warehouse collection", + "parameters": [], + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/LFSource" + } + } + } + }, + "403": { + "description": "" + }, + "500": { + "description": "Failed to delete warehouse collection" + } + }, + "tags": [ + "analytics" + ], + "security": [ + { + "bearer": [] + } + ] + } + }, + "/v1/projects/{ref}/analytics/warehouse/access-tokens": { + "get": { + "operationId": "v1-list-all-warehouse-tokens", + "summary": "Lists project's warehouse access tokens from logflare", + "parameters": [ + { + "name": "ref", + "required": true, + "in": "path", + "description": "Project ref", + "schema": { + "minLength": 20, + "maxLength": 20, + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/LFAccessToken" + } + } + } + } + }, + "403": { + "description": "" + }, + "500": { + "description": "Failed to fetch warehouse access tokens" + } + }, + "tags": [ + "analytics" + ], + "security": [ + { + "bearer": [] + } + ] + }, + "post": { + "operationId": "v1-create-a-warehouse-token", + "summary": "Create a warehouse access token", + "parameters": [], + "responses": { + "201": { + "description": "", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/LFAccessToken" + } + } + } + }, + "403": { + "description": "" + }, + "500": { + "description": "Failed to create warehouse access token" + } + }, + "tags": [ + "analytics" + ], + "security": [ + { + "bearer": [] + } + ] + } + }, + "/v1/projects/{ref}/analytics/warehouse/access-tokens/{token}": { + "delete": { + "operationId": "v1-delete-a-warehouse-token", + "summary": "Delete a warehouse access token", + "parameters": [], + "responses": { + "200": { + "description": "" + }, + "403": { + "description": "" + }, + "500": { + "description": "Failed to delete warehouse access token" + } + }, + "tags": [ + "analytics" + ], + "security": [ + { + "bearer": [] + } + ] + } + }, + "/v1/projects/{ref}/analytics/warehouse/endpoints": { + "get": { + "operationId": "v1-list-all-warehouse-endpoints", + "summary": "Lists project's warehouse endpoints from logflare", + "parameters": [ + { + "name": "ref", + "required": true, + "in": "path", + "description": "Project ref", + "schema": { + "minLength": 20, + "maxLength": 20, + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/LFEndpoint" + } + } + } + } + }, + "403": { + "description": "" + }, + "500": { + "description": "Failed to fetch warehouse endpoints" + } + }, + "tags": [ + "analytics" + ], + "security": [ + { + "bearer": [] + } + ] + }, + "post": { + "operationId": "v1-create-a-warehouse-endpoint", + "summary": "Create a warehouse endpoint", + "parameters": [], + "responses": { + "201": { + "description": "", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/LFEndpoint" + } + } + } + }, + "403": { + "description": "" + }, + "500": { + "description": "Failed to create warehouse endpoint" + } + }, + "tags": [ + "analytics" + ], + "security": [ + { + "bearer": [] + } + ] + } + }, + "/v1/projects/{ref}/analytics/warehouse/endpoints/{token}": { + "put": { + "operationId": "v1-update-a-warehouse-endpoint", + "summary": "Update a warehouse endpoint", + "parameters": [], + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/LFEndpoint" + } + } + } + }, + "403": { + "description": "" + }, + "500": { + "description": "Failed to update warehouse endpoint" + } + }, + "tags": [ + "analytics" + ], + "security": [ + { + "bearer": [] + } + ] + }, + "delete": { + "operationId": "v1-delete-a-warehouse-endpoint", + "summary": "Delete a warehouse endpoint", + "parameters": [], + "responses": { + "200": { + "description": "" + }, + "403": { + "description": "" + }, + "500": { + "description": "Failed to delete warehouse endpoint" + } + }, + "tags": [ + "analytics" + ], + "security": [ + { + "bearer": [] + } + ] + } + }, + "/v1/projects/{ref}/analytics/warehouse/query": { + "get": { + "operationId": "v1-list-all-warehouse-queries", + "summary": "Lists project's warehouse queries from logflare", + "parameters": [ + { + "name": "ref", + "required": true, + "in": "path", + "description": "Project ref", + "schema": { + "minLength": 20, + "maxLength": 20, + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "" + }, + "403": { + "description": "" + }, + "500": { + "description": "Failed to fetch warehouse queries" + } + }, + "tags": [ + "analytics" + ], + "security": [ + { + "bearer": [] + } + ] + } + } + } +} diff --git a/plugins/openapi/testdata/supabase-90b71e3e.json b/plugins/openapi/testdata/supabase-90b71e3e.json new file mode 100644 index 0000000..10125e9 --- /dev/null +++ b/plugins/openapi/testdata/supabase-90b71e3e.json @@ -0,0 +1,10 @@ +{ + "openapi": "3.0.0", + "info": { + "title": "Supabase API (v1)", + "description": "Supabase API generated from the OpenAPI specification.
Visit [https://supabase.com/docs](https://supabase.com/docs) for a complete documentation.", + "version": "1.0.0", + "contact": {} + }, + "paths": {} +} diff --git a/plugins/openapi/testdata/supabase-a5fc0527.json b/plugins/openapi/testdata/supabase-a5fc0527.json new file mode 100644 index 0000000..a922c9b --- /dev/null +++ b/plugins/openapi/testdata/supabase-a5fc0527.json @@ -0,0 +1,433 @@ +{ + "openapi": "3.0.0", + "info": { + "title": "Supabase API (v1)", + "description": "Supabase API generated from the OpenAPI specification.
Visit [https://supabase.com/docs](https://supabase.com/docs) for a complete documentation.", + "version": "1.0.0", + "contact": {} + }, + "paths": { + "/v1/branches/{branch_id_or_ref}": { + "get": { + "description": "Fetches configurations of the specified database branch", + "operationId": "v1-get-a-branch-config", + "parameters": [ + { + "name": "branch_id_or_ref", + "required": true, + "in": "path", + "description": "Branch ID", + "schema": { + "oneOf": [ + { + "type": "string", + "minLength": 20, + "maxLength": 20, + "pattern": "^[a-z]+$", + "description": "Project ref" + }, + { + "type": "string", + "format": "uuid", + "deprecated": true + } + ] + } + } + ], + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/BranchDetailResponse" + } + } + } + }, + "500": { + "description": "Failed to retrieve database branch" + } + }, + "security": [ + { + "bearer": [] + } + ], + "summary": "Get database branch config", + "tags": [ + "Environments" + ] + }, + "patch": { + "description": "Updates the configuration of the specified database branch", + "operationId": "v1-update-a-branch-config", + "parameters": [ + { + "name": "branch_id_or_ref", + "required": true, + "in": "path", + "description": "Branch ID", + "schema": { + "oneOf": [ + { + "type": "string", + "minLength": 20, + "maxLength": 20, + "pattern": "^[a-z]+$", + "description": "Project ref" + }, + { + "type": "string", + "format": "uuid", + "deprecated": true + } + ] + } + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/UpdateBranchBody" + } + } + } + }, + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/BranchResponse" + } + } + } + }, + "500": { + "description": "Failed to update database branch" + } + }, + "security": [ + { + "bearer": [] + } + ], + "summary": "Update database branch config", + "tags": [ + "Environments" + ] + }, + "delete": { + "description": "Deletes the specified database branch", + "operationId": "v1-delete-a-branch", + "parameters": [ + { + "name": "branch_id_or_ref", + "required": true, + "in": "path", + "description": "Branch ID", + "schema": { + "oneOf": [ + { + "type": "string", + "minLength": 20, + "maxLength": 20, + "pattern": "^[a-z]+$", + "description": "Project ref" + }, + { + "type": "string", + "format": "uuid", + "deprecated": true + } + ] + } + } + ], + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/BranchDeleteResponse" + } + } + } + }, + "500": { + "description": "Failed to delete database branch" + } + }, + "security": [ + { + "bearer": [] + } + ], + "summary": "Delete a database branch", + "tags": [ + "Environments" + ] + } + }, + "/v1/branches/{branch_id_or_ref}/push": { + "post": { + "description": "Pushes the specified database branch", + "operationId": "v1-push-a-branch", + "parameters": [ + { + "name": "branch_id_or_ref", + "required": true, + "in": "path", + "description": "Branch ID", + "schema": { + "oneOf": [ + { + "type": "string", + "minLength": 20, + "maxLength": 20, + "pattern": "^[a-z]+$", + "description": "Project ref" + }, + { + "type": "string", + "format": "uuid", + "deprecated": true + } + ] + } + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/BranchActionBody" + } + } + } + }, + "responses": { + "201": { + "description": "", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/BranchUpdateResponse" + } + } + } + }, + "500": { + "description": "Failed to push database branch" + } + }, + "security": [ + { + "bearer": [] + } + ], + "summary": "Pushes a database branch", + "tags": [ + "Environments" + ] + } + }, + "/v1/branches/{branch_id_or_ref}/merge": { + "post": { + "description": "Merges the specified database branch", + "operationId": "v1-merge-a-branch", + "parameters": [ + { + "name": "branch_id_or_ref", + "required": true, + "in": "path", + "description": "Branch ID", + "schema": { + "oneOf": [ + { + "type": "string", + "minLength": 20, + "maxLength": 20, + "pattern": "^[a-z]+$", + "description": "Project ref" + }, + { + "type": "string", + "format": "uuid", + "deprecated": true + } + ] + } + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/BranchActionBody" + } + } + } + }, + "responses": { + "201": { + "description": "", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/BranchUpdateResponse" + } + } + } + }, + "500": { + "description": "Failed to merge database branch" + } + }, + "security": [ + { + "bearer": [] + } + ], + "summary": "Merges a database branch", + "tags": [ + "Environments" + ] + } + }, + "/v1/branches/{branch_id_or_ref}/reset": { + "post": { + "description": "Resets the specified database branch", + "operationId": "v1-reset-a-branch", + "parameters": [ + { + "name": "branch_id_or_ref", + "required": true, + "in": "path", + "description": "Branch ID", + "schema": { + "oneOf": [ + { + "type": "string", + "minLength": 20, + "maxLength": 20, + "pattern": "^[a-z]+$", + "description": "Project ref" + }, + { + "type": "string", + "format": "uuid", + "deprecated": true + } + ] + } + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/BranchActionBody" + } + } + } + }, + "responses": { + "201": { + "description": "", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/BranchUpdateResponse" + } + } + } + }, + "500": { + "description": "Failed to reset database branch" + } + }, + "security": [ + { + "bearer": [] + } + ], + "summary": "Resets a database branch", + "tags": [ + "Environments" + ] + } + }, + "/v1/branches/{branch_id_or_ref}/diff": { + "get": { + "description": "Diffs the specified database branch", + "operationId": "v1-diff-a-branch", + "parameters": [ + { + "name": "branch_id_or_ref", + "required": true, + "in": "path", + "description": "Branch ID", + "schema": { + "oneOf": [ + { + "type": "string", + "minLength": 20, + "maxLength": 20, + "pattern": "^[a-z]+$", + "description": "Project ref" + }, + { + "type": "string", + "format": "uuid", + "deprecated": true + } + ] + } + }, + { + "name": "included_schemas", + "required": false, + "in": "query", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "text/plain": { + "schema": { + "type": "string" + } + } + }, + "description": "" + }, + "500": { + "description": "Failed to diff database branch" + } + }, + "security": [ + { + "bearer": [] + } + ], + "summary": "[Beta] Diffs a database branch", + "tags": [ + "Environments" + ] + } + } + } +} diff --git a/plugins/openapi/testdata/supabase-bf04ff66.json b/plugins/openapi/testdata/supabase-bf04ff66.json new file mode 100644 index 0000000..5cc0d00 --- /dev/null +++ b/plugins/openapi/testdata/supabase-bf04ff66.json @@ -0,0 +1,226 @@ +{ + "openapi": "3.0.0", + "info": { + "title": "Supabase API (v1)", + "description": "Supabase API generated from the OpenAPI specification.
Visit [https://supabase.com/docs](https://supabase.com/docs) for a complete documentation.", + "version": "1.0.0", + "contact": {} + }, + "paths": { + "/v1/projects/{ref}/functions": { + "get": { + "operationId": "v1-list-all-functions", + "summary": "List all functions", + "description": "Returns all functions you've previously added to the specified project.", + "parameters": [ + { + "name": "ref", + "required": true, + "in": "path", + "description": "Project ref", + "schema": { + "minLength": 20, + "maxLength": 20, + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/FunctionResponse" + } + } + } + } + }, + "403": { + "description": "" + }, + "500": { + "description": "Failed to retrieve project's functions" + } + }, + "tags": [ + "Edge Functions" + ], + "security": [ + { + "bearer": [] + } + ] + }, + "post": { + "operationId": "v1-create-a-function", + "summary": "Create a function", + "description": "This endpoint is deprecated - use the deploy endpoint. Creates a function and adds it to the specified project.", + "deprecated": true, + "parameters": [ + { + "name": "ref", + "required": true, + "in": "path", + "description": "Project ref", + "schema": { + "minLength": 20, + "maxLength": 20, + "type": "string" + } + }, + { + "name": "slug", + "required": false, + "in": "query", + "schema": { + "pattern": "/^[A-Za-z0-9_-]+$/", + "type": "string" + } + }, + { + "name": "name", + "required": false, + "in": "query", + "schema": { + "type": "string" + } + }, + { + "name": "verify_jwt", + "required": false, + "in": "query", + "schema": { + "type": "boolean" + } + }, + { + "name": "import_map", + "required": false, + "in": "query", + "schema": { + "type": "boolean" + } + }, + { + "name": "entrypoint_path", + "required": false, + "in": "query", + "schema": { + "type": "string" + } + }, + { + "name": "import_map_path", + "required": false, + "in": "query", + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/V1CreateFunctionBody" + } + }, + "application/vnd.denoland.eszip": { + "schema": { + "$ref": "#/components/schemas/V1CreateFunctionBody" + } + } + } + }, + "responses": { + "201": { + "description": "", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/FunctionResponse" + } + } + } + }, + "403": { + "description": "" + }, + "500": { + "description": "Failed to create project's function" + } + }, + "tags": [ + "Edge Functions" + ], + "security": [ + { + "bearer": [] + } + ] + }, + "put": { + "operationId": "v1-bulk-update-functions", + "summary": "Bulk update functions", + "description": "Bulk update functions. It will create a new function or replace existing. The operation is idempotent. NOTE: You will need to manually bump the version.", + "parameters": [ + { + "name": "ref", + "required": true, + "in": "path", + "description": "Project ref", + "schema": { + "minLength": 20, + "maxLength": 20, + "type": "string" + } + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/BulkUpdateFunctionBody" + } + } + } + } + }, + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/BulkUpdateFunctionResponse" + } + } + } + }, + "403": { + "description": "" + }, + "500": { + "description": "Failed to update functions" + } + }, + "tags": [ + "Edge Functions" + ], + "security": [ + { + "bearer": [] + } + ] + } + } + } +} diff --git a/plugins/openapi/testdata/supabase-de806266.json b/plugins/openapi/testdata/supabase-de806266.json new file mode 100644 index 0000000..8bb31cc --- /dev/null +++ b/plugins/openapi/testdata/supabase-de806266.json @@ -0,0 +1,349 @@ +{ + "openapi": "3.0.0", + "info": { + "title": "Supabase API (v1)", + "description": "Supabase API generated from the OpenAPI specification.
Visit [https://supabase.com/docs](https://supabase.com/docs) for a complete documentation.", + "version": "1.0.0", + "contact": {} + }, + "paths": { + "/v1/branches/{branch_id}": { + "get": { + "operationId": "v1-get-a-branch-config", + "summary": "Get database branch config", + "description": "Fetches configurations of the specified database branch", + "parameters": [ + { + "name": "branch_id", + "required": true, + "in": "path", + "description": "Branch ID", + "schema": { + "format": "uuid", + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/BranchDetailResponse" + } + } + } + }, + "500": { + "description": "Failed to retrieve database branch" + } + }, + "tags": [ + "Environments" + ], + "security": [ + { + "bearer": [] + } + ] + }, + "patch": { + "operationId": "v1-update-a-branch-config", + "summary": "Update database branch config", + "description": "Updates the configuration of the specified database branch", + "parameters": [ + { + "name": "branch_id", + "required": true, + "in": "path", + "description": "Branch ID", + "schema": { + "format": "uuid", + "type": "string" + } + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/UpdateBranchBody" + } + } + } + }, + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/BranchResponse" + } + } + } + }, + "500": { + "description": "Failed to update database branch" + } + }, + "tags": [ + "Environments" + ], + "security": [ + { + "bearer": [] + } + ] + }, + "delete": { + "operationId": "v1-delete-a-branch", + "summary": "Delete a database branch", + "description": "Deletes the specified database branch", + "parameters": [ + { + "name": "branch_id", + "required": true, + "in": "path", + "description": "Branch ID", + "schema": { + "format": "uuid", + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/BranchDeleteResponse" + } + } + } + }, + "500": { + "description": "Failed to delete database branch" + } + }, + "tags": [ + "Environments" + ], + "security": [ + { + "bearer": [] + } + ] + } + }, + "/v1/branches/{branch_id}/push": { + "post": { + "operationId": "v1-push-a-branch", + "summary": "Pushes a database branch", + "description": "Pushes the specified database branch", + "parameters": [ + { + "name": "branch_id", + "required": true, + "in": "path", + "description": "Branch ID", + "schema": { + "format": "uuid", + "type": "string" + } + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/BranchActionBody" + } + } + } + }, + "responses": { + "201": { + "description": "", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/BranchUpdateResponse" + } + } + } + }, + "500": { + "description": "Failed to push database branch" + } + }, + "tags": [ + "Environments" + ], + "security": [ + { + "bearer": [] + } + ] + } + }, + "/v1/branches/{branch_id}/merge": { + "post": { + "operationId": "v1-merge-a-branch", + "summary": "Merges a database branch", + "description": "Merges the specified database branch", + "parameters": [ + { + "name": "branch_id", + "required": true, + "in": "path", + "description": "Branch ID", + "schema": { + "format": "uuid", + "type": "string" + } + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/BranchActionBody" + } + } + } + }, + "responses": { + "201": { + "description": "", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/BranchUpdateResponse" + } + } + } + }, + "500": { + "description": "Failed to merge database branch" + } + }, + "tags": [ + "Environments" + ], + "security": [ + { + "bearer": [] + } + ] + } + }, + "/v1/branches/{branch_id}/reset": { + "post": { + "operationId": "v1-reset-a-branch", + "summary": "Resets a database branch", + "description": "Resets the specified database branch", + "parameters": [ + { + "name": "branch_id", + "required": true, + "in": "path", + "description": "Branch ID", + "schema": { + "format": "uuid", + "type": "string" + } + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/BranchActionBody" + } + } + } + }, + "responses": { + "201": { + "description": "", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/BranchUpdateResponse" + } + } + } + }, + "500": { + "description": "Failed to reset database branch" + } + }, + "tags": [ + "Environments" + ], + "security": [ + { + "bearer": [] + } + ] + } + }, + "/v1/branches/{branch_id}/diff": { + "get": { + "operationId": "v1-diff-a-branch", + "summary": "[Beta] Diffs a database branch", + "description": "Diffs the specified database branch", + "parameters": [ + { + "name": "branch_id", + "required": true, + "in": "path", + "description": "Branch ID", + "schema": { + "format": "uuid", + "type": "string" + } + }, + { + "name": "included_schemas", + "required": false, + "in": "query", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "text/plain": { + "schema": { + "type": "string" + } + } + }, + "description": "" + }, + "500": { + "description": "Failed to diff database branch" + } + }, + "tags": [ + "Environments" + ], + "security": [ + { + "bearer": [] + } + ] + } + } + } +} diff --git a/plugins/openapi/testdata/supabase-eb21ae25.json b/plugins/openapi/testdata/supabase-eb21ae25.json new file mode 100644 index 0000000..1ce4902 --- /dev/null +++ b/plugins/openapi/testdata/supabase-eb21ae25.json @@ -0,0 +1,209 @@ +{ + "openapi": "3.0.0", + "info": { + "title": "Supabase API (v1)", + "description": "Supabase API generated from the OpenAPI specification.
Visit [https://supabase.com/docs](https://supabase.com/docs) for a complete documentation.", + "version": "1.0.0", + "contact": {} + }, + "paths": { + "/v1/projects/{ref}/analytics/endpoints/logs.all": { + "get": { + "deprecated": true, + "description": "Executes a SQL query on the project's logs.\n\nEither the `iso_timestamp_start` and `iso_timestamp_end` parameters must be provided.\nIf both are not provided, only the last 1 minute of logs will be queried.\nThe timestamp range must be no more than 24 hours and is rounded to the nearest minute. If the range is more than 24 hours, a validation error will be thrown.\n\nNote: Unless the `sql` parameter is provided, only edge_logs will be queried. See the [log query docs](/docs/guides/telemetry/logs?queryGroups=product&product=postgres&queryGroups=source&source=edge_logs#querying-with-the-logs-explorer:~:text=logs%20from%20the-,Sources,-drop%2Ddown%3A) for all available sources.\n", + "operationId": "v1-get-project-logs-all", + "parameters": [ + { + "name": "ref", + "required": true, + "in": "path", + "description": "Project ref", + "schema": { + "minLength": 20, + "maxLength": 20, + "pattern": "^[a-z]+$", + "example": "abcdefghijklmnopqrst", + "type": "string" + } + }, + { + "name": "sql", + "required": false, + "in": "query", + "description": "Custom SQL query to execute on the logs. See [querying logs](/docs/guides/telemetry/logs?queryGroups=product&product=postgres&queryGroups=source&source=edge_logs#querying-with-the-logs-explorer) for more details.", + "schema": { + "type": "string" + } + }, + { + "name": "iso_timestamp_start", + "required": false, + "in": "query", + "schema": { + "format": "date-time", + "example": "2025-03-01T00:00:00Z", + "type": "string" + } + }, + { + "name": "iso_timestamp_end", + "required": false, + "in": "query", + "schema": { + "format": "date-time", + "example": "2025-03-01T23:59:59Z", + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AnalyticsResponse" + } + } + } + }, + "401": { + "description": "Unauthorized" + }, + "402": { + "description": "Usage exceeded. Enable additional usage to continue querying" + }, + "403": { + "description": "Forbidden action" + }, + "429": { + "description": "Rate limit exceeded" + } + }, + "security": [ + { + "bearer": [] + }, + { + "fga_permissions": [ + "analytics_logs_read" + ] + } + ], + "summary": "Gets project's logs", + "tags": [ + "Analytics" + ], + "x-badges": [ + { + "name": "OAuth scope: analytics:read", + "position": "after" + } + ], + "x-endpoint-owners": [ + "analytics" + ], + "x-oauth-scope": "analytics:read" + } + }, + "/v1/projects/{ref}/analytics/endpoints/logs": { + "get": { + "deprecated": false, + "description": "Executes an SQL or LQL query on the project's unified logs stream.\n\nEither the `iso_timestamp_start` and `iso_timestamp_end` parameters must be provided.\nIf both are not provided, only the last 1 minute of logs will be queried.\nThe timestamp range must be no more than 24 hours and is rounded to the nearest minute. If the range is more than 24 hours, a validation error will be thrown.\n\nFilter by the `source` column to specify specific log sources, such as edge_logs, postgres_logs, etc.\n\nNote: SQL must be written in **ClickHouse SQL dialect**.\n", + "operationId": "v1-get-project-logs", + "parameters": [ + { + "name": "ref", + "required": true, + "in": "path", + "description": "Project ref", + "schema": { + "minLength": 20, + "maxLength": 20, + "pattern": "^[a-z]+$", + "example": "abcdefghijklmnopqrst", + "type": "string" + } + }, + { + "name": "sql", + "required": false, + "in": "query", + "description": "Custom SQL query to execute on the logs. See [querying logs](/docs/guides/telemetry/logs?queryGroups=product&product=postgres&queryGroups=source&source=edge_logs#querying-with-the-logs-explorer) for more details.", + "schema": { + "type": "string" + } + }, + { + "name": "iso_timestamp_start", + "required": false, + "in": "query", + "schema": { + "format": "date-time", + "example": "2025-03-01T00:00:00Z", + "type": "string" + } + }, + { + "name": "iso_timestamp_end", + "required": false, + "in": "query", + "schema": { + "format": "date-time", + "example": "2025-03-01T23:59:59Z", + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AnalyticsResponse" + } + } + } + }, + "401": { + "description": "Unauthorized" + }, + "402": { + "description": "Usage exceeded. Enable additional usage to continue querying" + }, + "403": { + "description": "Forbidden action" + }, + "429": { + "description": "Rate limit exceeded" + } + }, + "security": [ + { + "bearer": [] + }, + { + "fga_permissions": [ + "analytics_logs_read" + ] + } + ], + "summary": "Gets all project's logs in a single log stream", + "tags": [ + "Analytics" + ], + "x-badges": [ + { + "name": "OAuth scope: analytics:read", + "position": "after" + } + ], + "x-endpoint-owners": [ + "analytics" + ], + "x-oauth-scope": "analytics:read" + } + } + } +} diff --git a/plugins/openapi/vercel.go b/plugins/openapi/vercel.go index 3bf9ce9..0c50690 100644 --- a/plugins/openapi/vercel.go +++ b/plugins/openapi/vercel.go @@ -46,14 +46,22 @@ func vercelDeprecatedSummary(summary string) bool { // // Additions are dropped too: nobody has to fix code for a new endpoint, and a // re-added one isn't new. -func vercelKeep(c diff.Change) bool { - switch c.Kind { - case diff.OperationDeprecated: - return true - case diff.OperationRemoved: - op, _ := c.Node.(map[string]any) - return vercelDiff.OperationDeprecated(op) - default: - return false +func vercelKeep(c diff.Change) bool { return deprecationsOnly(vercelDiff)(c) } + +// deprecationsOnly keeps operation deprecations, and removals of operations +// the old spec had marked deprecated (by opts' reading of "marked"): +// everything else is dropped. For a spec whose removals and property changes +// were mostly not changes to the API (vercel, supabase). +func deprecationsOnly(opts diff.Options) func(diff.Change) bool { + return func(c diff.Change) bool { + switch c.Kind { + case diff.OperationDeprecated: + return true + case diff.OperationRemoved: + op, _ := c.Node.(map[string]any) + return opts.OperationDeprecated(op) + default: + return false + } } } diff --git a/providers/README.md b/providers/README.md index a976994..8f12286 100644 --- a/providers/README.md +++ b/providers/README.md @@ -15,6 +15,7 @@ One page per plugin id: `providers/.md`. Start from [`_template.md`](_templ | [github.md](github.md) | `github` | `openapi` | | [gitlab.md](gitlab.md) | `gitlab` | `openapi` | | [vercel.md](vercel.md) | `vercel` | `openapi` | +| [supabase.md](supabase.md) | `supabase` | `openapi` | | [openai-models.md](openai-models.md) | `openai-models` | `retirements` | | [anthropic-models.md](anthropic-models.md) | `anthropic-models` | `retirements` | | [anthropic.md](anthropic.md) | `anthropic` | `migrationguide` | diff --git a/providers/supabase.md b/providers/supabase.md new file mode 100644 index 0000000..87ec785 --- /dev/null +++ b/providers/supabase.md @@ -0,0 +1,46 @@ +# Supabase (`supabase`) + +## What it watches + +The Supabase Management API (`api.supabase.com/v1`): operations Supabase marks deprecated, and removals of operations it had marked deprecated, between two versions of the API's OpenAPI spec. + +Format plugin: `openapi` (`plugins/openapi`), with `adapter.Supabase`. + +## Why this source + +- **Source:** `apps/docs/spec/api_v1_openapi.json` in [supabase/supabase](https://github.com/supabase/supabase), pinned to the commit that last changed it (`https://raw.githubusercontent.com/supabase/supabase//apps/docs/spec/api_v1_openapi.json`). The newest such commit comes from the GitHub commits API. Checked on 2026-11-19. +- **Why this one:** + - It's Supabase's own description of the API: the spec its API reference is built from. + - It marks deprecations with the `deprecated` flag, sometimes with the reason ("This endpoint is deprecated - use the deploy endpoint."). + - There are 90 versions from 2024-05-31 to 2026-11-18, and a commit can be cited and replayed. +- **Alternatives considered:** + - **`https://api.supabase.com/api/v1-json`.** The same spec served live, but it has no versions to pin, cite or replay. + - **The [changelog](https://supabase.com/changelog)** (RSS at `https://supabase.com/changelog-rss.xml`, 238 posts since 2022). It has about 30 breaking or deprecation posts. Almost all are about the platform rather than an API operation: Postgres versions, pooler ports, OAuth providers, the CLI, self-hosting. Or they're behavior changes ("OAuth token endpoint will return HTTP 200 instead of 201") with no field or operation to name. + - **There's no deprecations page** (`/docs/guides/deprecated` is a 404). + - **The SDKs.** `supabase-js` (2.119) and `supabase-py` (2.34) haven't had a major release in years, and their changelogs have no breaking sections to read. +- **Quote:** "This endpoint is deprecated - use the deploy endpoint." (`POST /v1/projects/{ref}/functions`, deprecated in the spec on 2025-02-19) + +## How the provider announces changes + +- **No API version beyond `/v1`.** `info.version` is a fixed `1.0.0`, so the event's `version` is the date of the spec commit, the closest thing to the API version a change arrived in. +- **The spec changes a few times a month.** Deprecations are rare: two in two and a half years. Three more operations were added already marked deprecated and later un-deprecated, so they never became deprecated. + +## What the plugin reads and ignores + +- **Reads:** the spec at the newest commit, diffed against the last one. Two events come out of it: + - **Deprecations:** an operation that gains the `deprecated` flag. The event quotes the whole operation, so Supabase's reason, when there is one, is in the excerpt. + - **Removals (breaking):** an operation that leaves the spec after the previous spec had marked it deprecated. +- **Matches operations by path template:** `/v1/branches/{branch_id}/merge` and `/v1/branches/{branch_id_or_ref}/merge` are one operation (renamed 2025-09-11). +- **Ignores everything else:** + - **Removals of operations that were never deprecated.** 22 operations left the spec in its history, none deprecated first: 14 analytics warehouse operations on 2024-07-15, 7 path-parameter renames, and one that came back 12 days later. Without credentials every route answers `401`, made-up ones included, so whether a removed one still works can't be checked from outside. + - **Request and response property changes, and new operations.** +- Over the 90 commits this keeps 2 events, both deprecations: `POST /v1/projects/{ref}/functions` (2025-02-19) and `GET /v1/projects/{ref}/analytics/endpoints/logs.all` (2026-06-29). +- **Replays** a historical pair (`Replay`, from `693bdc38` to `eb21ae25`) and recreates the `logs.all` deprecation. The golden test also runs the `functions` deprecation as a daily ingest. The drop tests replay the warehouse removal and the branch path-parameter rename. + +## Known gaps + +- **A shutdown said only in words isn't an event.** On 2026-09-30 the `logs.all` description became "This endpoint has been removed and always responds with `410 Gone`", but the operation stayed in the spec. The diff sees no structural change. +- **Removals Supabase didn't mark first aren't events,** even if the endpoint really went away. +- **Only the Management API is covered.** The APIs most apps call (the Data API through PostgREST, Auth, Storage, Realtime) and the SDKs are not. +- **Two spec commits on one day share a `version`.** It happened on four days in the history. The events stay distinct, because the operation is part of the fingerprint, but the second run's `previous_version` equals its `version`. +- **The patch-it client can't place these events yet.** Their `version` is a date (`2026-06-29`), because the API has no version. The client's version check reads an `api_operation` version as a package version, so it needs the same rule for date-versioned API events that `cloudflare`'s need.