You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To support enumStyle (#5223), we need to upgrade oazapfts from v6 to v7. However, v7 removes the ApiGenerator class and oazapfts/generate export path entirely — the semi-official APIs that codegen currently depends on. The new public API is limited to createContext (oazapfts/context), UNSTABLE_cg, and generateAst (oazapfts).
In #4265, @Xiphe notified that v7 would remove these APIs, and a Plugin System is in early development (oazapfts#805).
Migration options
Option A: Reimplement lazy type generation locally
Compatibility adapter (~400 lines) using v7's createContext + UNSTABLE_cg, reimplementing the removed ApiGenerator behavior.
Pro: Preserves v6's lazy architecture — types are created on-demand per $ref, so filterEndpoints works naturally.
Con: ~400 lines of type generation logic that needs manual sync when oazapfts evolves.
Option B: Use generateAst + post-filter unreferenced types
Use v7's generateAst(ctx) to generate all types upfront, then filter out types not referenced by selected endpoints.
Pro: Delegates type generation to oazapfts — bug fixes and new features are inherited automatically.
Con: Requires AST-based transitive closure to determine referenced types. Circular references and discriminator patterns make this non-trivial.
Proof of concept
I have a working implementation of Option A that passes all 73 existing tests, including enumStyle: 'union' | 'enum' | 'as-const' support and proper handling of discriminator patterns, readOnly/writeOnly, and unionUndefined. Happy to share as a draft PR, or pivot to another approach.
Questions
Which migration approach is preferred? Option A is ready now but adds maintenance; Option B delegates more but requires filter logic. Or should we wait for the Plugin System (Oazapfts will get plugins #4265) instead?
Is it worth coordinating with @Xiphe on what RTK codegen would need from the plugin API?
Should the v7 migration be a separate PR from enumStyle? The migration is a prerequisite, but splitting might make review easier.
@Xiphe Thanks for the offer! Would love to collaborate.
PR #5228 currently reimplements lazy type generation using createContext + UNSTABLE_cg. The key hooks RTK codegen would need:
Lazy/on-demand type generation — types created per $ref as endpoints are processed (not all upfront), so filterEndpoints works naturally
Per-endpoint code generation control — select which operations to generate
Access to schema-to-type mapping — discriminator patterns, readOnly/writeOnly, unionUndefined
Happy to use the current adapter as a bridge until the plugin API covers these.
Context
To support
enumStyle(#5223), we need to upgrade oazapfts from v6 to v7. However, v7 removes theApiGeneratorclass andoazapfts/generateexport path entirely — the semi-official APIs that codegen currently depends on. The new public API is limited tocreateContext(oazapfts/context),UNSTABLE_cg, andgenerateAst(oazapfts).In #4265, @Xiphe notified that v7 would remove these APIs, and a Plugin System is in early development (oazapfts#805).
Migration options
Option A: Reimplement lazy type generation locally
Compatibility adapter (~400 lines) using v7's
createContext+UNSTABLE_cg, reimplementing the removedApiGeneratorbehavior.$ref, sofilterEndpointsworks naturally.Option B: Use
generateAst+ post-filter unreferenced typesUse v7's
generateAst(ctx)to generate all types upfront, then filter out types not referenced by selected endpoints.Proof of concept
I have a working implementation of Option A that passes all 73 existing tests, including
enumStyle: 'union' | 'enum' | 'as-const'support and proper handling of discriminator patterns, readOnly/writeOnly, andunionUndefined. Happy to share as a draft PR, or pivot to another approach.Questions
enumStyle? The migration is a prerequisite, but splitting might make review easier.Related
enumStyleoption from oazapfts v7.3.0 #5223 —enumStylefeature requestenumStylein oazapfts@Xiphe Thanks for the offer! Would love to collaborate.
PR #5228 currently reimplements lazy type generation using
createContext+UNSTABLE_cg. The key hooks RTK codegen would need:$refas endpoints are processed (not all upfront), sofilterEndpointsworks naturallyunionUndefinedHappy to use the current adapter as a bridge until the plugin API covers these.
cc @aryaemami59 @markerikson — any thoughts?