Skip to content

chore(codegen): daily schema refresh (2026-08-05) - #113

Draft
timgl wants to merge 1 commit into
mainfrom
posthog-code/schema-refresh-2026-08-05
Draft

chore(codegen): daily schema refresh (2026-08-05)#113
timgl wants to merge 1 commit into
mainfrom
posthog-code/schema-refresh-2026-08-05

Conversation

@timgl

@timgl timgl commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

What

Daily regeneration of src/generated/api.d.ts from the live PostHog OpenAPI
spec (https://us.posthog.com/api/schema/?format=json, filtered by
openapi-filter.yaml), plus the minimal client patches needed to realign the
managed resource families with upstream schema/route renames.

Why: automated daily schema-refresh detected drift in the live API spec; the
typed client must track it so pnpm typecheck/pnpm test stay green.

Spec diff size

src/generated/api.d.ts: +4424 / −1621 lines.

Managed-family drift resolved

Family Upstream change Fix
endpoints operationIds environments_endpoints_*endpoints_*; route moved /api/environments/{environment_id}/endpoints//api/projects/{project_id}/endpoints/ filter operationIds swapped; endpoint/client.ts paths + path params updated
dashboard partial_update body schema PatchedDashboardPatchedPatchedDashboardOpenApi dashboard/client.ts type ref
experiment ExperimentExperimentWrite (create/update body), PatchedExperimentPatchedExperimentWrite, PaginatedExperimentListPaginatedExperimentBasicList experiment/client.ts type refs

operationIds added to the filter

Replaced the six renamed endpoint ops (net-new to the allowlist):

  • endpoints_list, endpoints_create, endpoints_retrieve, endpoints_update, endpoints_partial_update, endpoints_destroy

(removing the now-nonexistent environments_endpoints_* — this is a rename in
the live spec, not a dropped capability.)

Resources touched

  • src/resources/endpoint/client.ts (route + params)
  • src/resources/dashboard/client.ts (schema ref)
  • src/resources/experiment/client.ts (schema refs)

Disappeared operationIds

Only the six environments_endpoints_* ops disappeared, and they were renamed
(not removed) to endpoints_* — handled above. No managed capability was dropped,
so nothing needs a human deletion this cycle.

New operationIds NOT added (intentionally unmanaged)

openapi-filter.yaml is an allowlist, so the drift report lists the entire live
API surface (~1.7k ops) minus the managed families. These stay excluded — they
belong to products outside the IaC-managed scope (accounts, error tracking,
logs, warehouse, tasks, LLM analytics, messaging, etc.). Worth calling out: a few
are new full-PUT counterparts to families we already manage via partial_update
(event_definitions_update, schema_property_groups_update,
event_schemas_update/event_schemas_partial_update, experiment_holdouts_update,
experiment_saved_metrics_update). The resource clients don't use them, so they're
left out to keep the generated surface minimal.

Verification

  • pnpm typecheck
  • pnpm test ✅ (291 tests)

Pre-existing repo-wide eslint/prettier warnings are unrelated to this diff
(present on main) and left untouched.

TaskRun

https://us.posthog.com/project/423401/tasks/4936f0d4-b217-492a-850c-4a73d88b3732


Created with PostHog Code

Regenerate src/generated/api.d.ts from the live PostHog OpenAPI spec and
realign the managed resource clients with upstream schema/route renames.

- endpoints: operationIds environments_endpoints_* renamed to endpoints_* and
  route moved from /api/environments/{environment_id}/endpoints/ to
  /api/projects/{project_id}/endpoints/. Updated openapi-filter.yaml and the
  endpoint client paths/params accordingly.
- dashboard: partial_update request body schema PatchedDashboard renamed to
  PatchedPatchedDashboardOpenApi.
- experiment: request/response schemas Experiment->ExperimentWrite,
  PatchedExperiment->PatchedExperimentWrite, and
  PaginatedExperimentList->PaginatedExperimentBasicList.

typecheck + test (291 tests) pass.

Generated-By: PostHog Code
Task-Id: 4936f0d4-b217-492a-850c-4a73d88b3732
@timgl
timgl requested a review from pl August 5, 2026 07:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant