Skip to content

fix: a property's x-go-name beside its $ref names its field; more extensions on the roadmap - #87

Merged
MarkRosemaker merged 2 commits into
mainfrom
fix/go-name-beside-ref
Nov 25, 2026
Merged

MarkRosemaker merged 2 commits into
mainfrom
fix/go-name-beside-ref

Conversation

@MarkRosemaker

@MarkRosemaker MarkRosemaker commented Nov 25, 2026 •

Copy link
Copy Markdown
Owner

A property that is a $ref took its Go field name only from the referenced schema's x-go-name. One written beside the reference was ignored, even though a description there 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 netliquidation and availablefunds-s, all of one SummaryValue type. Each has its own x-go-name beside the $ref, yet they generated Netliquidation and AvailablefundsS.

Now the property's own x-go-name wins. The referenced schema's still names the field where the property has none, as TestFromComponentSchemas_XGoNameRespectedThroughRef covers. A tuple's items get the same.

oapi-codegen behaves this way too. Its combinedSchemaExtensions copies the referenced schema's extensions, then the reference's own over them.

Test: TestFromComponentSchemas_XGoNameBesideRef, a netliquidation property that's a $ref with x-go-name: NetLiquidation. Without the fix it generates Netliquidation.

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-import
  • x-go-type-skip-optional-pointer
  • x-omitzero
  • x-oapi-codegen-extra-tags
  • x-deprecated-reason
  • x-order

It also says in one line why the rest don't fit.

Checked against ibkr: with this generator its summary fields are AccountCode, NetLiquidation, AvailableFundsSecurities and so on. make ready passes here, and the golden files are unchanged.

🤖 Generated with Claude Code

https://claude.ai/code/session_019QCb1AfnATvpBQCH3PrX7Y

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
@MarkRosemaker MarkRosemaker changed the title fix: a property's x-go-name beside its $ref names its field fix: a property's x-go-name beside its $ref names its field; more extensions on the roadmap Nov 25, 2026
@MarkRosemaker
MarkRosemaker merged commit 09697b4 into main Nov 25, 2026
1 check passed
@MarkRosemaker
MarkRosemaker deleted the fix/go-name-beside-ref branch November 25, 2026 18:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants