test(generator): a spec that crosses features, generated, compiled, and vetted - #119
Merged
Conversation
…ed schemas
allOf is JSON Schema 2020-12 composition, which 3.1 uses, and it is valid
anywhere a schema is. convertSchema composes it for a named component schema
and resolveGoType, which types every inline property, never looked at it, so
a property that composed anything resolved to any.
In a 3.1 spec today:
allOf: [$ref, {inline object}] -> any
allOf: [$ref] -> any
$ref with sibling keywords -> the referenced type
anyOf: [$ref, {type: null}] -> the referenced type
The first two are the inconsistency: the same composition on a named schema
builds a struct. A lone $ref inside an allOf says the value must match that
schema, so it resolves to it; anything more composes a shape of its own and
is named like other inline schemas, keeping both what it embeds and what it
adds.
The two idioms 3.1 offers instead already worked, and now have a test that
keeps them working.
…parts The composition path this PR adds converted its schema as if it were sent as JSON, so a multipart body written as allOf typed its binary properties as byte slices and the encoder sent them as base64 text in ordinary fields, the same failure #90 fixed for a body written as an object. Multipart is a property of where a schema is used, so the composition path consults it the same way the object path does.
…nd vetted The tests around this one each drive a single feature through a spec written for it. What none of them catch is a feature that quietly stops happening in the presence of another, or one that disappears while the package still builds. Every bug found by generating real specs by hand was invisible to this suite: iterators generated for no operation, a page parameter that is not a number, a file part that turned back into base64 text. testdata/combinations.yaml crosses them deliberately: three pagination styles in one package, one of them iterating a union, a multipart body that composes a schema, webhooks beside callbacks, headers and properties whose names normalize together, schemas named after identifiers the templates declare, and an operation that opts out of the document's security. The assertions are features that have each regressed at least once, and the generated package is compiled and vetted rather than only compiled: vet catches what builds and is still wrong. Writing it found one more, fixed in the commit before this: a multipart body composed through allOf lost its file parts.
This was referenced Aug 21, 2026
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.
Depends on #117; this branch is stacked on it, since the corpus spec composes a multipart body through
allOf. Merge that one first.Why
The suite has 62 e2e tests, and each drives one feature through a spec written for it. None of them catch a feature that quietly stops happening in the presence of another, or one that disappears entirely while the package still builds.
Every bug from the last stretch was found by generating real specs by hand, and every one was invisible here:
What this adds
testdata/combinations.yaml, a 3.1 spec that crosses features rather than listing them:allOfClientandDefaultBaseURL, which the templates declareconstand share a baseallowReservedone, and a union-typed oneThe test asserts each of those survived, then compiles and vets the output.
go vetrather than build alone: it catches what compiles and is still wrong.Assertions compare with whitespace collapsed, since the files reach the test before goimports aligns them.
It found one immediately
An inline multipart body composed through
allOflost its file parts, typing them as byte slices so the encoder sent base64 text in ordinary fields. That is the same failure #90 fixed for a body written as an object, in the path #117 introduced. Fixed in #117, with the commit that adds it.gofmt,golangci-lint,go vet ./..., andgo test ./...pass.