Skip to content
This repository was archived by the owner on Jan 19, 2026. It is now read-only.

feat: add a generated api client#135

Merged
joshsny merged 4 commits into
mainfrom
build-client-from-api-schema
Sep 16, 2025
Merged

feat: add a generated api client#135
joshsny merged 4 commits into
mainfrom
build-client-from-api-schema

Conversation

@joshsny
Copy link
Copy Markdown
Collaborator

@joshsny joshsny commented Sep 15, 2025

Right now, half the work for adding tools is adding the schema from the API.

Our OpenAPI spec is far from perfect, and we can't rely on it for our API client, but it does have some useful types that we can generate a client from and use within our own API client.

This adds a generated client and uses it for the insights().list() method as an example.

Copilot AI review requested due to automatic review settings September 15, 2025 21:16
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds a generated API client by introducing a new OpenAPI-based client generation system that works alongside the existing manual API client implementation.

Key changes:

  • Adds automated OpenAPI client generation from PostHog's API schema
  • Integrates the generated client into the existing ApiClient class
  • Updates the insights API endpoint to use the new generated client as a proof of concept

Reviewed Changes

Copilot reviewed 5 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
typescript/src/api/fetcher.ts Implements a custom fetch adapter for the generated API client with authentication and parameter handling
typescript/src/api/client.ts Integrates the generated client and updates insights list method to use it
typescript/scripts/update-openapi-client.ts Provides automation script to fetch OpenAPI schema and generate TypeScript client
typescript/package.json Adds new dependencies and npm script for client generation
biome.json Excludes generated TypeScript files from linting
Files not reviewed (1)
  • typescript/pnpm-lock.yaml: Language not supported

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread typescript/src/api/client.ts Outdated
Comment thread typescript/src/api/client.ts Outdated
Comment thread typescript/src/api/client.ts
@joshsny joshsny requested a review from jonathanlab September 15, 2025 21:48
Copy link
Copy Markdown
Collaborator

@jonathanlab jonathanlab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, definitely better than nothing 👍🏻

@joshsny joshsny merged commit 7fec00c into main Sep 16, 2025
11 of 12 checks passed
@joshsny joshsny deleted the build-client-from-api-schema branch September 16, 2025 11:18
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants