Skip to content

Replace openapi-typescript with custom OpenAPI type generator - #24

Merged
bachmacintosh merged 1 commit into
mainfrom
claude/optimistic-rubin-jsai26
Oct 4, 2026
Merged

bachmacintosh merged 1 commit into
mainfrom
claude/optimistic-rubin-jsai26

Conversation

@bachmacintosh

Copy link
Copy Markdown
Contributor

Summary

Replaced the openapi-typescript dependency 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:

    • Parses OpenAPI 3.1 component schemas and generates TypeScript type definitions
    • Handles JSON Schema keywords affecting type shape (type, properties, allOf, oneOf, anyOf, etc.)
    • Builds types as plain strings without depending on TypeScript compiler APIs
    • Supports complex types including unions, intersections, arrays, tuples, objects, and records
    • Generates JSDoc comments from schema descriptions
  • New type definitions (workers/webhooks/scripts/openapi/types.ts): Minimal model of OpenAPI 3.1 structures needed by the generator

  • Updated type generation script (workers/webhooks/scripts/types.ts): Refactored to use the new custom generator instead of openapi-typescript

  • Removed dependency: Deleted openapi-typescript from package.json devDependencies

  • Workspace configuration: Removed TypeScript 7 compatibility workaround from pnpm-workspace.yaml

Notable Implementation Details

  • The generator uses a recursive type node system to represent TypeScript types internally before rendering them as strings
  • Includes deduplication logic for union and intersection types to avoid redundant members
  • Properly handles edge cases like readonly properties, optional fields, and complex nested structures
  • Maintains compatibility with the existing GitHub webhook type generation workflow

https://claude.ai/code/session_015aGhpGWiL6tRimDU8kwhbe

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
@bachmacintosh
bachmacintosh added this pull request to the merge queue Oct 4, 2026
Merged via the queue into main with commit 957e39b Oct 4, 2026
1 check passed
@bachmacintosh
bachmacintosh deleted the claude/optimistic-rubin-jsai26 branch October 4, 2026 15:33
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.

2 participants