refactor: pass each phase a context instead of shared loop state - #22
Merged
Merged
Conversation
schemaToValidator keeps the dispatch and hands each branch to a helper: enum, type array, string, int64, number, combinators with the allOf composer, and object. createValidatorForOperationInput builds its schema pairs through module-level emitters parameterised on the object kind and the key mapper. Co-Authored-By: LLM <noreply@block65.dev>
The document phases are now functions over a DocumentContext: output files, module preambles, component schemas, operations, client module, validated module, hono module and the trailing type-argument trim. Each operation builds an OperationShape record: its command class, resolved parameters, the query, header, params and body type aliases, and the input type. The record is what the type-argument and constructor phases read, so the loop-local variables the old body shared are declared once. Co-Authored-By: LLM <noreply@block65.dev>
schemaToType hands each schema shape to a helper and spreads the type it returns into the property structure. registerTypesFromSchema ends every case through one registerAlias helper and takes its combinator and named-string cases from their own functions. Co-Authored-By: LLM <noreply@block65.dev>
Co-Authored-By: LLM <noreply@block65.dev>
…alike OperationShape carried `parameters` as one nested group while the three type aliases sat flat beside it, so every consumer re-paired them by hand. The locations are now sibling pairs, like the body and input fields already were: queryParameters/queryType, headerParameters/ headerType, pathParameters/pathType. `paramsType` becomes `pathType` so each pair shares its prefix. The per-document and per-operation contexts serve the same purpose, so they are named the same way. OperationShape is now OperationContext, and the variables are documentCtx and operationCtx. Three comments go: two restated the declaration below them, one restated a ternary. Where one carried a reason, the reason stays as a clause. Co-Authored-By: LLM <noreply@block65.dev>
Only the `#generator` fingerprint moves. Every per-file content hash is unchanged, so the emitted clients are byte-identical across the refactor. Co-Authored-By: LLM <noreply@block65.dev>
`defineOverrides` already returns the array, so the spread rebuilt it. Co-Authored-By: LLM <noreply@block65.dev>
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.
processOpenApiDocumentheld every operation's state in loop-local variables that later phases read out of the enclosing scope, so it could not be split while its parts shared that scope. Each phase is now a function over a context —DocumentContextper document,OperationContextper operation — and reads one value instead. The same split coversschemaToValidator,createValidatorForOperationInput,schemaToTypeandregisterTypesFromSchema.Every function oxlint flagged on
max-statements,complexityormax-lines-per-functionnow meets the limits by extraction, with no disable comments and no rule changes.Proof
Fixture regeneration changes no generated file. The only diff under
__tests__/fixturesis the#generatorstamp in each manifest, which hashes the generator sources.