Repository navigation
fix: a property's x-go-name beside its $ref names its field; more extensions on the roadmap - #87
Merged
Merged
Conversation
A property that is a $ref took its field name from the referenced schema's x-go-name alone, so one written beside the reference was ignored, though a description there is read. go-api-libs/ibkr's portfolio summary has 50 properties of one SummaryValue type, each needing its own name. The property's own x-go-name now wins, the referenced schema's still serving where it has none; a tuple's items likewise. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019QCb1AfnATvpBQCH3PrX7Y
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019QCb1AfnATvpBQCH3PrX7Y
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.
A property that is a
$reftook its Go field name only from the referenced schema'sx-go-name. One written beside the reference was ignored, even though adescriptionthere is read. So many properties of one component type couldn't each get their own name.go-api-libs/ibkr's portfolio summary needs exactly that: 50 properties, such as
netliquidationandavailablefunds-s, all of oneSummaryValuetype. Each has its ownx-go-namebeside the$ref, yet they generatedNetliquidationandAvailablefundsS.Now the property's own
x-go-namewins. The referenced schema's still names the field where the property has none, asTestFromComponentSchemas_XGoNameRespectedThroughRefcovers. A tuple's items get the same.oapi-codegen behaves this way too. Its
combinedSchemaExtensionscopies the referenced schema's extensions, then the reference's own over them.Test:
TestFromComponentSchemas_XGoNameBesideRef, anetliquidationproperty that's a$refwithx-go-name: NetLiquidation. Without the fix it generatesNetliquidation.Roadmap: a new entry, "More of oapi-codegen's extensions". It lists the ones that would fit, each to be done as oapi-codegen has it once a spec needs it:
x-go-type/x-go-type-importx-go-type-skip-optional-pointerx-omitzerox-oapi-codegen-extra-tagsx-deprecated-reasonx-orderIt also says in one line why the rest don't fit.
Checked against ibkr: with this generator its summary fields are
AccountCode,NetLiquidation,AvailableFundsSecuritiesand so on.make readypasses here, and the golden files are unchanged.🤖 Generated with Claude Code
https://claude.ai/code/session_019QCb1AfnATvpBQCH3PrX7Y