Skip to content

feat: Migrate codegen to use use Blueprint#585

Merged
razor-x merged 3 commits into
mainfrom
claude/codegen-cleanup-blueprint-lfafma
Jul 23, 2026
Merged

feat: Migrate codegen to use use Blueprint#585
razor-x merged 3 commits into
mainfrom
claude/codegen-cleanup-blueprint-lfafma

Conversation

@razor-x

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

Copy link
Copy Markdown
Member

Summary

This PR migrates the Python SDK code generator from parsing raw OpenAPI schemas to using the Blueprint specification that is already available in Metalsmith metadata. This eliminates the need for frozen output-parity workarounds and simplifies the codebase by removing temporary OpenAPI parsing utilities.

Key Changes

  • Removed OpenAPI parsing dependencies: Deleted temporary files that were verbatim ports from the previous generator:

    • openapi/get-parameter-and-response-schema.ts
    • openapi/deep-flatten-one-of-and-all-of-schema.ts
    • openapi/flatten-obj-schema.ts
    • openapi/map-parent-to-children-resource.ts
    • openapi/get-filtered-routes.ts
    • openapi/types.ts
    • map-python-type.ts
    • endpoint-rules.ts
  • Refactored route generation (codegen/lib/routes.ts):

    • Now driven entirely by blueprint.routes and blueprint.namespaces instead of OpenAPI paths
    • Simplified class and namespace mapping using Blueprint's path-based structure
    • Removed complex parent-child resource mapping logic in favor of Blueprint's parentPath relationships
    • Filters routes and endpoints using Blueprint's isUndocumented flags instead of OpenAPI extensions
  • Created new type mapping module (codegen/lib/python-type.ts):

    • Replaces the old OpenAPI-based type mapping with Blueprint-aware functions
    • mapParameterToPythonType() and mapPropertyToPythonType() use Blueprint's format system
    • Handles special cases like Batch resource properties and list item formats
  • Updated models layout context (codegen/lib/layouts/models.ts):

    • Now uses blueprint.resources, blueprint.events, and blueprint.actionAttempts directly
    • Simplified property merging for action attempt and event variants
    • Removed OpenAPI schema flattening logic
  • Type refinements (seam/routes/models.py):

    • Changed ActionAttempt.result from Any to Dict[str, Any]
    • Updated Batch resource list properties from List[Any] to List[Dict[str, Any]]
    • Changed Device.device_type from Any to str
    • Changed Device.properties from Any to Dict[str, Any]
    • Removed deprecated PhoneRegistration dataclass
    • Changed ThermostatSchedule.max_override_period_minutes from int to float
    • Changed UnmanagedDevice.device_type from Any to str
    • Removed AbstractAcsEncoders class (moved to simulate submodule)
    • Updated various limit parameters from Optional[int] to Optional[float]
    • Reordered method parameters in AcsUsers.get() and Events.get() for consistency
  • Route file updates:

    • Added workspaces.update() method
    • Updated parameter types across multiple route files to use float instead of int for pagination limits
    • Added missing imports (e.g., AcsEncodersSimulate in acs_encoders.py)

Implementation Details

  • The generator now uses Blueprint's path-based namespace system (toNamespace() function converts paths like /acs/encoders to acs_encoders)
  • Child class relationships are determined by comparing parentPath values from Blueprint entries
  • Parameter and property type mapping is simplified by using Blueprint's standardized format system instead of parsing OpenAPI schemas
  • The migration maintains backward compatibility with generated output while removing technical debt from the previous generator's workarounds

https://claude.ai/code/session_011TdqYTYvyrK8rrR7FL1Aax

claude and others added 3 commits July 22, 2026 14:43
Remove all TEMPORARY output-parity workarounds and their TODOs from the
codegen. The generator now consumes only the Blueprint from
@seamapi/blueprint; the raw OpenAPI spec is no longer parsed anywhere in
this repository's codegen (it is only passed to the blueprint plugin,
which builds the Blueprint from it).

- Delete codegen/lib/openapi/, map-python-type.ts, and endpoint-rules.ts.
- Filter endpoints on blueprint isUndocumented flags instead of raw
  x-undocumented/x-fern-sdk-group-name extensions and hardcoded path
  lists.
- Derive namespaces and parent/child class wiring from blueprint route
  and namespace paths, which now also wires deeply nested namespaces
  (seam.acs.encoders.simulate) to their parent class.
- Derive method parameters from endpoint.request.parameters and return
  types from endpoint.response via a new blueprint-format-to-Python-type
  mapping (codegen/lib/python-type.ts).
- Build models.py from blueprint resources, events, action attempts, and
  pagination, merging event and action attempt variant properties into
  single dataclasses.
- Fix the parameter sort comparator precedence so an explicit position
  sorts a parameter first.

Expected generated output changes:

- integer parameters and properties are now typed float (the blueprint
  collapses integer into number)
- new workspaces.update() method returning None
- seam.acs.encoders.simulate is now reachable
- {resource}_id parameter sorts first in get() methods
- PhoneRegistration model removed (blueprint omits it; it was referenced
  nowhere)
- ActionAttempt.result is now Dict[str, Any] with DeepAttrDict access
- Batch fields are now List[Dict[str, Any]]; Device.device_type is now
  str

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011TdqYTYvyrK8rrR7FL1Aax
Upgrade @seamapi/blueprint to 0.58.0 and map number parameters and
properties with isInt to Python int, restoring the integer types that
were collapsed to float when the codegen moved off the raw OpenAPI
schemas. List items carry no isInt flag, so numbers inside lists remain
float.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011TdqYTYvyrK8rrR7FL1Aax
@razor-x razor-x changed the title Migrate Python SDK codegen to use Blueprint instead of OpenAPI feat: Migrate Python SDK codegen to use use Blueprint Jul 23, 2026
@razor-x razor-x changed the title feat: Migrate Python SDK codegen to use use Blueprint feat: Migrate codegen to use use Blueprint Jul 23, 2026
@razor-x
razor-x marked this pull request as ready for review July 23, 2026 15:22
@razor-x
razor-x requested a review from a team as a code owner July 23, 2026 15:22
@razor-x
razor-x merged commit b3e8430 into main Jul 23, 2026
18 checks passed
@razor-x
razor-x deleted the claude/codegen-cleanup-blueprint-lfafma branch July 23, 2026 15:23
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