Skip to content

chore(codegen): daily schema refresh (2026-07-25) - #101

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

chore(codegen): daily schema refresh (2026-07-25)#101
timgl wants to merge 1 commit into
mainfrom
posthog-code/schema-refresh-2026-07-25

Conversation

@timgl

@timgl timgl commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Why

Automated daily OpenAPI schema refresh. Keeps src/generated/api.d.ts in sync with the live PostHog API schema (filtered by openapi-filter.yaml) and patches managed resources when upstream schema shapes drift, so the typed client keeps compiling.

Spec diff size

src/generated/api.d.ts: +3540 / −1521 lines (regenerated via pnpm codegen; not hand-edited).

New operationIds added to the filter

The endpoints resource was renamed upstream. The previously-@deprecated path /api/environments/{environment_id}/endpoints/ (operationIds environments_endpoints_*) has been removed from the live spec, replaced by the project-scoped /api/projects/{project_id}/endpoints/ (operationIds endpoints_*). Since this is the same managed resource family, the new CRUD operationIds were added to openapi-filter.yaml:

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

No other new operationIds were added. The drift detector lists ~the entire PostHog API surface because openapi-filter.yaml is an intentional minimal allowlist (inverseOperationIds), not a mirror — every non-allowlisted operation shows up as "new". The remaining unlisted operationIds are out of scope for this IaC tool (other products, sub-resources, admin/internal endpoints) and were deliberately left out.

Resources touched

  • endpoint (src/resources/endpoint/client.ts) — repointed all 5 CRUD calls from /api/environments/{environment_id}/endpoints/ to /api/projects/{project_id}/endpoints/ (path param environment_idproject_id).
  • experiment (src/resources/experiment/client.ts) — renamed component schema aliases: Experiment (create body) → ExperimentWrite, PatchedExperimentPatchedExperimentWrite, PaginatedExperimentListPaginatedExperimentBasicList.
  • dashboard (src/resources/dashboard/client.ts) — renamed PatchedDashboardPatchedPatchedDashboardOpenApi (patch body). Note the upstream double-Patched name is verbatim from the generated schema.

pnpm typecheck passes and all 291 tests pass. (Pre-existing lint/format:check failures on main are unrelated and untouched.)

Unresolved drift for a human

The old environments_endpoints_* operationIds have disappeared from the live spec (renamed, see above). Per the refresh policy, disappeared operationIds are not removed automatically — they're kept in openapi-filter.yaml (harmless: openapi-format simply doesn't match them) with a comment flagging them. A human should delete the six environments_endpoints_* entries once the endpoints migration is confirmed stable.

TaskRun

Task-Id: bc69de41-333f-486a-a8cc-7462609ec0db


Created with PostHog Code

Regenerate src/generated/api.d.ts from the live PostHog OpenAPI schema and
patch managed resources for upstream schema drift.

- Endpoints resource renamed upstream: the deprecated
  /api/environments/{environment_id}/endpoints/ path (environments_endpoints_*)
  was removed from the live spec; the canonical family is now the
  project-scoped /api/projects/{project_id}/endpoints/ (endpoints_*). Added the
  new operationIds to openapi-filter.yaml and repointed the endpoint client.
  The old environments_endpoints_* entries are kept (harmless, unmatched) and
  flagged for a human to delete.
- Renamed request/response component schemas patched in clients:
  PatchedExperiment -> PatchedExperimentWrite, Experiment (create body) ->
  ExperimentWrite, PaginatedExperimentList -> PaginatedExperimentBasicList,
  PatchedDashboard -> PatchedPatchedDashboardOpenApi.

typecheck + all 291 tests pass.

Generated-By: PostHog Code
Task-Id: bc69de41-333f-486a-a8cc-7462609ec0db
@timgl
timgl requested a review from pl July 25, 2026 07:45
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