Chore: Fork-free code generation and regenerated Components.swift - #441
Closed
Krivoblotsky wants to merge 6 commits into
Closed
Krivoblotsky wants to merge 6 commits into
Krivoblotsky wants to merge 6 commits into
Conversation
make generate now clones and builds the pinned generator release under .build/ and installs PyYAML into a virtualenv there; no sibling checkout or private fork is needed. Two scripts replace the fork's patches: transform_openapi.py collapses OpenAI's anyOf-with-null nullability into optional properties (the stock generator drops those properties) and records the wire values of every discriminated union, whose discriminators have no mapping in the spec; postprocess_components.py re-wraps the 1.13 multi-file output under the existing header, appends the wire values per union and adds the try-both fallback for the message value shared by InputMessage and OutputMessage. It supersedes extract_components.py. fix_recursive_reference.py now handles any number of recursive references, which the live spec requires. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Same vendored spec, stock generator 1.13.1. The 29 generated-type differences against 0.5.1 are recorded in the API allowlist and explained in the changelog: 23 nested typealias artifacts of the previous nullable handling are gone, CreateTranscriptionRequest.ChunkingStrategyPayload.body is no longer optional, and CreateTranscriptionRequest gained a stream part. Two regression tests cover decoding the previous patches got wrong: ItemResource accepts input messages and InputItem decodes item_reference by wire value. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Runs the generation pipeline on every pull request and push to main and fails if the committed file differs, so generated schemas cannot drift from the pipeline. The built generator is cached per version and Swift toolchain. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…rmat The breakage allowlist must contain messages only: with a comment or blank line present the checker matches none of the entries. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Krivoblotsky
force-pushed
the
chore/fork-free-generation
branch
from
September 14, 2026 14:16
38ca98b to
684760c
Compare
Lets a stacked pull request, whose base is not main, get the platform matrix on demand. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Krivoblotsky
changed the base branch from
chore/phase-0-ci-safety-net
to
main
September 14, 2026 14:18
Krivoblotsky
changed the base branch from
main
to
chore/phase-0-ci-safety-net
September 14, 2026 14:31
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
Makes
make generatea one-command, fork-free operation and regeneratesComponents.swiftwith it..build/, and installs the one Python dependency (PyYAML) into a virtualenv there. Prerequisites are a Swift toolchain,python3withvenv, and network access on the first run.Scripts/transform_openapi.pycollapses OpenAI'sanyOf: [X, {type: 'null'}]nullability into optional properties (481 sites in the vendored spec; the stock generator otherwise drops every such property) and records the wire values of all 45 discriminated unions, whose discriminators have nomappingin the spec.Scripts/postprocess_components.pyre-wraps the generator's 1.13 multi-file output under the existing header, appends the wire values to each union's decoder, and adds the try-both fallback formessage, which names bothInputMessageandOutputMessage. It supersedesScripts/extract_components.py.Scripts/fix_recursive_reference.pyhandles any number of$recursiveRefoccurrences, each pointed at its enclosing component. The live spec now has two (CompoundFilter,BetaCompoundFilter) and the strict one-occurrence version aborts on it.Generationworkflow: runsmake generateon every PR and fails when the committedComponents.swiftdiffers, so the file can never drift from the pipeline again. The built generator is cached per version and Swift toolchain.Components.swiftfrom the unchanged vendored spec. Two regression tests cover behaviour the fork got wrong:ItemResourcenow decodes input messages, andInputItemdecodesitem_referenceby its wire value.Why
Regeneration only worked on one machine: it required a sibling checkout of an unpinned, unpublished fork of the generator. Upstream has not shipped the missing behaviour (nullable
anyOfhas been open since 2024 and the maintainer considers a proper fix a breaking change), and generator 1.13 changed its output layout in a way the old extraction script could not handle. The upstream maintainer's recommended workaround is exactly this: fix the spec before generation instead of patching the generator. Full analysis: the "Generation Without the Fork" audit.Affected Areas
Generation tooling (
Makefile,Scripts/,openapi-generator-config.yamlunchanged), CI (.github/workflows/generation.yml), the generatedComponents.swift, two tests, docs. No hand-written source changes.The regenerated schemas differ from the fork's output in 29 API-gate lines, all recorded in
.github/api-breakage-allowlist.txtwith the changelog entry:anyOfalive (for exampleOutputMessage.MessagePhase,CreateResponse.Value3Payload.IncludeEnum); the top-level types they aliased are unchanged. Keeping theanyOfinstead produces 5,000 lines of wrapper structs, so collapsing is the right call.CreateTranscriptionRequest.ChunkingStrategyPayload.bodyis no longer optional (a request-side generated type the SDK does not use itself), andCreateTranscriptionRequestgained astreampart.If exact parity is preferred, the post-processor can re-add the 23 typealiases; say so and I will add it before merge.
More Info
mainwhen Chore: Add API breakage gate, platform CI matrix and changelog (Phase 0) #440 merges.make generateruns in about 6 seconds with a built generator; the full suite passes; the same pipeline generates the live September 2026 spec cleanly (Phase 2 then needs changes in two hand-written files only).WebSearchActionSearch/queryis still removed fromrequiredfor the vendored spec; the live spec no longer requires it, so that entry goes when the spec is updated (noted in the Makefile).🤖 Generated with Claude Code