Repository navigation
Replace openapi-typescript with custom OpenAPI type generator - #24
Merged
Merged
Conversation
openapi-typescript is in maintenance mode and depends on the TypeScript 5
compiler API, so it will never support TypeScript 7. Keeping it meant a
resolvePeersFromWorkspaceRoot workaround that newer pnpm versions no longer
honor.
The webhooks worker now generates its GitHub types with a small,
dependency-free generator (scripts/openapi) that builds the types as strings
from the OpenAPI 3.1 component schemas. The workspace is now TypeScript 7
only, with no peer dependency workarounds.
The generated types keep the same `components["schemas"][...]` shape and
helpers, and are identical or wider than before. A few cases
openapi-typescript got wrong are fixed:
- `{ type: ["null"], allOf: [{ $ref }] }` is now `X | null` instead of
`null & X` (i.e. `never`)
- a `type` list combined with `oneOf`/`anyOf` no longer intersects away
members, e.g. `string | string[] | null` instead of `string[]`
- objects with no declared properties are `Record<string, unknown>`
instead of `Record<string, never>`
Examples are now rendered as inline code or fenced JSON rather than
`@example` tags, which oxfmt was formatting as code.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015aGhpGWiL6tRimDU8kwhbe
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replaced the
openapi-typescriptdependency with a custom TypeScript type generator that parses OpenAPI 3.1 schemas without relying on the TypeScript compiler API. This eliminates the TypeScript 7 compatibility issue while maintaining the same functionality.Key Changes
New custom OpenAPI generator (
workers/webhooks/scripts/openapi/index.ts): Implements a complete type generator that:type,properties,allOf,oneOf,anyOf, etc.)New type definitions (
workers/webhooks/scripts/openapi/types.ts): Minimal model of OpenAPI 3.1 structures needed by the generatorUpdated type generation script (
workers/webhooks/scripts/types.ts): Refactored to use the new custom generator instead ofopenapi-typescriptRemoved dependency: Deleted
openapi-typescriptfrompackage.jsondevDependenciesWorkspace configuration: Removed TypeScript 7 compatibility workaround from
pnpm-workspace.yamlNotable Implementation Details
https://claude.ai/code/session_015aGhpGWiL6tRimDU8kwhbe