Skip to content

chore(codegen): daily schema refresh (2026-08-02) - #110

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

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

Conversation

@timgl

@timgl timgl commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Why

Automated daily OpenAPI schema refresh. Keeps src/generated/api.d.ts in sync with the live PostHog spec so the typed client doesn't drift, and follows any upstream operationId/schema renames through the affected resource clients.

Spec diff size

  • src/generated/api.d.ts: 17,571 → 19,908 lines (~726 KB → ~902 KB); +3,969 / −1,632 lines within the file.
  • Bulk of the churn is upstream schema-shape changes to already-managed operations (regenerated, not hand-edited).

New operationIds added to the filter

The endpoint resource family was renamed upstream — the deprecated environments_endpoints_* operations (served at /api/environments/{environment_id}/endpoints/) were removed and replaced by endpoints_* at /api/projects/{project_id}/endpoints/. Swapped the six CRUD operationIds in openapi-filter.yaml:

  • endpoints_list, endpoints_create, endpoints_retrieve, endpoints_update, endpoints_partial_update, endpoints_destroy (replacing the environments_endpoints_* equivalents).

No brand-new resource families were added. The live spec contains ~1,724 operationIds outside the allowlist, but they are all product/API surface this IaC tool does not manage (conversations, tasks, logs, vision scanners, warehouse, LLM analytics, admin/debug endpoints, per-resource sub-actions like *_activity/*_collaborators, and PUT *_update variants of families we intentionally manage via PATCH). The allowlist is curated to the CRUD operations the resource clients actually use, so these were intentionally left out.

Resources touched

Regenerating surfaced three upstream schema renames that broke pnpm typecheck; patched the affected client type aliases minimally (no refactors):

  • endpoint (src/resources/endpoint/client.ts) — repointed all five request paths from /api/environments/{environment_id}/endpoints/… to /api/projects/{project_id}/endpoints/… (and the path param environment_idproject_id). Response/request component names (EndpointResponse, EndpointVersionResponse, PaginatedEndpointResponseList, EndpointRequest) are unchanged.
  • dashboard (src/resources/dashboard/client.ts) — dashboards_partial_update body schema PatchedDashboardPatchedPatchedDashboardOpenApi (same restriction_level / tiles / delete_insights fields).
  • experiment (src/resources/experiment/client.ts) — create body ExperimentExperimentWrite, partial_update body PatchedExperimentPatchedExperimentWrite, list response PaginatedExperimentListPaginatedExperimentBasicList. Verified ExperimentBasic still carries the fields ServerExperimentSchema requires (id, name, feature_flag_key, feature_flag) and the schema is .loose(), so the list parse stays runtime-safe.

Verification

  • pnpm codegen (regenerated, not hand-edited)
  • pnpm typecheck
  • pnpm test ✅ (291 passed)

pnpm lint / pnpm format:check fail on the repo baseline (68 files, incl. the two client files here — pre-existing before this change, no pre-commit hook enforces it). Not reformatted, to avoid touching unrelated files.

Unresolved drift

None. The only managed operationIds missing from the live spec were the six environments_endpoints_* — resolved via the rename above, not a deletion. No managed operations were dropped upstream, so there is nothing pending human deletion.

TaskRun

Cloud run: 4cd15248-154c-4308-befd-9f34fa5b4e94https://us.posthog.com/project/423401/tasks


Created with PostHog Code

Regenerate src/generated/api.d.ts from the live PostHog OpenAPI spec and
follow the upstream renames through the affected resource clients.

- endpoints: operationIds/paths moved from the deprecated
  environments_endpoints_* (/api/environments/{environment_id}/endpoints/)
  to endpoints_* (/api/projects/{project_id}/endpoints/). Updated the filter
  allowlist and the endpoint client paths accordingly.
- dashboards: partial_update body schema renamed
  PatchedDashboard -> PatchedPatchedDashboardOpenApi.
- experiments: create body Experiment -> ExperimentWrite, partial_update body
  PatchedExperiment -> PatchedExperimentWrite, list response
  PaginatedExperimentList -> PaginatedExperimentBasicList.

Generated-By: PostHog Code
Task-Id: 4cd15248-154c-4308-befd-9f34fa5b4e94
@timgl
timgl requested a review from pl August 2, 2026 07:52
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