feat: fully typed SDK generation for Python and TypeScript#36
Merged
Conversation
Replace template-side type mapping with a Rust type-rendering engine (xdk-lib/src/types.rs) so generated SDKs are fully typed wherever the OpenAPI spec defines types. Type engine: - $refs render as schema type names (cycle-safe: never recurses into reference bodies); enums as literal unions / typing.Literal; arrays keep item types; oneOf/anyOf become unions, allOf intersections (TS); nullable (newly parsed) maps to '| null' / Optional - Python identifier safety: keyword fields get a '_' suffix plus Field(alias=...); schema names colliding with typing imports get an X prefix (List -> XList) - example_json builds minimal spec-valid payloads for generated tests TypeScript: - schemas.ts declarations fully rendered in Rust: real interfaces, literal-union enums, typed compositions (was 'any') - typed parameters, request/response models, and Options interfaces Python: - new generated xdk/schemas.py: Pydantic models for every component schema (nested inline objects hoisted into named models, aliases topologically sorted, forward refs resolved at import) - per-tag models alias the schema models; union responses get RootModel wrappers; removes the 'Tweet = Any' alias table, the required-fields- forced-to-str bug, and flattened union handling Generator robustness: - has_request_model / has_json_response flags computed once in Rust and used by every template that imports or references a model, so import and definition conditions cannot drift - output directories cleaned before generation (stale modules from a previous spec no longer break builds) - parameters deduplicated by (name, in) for specs that illegally declare a parameter twice - generated test mocks derive from the response schemas (spec-valid) instead of fabricated placeholder values Verified on staging and prod specs: both SDKs build, type-check, and pass their full test suites; public method names are byte-identical to the previous generator's output for the same spec. specs/ pins the staging spec for reproducible local generation.
santiagomed
added a commit
that referenced
this pull request
Jul 21, 2026
The fully-typed-codegen PR (#36) accidentally committed the staging spec snapshot. Replace it with the production spec as specs/openapi.json and gitignore environment-specific snapshots so they stay local-only.
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.
What
Replaces template-side type mapping with a Rust type-rendering engine (
xdk-lib/src/types.rs). Generated SDKs are now fully typed wherever the spec defines types — no moreany/Anyfor refs, enums, arrays, or compositions.TypeScript:
schemas.tsgets real interfaces, literal-union enums, union/intersection compositions; typed params and request/response models throughout.anycount in src: ~1334 → 626 (remaining are spec-free-form objects and the deliberate Options index signature).Python: new generated
xdk/schemas.pywith Pydantic models for all component schemas (nested inline objects hoisted, aliases topo-sorted, forward refs resolved at import). Per-tag models alias these; union responses getRootModelwrappers. Kills theTweet = Anyalias table and the required-fields-forced-to-strbug.Anycount: ~932 → 190.Robustness:
has_request_model/has_json_responseflags computed once in Rust (import/definition conditions can't drift), output dirs cleaned before generation, parameter dedup for non-conforming specs, spec-valid test mocks generated from response schemas,nullableparsed, Python keyword-safe field names.Validation