Skip to content

Migrate Ruby SDK route generation to Metalsmith-based codegen#524

Merged
razor-x merged 1 commit into
mainfrom
claude/ruby-codegen-port-klgowp
Jul 21, 2026
Merged

Migrate Ruby SDK route generation to Metalsmith-based codegen#524
razor-x merged 1 commit into
mainfrom
claude/ruby-codegen-port-klgowp

Conversation

@razor-x

@razor-x razor-x commented Jul 21, 2026

Copy link
Copy Markdown
Member

Summary

Replaces the direct dependency on @seamapi/nextlove-sdk-generator with an internal Metalsmith-based code generation pipeline. The new implementation ports the route, client, and resource file generation logic while maintaining byte-identical output to the previous generator.

Key Changes

  • New codegen pipeline: Implemented codegen/smith.ts as the main Metalsmith orchestrator that replaces generate-routes.js
  • Route generation: Ported core logic from nextlove generator into codegen/lib/routes.ts, which:
    • Processes blueprint routes and OpenAPI endpoints
    • Generates client classes with methods
    • Creates resource files from OpenAPI schemas
    • Maintains parent-child resource relationships
  • Layout system: Added Handlebars templates and context builders for:
    • Client files (client.hbs, codegen/lib/layouts/client.ts)
    • Resource files (resource.hbs, codegen/lib/layouts/resource.ts)
    • Import index files (imports.hbs, codegen/lib/layouts/imports.ts)
    • Routes file (routes.hbs, codegen/lib/layouts/routes-file.ts)
  • OpenAPI utilities: Ported frozen output-parity workarounds from nextlove:
    • get-parameter-and-response-schema.ts
    • deep-flatten-one-of-and-all-of-schema.ts
    • flatten-obj-schema.ts
    • map-parent-to-children-resource.ts
    • get-filtered-routes.ts
  • Static resources: Extracted hardcoded Ruby resource classes into static-resources.ts
  • Build configuration: Added TypeScript config, ESLint config, and updated npm scripts
  • Documentation: Added .prettierignore and updated .gitignore for codegen artifacts

Implementation Details

  • All OpenAPI parsing logic is marked as TEMPORARY with TODO comments indicating migration paths to @seamapi/blueprint once output changes are permitted
  • The implementation preserves the exact output structure and ordering from the previous generator to ensure compatibility
  • Client method parameter sorting includes a preserved quirk from the original implementation (operator precedence bug) to maintain identical output
  • Handlebars partials are loaded dynamically from layouts/partials/
  • The codegen now runs via tsx codegen/smith.ts instead of direct Node.js execution

https://claude.ai/code/session_016XEpBuyVgLx5jvB4zygya6

Replace the @seamapi/nextlove-sdk-generator pipeline with the Metalsmith +
Handlebars + @seamapi/blueprint architecture used by seamapi/javascript-http
and seamapi/docs.

The blueprint drives route/endpoint/namespace iteration; the raw OpenAPI spec
is still consulted wherever the previous generator derived output from data the
blueprint normalizes differently. Those spots, and the verbatim helper ports
that back them, are marked with TODO/TEMPORARY banners so they can migrate to
blueprint once the generated output is allowed to change.

Generated output under lib/seam/routes is byte-identical after `rake format`.

- Add codegen/ (smith entry, Metalsmith plugin, layout context builders,
  Handlebars templates/partials, and TEMPORARY parity helpers)
- Pin @seamapi/blueprint 0.55.0, add @seamapi/smith and change-case; drop
  @seamapi/nextlove-sdk-generator and del
- Add tsconfig.json, eslint.config.ts, .prettierignore; wire typecheck/lint
  scripts; gitignore the generated root CODEGEN.md
- Remove generate-routes.js

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016XEpBuyVgLx5jvB4zygya6
@razor-x
razor-x marked this pull request as ready for review July 21, 2026 17:53
@razor-x
razor-x merged commit a7da064 into main Jul 21, 2026
17 checks passed
@razor-x
razor-x deleted the claude/ruby-codegen-port-klgowp branch July 21, 2026 17:53
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