René's URL Explorer Experiment


Title: A oneOf/anyOf branch that is an array of an inline enum gets the same type name as its items · Issue #2640 · oapi-codegen/oapi-codegen · GitHub

Open Graph Title: A oneOf/anyOf branch that is an array of an inline enum gets the same type name as its items · Issue #2640 · oapi-codegen/oapi-codegen

X Title: A oneOf/anyOf branch that is an array of an inline enum gets the same type name as its items · Issue #2640 · oapi-codegen/oapi-codegen

Description: When a union branch is an array whose items are an inline enum, the branch's type and the items' enum type get the same name (...Roles1). In a request body or a parameter, generation succeeds and the output doesn't compile. In a componen...

Open Graph Description: When a union branch is an array whose items are an inline enum, the branch's type and the items' enum type get the same name (...Roles1). In a request body or a parameter, generation succeeds and t...

X Description: When a union branch is an array whose items are an inline enum, the branch's type and the items' enum type get the same name (...Roles1). In a request body or a parameter, generation succee...

Opengraph URL: https://github.com/oapi-codegen/oapi-codegen/issues/2640

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"A oneOf/anyOf branch that is an array of an inline enum gets the same type name as its items","articleBody":"When a union branch is an array whose items are an inline enum, the branch's type and the items' enum type get the same name (`...Roles1`). In a request body or a parameter, generation succeeds and the output doesn't compile. In a component schema, generation fails with \"duplicate typename\", and the suggested `x-go-name` doesn't apply, since both names are generated.\n\n\"A string or a list of strings\" (`oneOf: [string, array of string]`) is a common shape; adding an `enum` to the items is enough to trigger this.\n\n## Reproduction\n\n`openapi.yaml`:\n\n```yaml\nopenapi: 3.0.3\ninfo: {title: t, version: \"1\"}\npaths:\n  /items:\n    post:\n      requestBody:\n        content:\n          application/json:\n            schema:\n              type: object\n              properties:\n                roles:\n                  oneOf:\n                    - {type: string}\n                    - {type: array, items: {type: string, enum: [admin, viewer]}}\n      responses:\n        \"204\": {description: ok}\n```\n\n```console\n$ oapi-codegen -generate types -package api -o api.gen.go openapi.yaml\n$ go build ./...\n./api.gen.go:21:6: invalid recursive type: PostItemsJSONBodyRoles1 refers to itself\n./api.gen.go:24:6: PostItemsJSONBodyRoles1 redeclared in this block\n\t./api.gen.go:21:6: other declaration of PostItemsJSONBodyRoles1\n```\n\nNo configuration file; the module requires `github.com/oapi-codegen/runtime` v1.8.0. The generated code:\n\n```go\n// PostItemsJSONBodyRoles1 defines parameters for PostItems.\ntype PostItemsJSONBodyRoles1 = []PostItemsJSONBodyRoles1\n\n// PostItemsJSONBodyRoles1 defines parameters for PostItems.\ntype PostItemsJSONBodyRoles1 string\n```\n\nOn `main` the first one is `type PostItemsJSONBodyRoles1 []PostItemsJSONBodyRoles1` and only the \"redeclared\" error remains.\n\nThe same `roles` property as a query parameter's schema gives `GetItemsParamsRoles1 redeclared`. Under `components.schemas.Item` (referenced from a response) generation fails instead:\n\n```text\nerror generating code: error generating code for type definitions: duplicate typename 'ItemRoles1' detected, can't auto-rename, please use x-go-name to specify your own name for one of them\n```\n\nIt also happens with a single-branch `oneOf`, with `anyOf`, with an enum on the string branch too, and with `resolve-type-name-collisions: true`. It reproduces on v2.4.1 as well. Setting `x-go-type-name` on the items (`items: {type: string, enum: [admin, viewer], x-go-type-name: Role}`) works around it.\n\n## Expected\n\nTwo distinct types, for example `PostItemsJSONBodyRoles1 []PostItemsJSONBodyRoles1Item` and `PostItemsJSONBodyRoles1Item string`, and code that compiles.\n\n## Versions\n\nv2.8.1 and `main` (15f5714, `v2.8.1-0.20261028140811-15f571472ff8`), Go 1.27.3, linux/amd64.\n\n## Likely cause\n\nAn array's items are generated at the array's own path (`generateGoSchema(ctx.at(itemHint), schema.Items, path)`, `pkg/codegen/schema.go:1729` on main), and an inline enum is named from its path (`schema.go:1693`), so the items' enum takes the array's name. A plain array property never gets a type of its own, so this doesn't show there. But `generateUnionElement` (`pkg/codegen/union.go:89`) names the array branch from that same path. #1878 had a similar shape: an array with an `enum` of its own and an enum on its items, both called `ApprovalConfigurationExclude`.\n","author":{"url":"https://github.com/BogdanYarotsky","@type":"Person","name":"BogdanYarotsky"},"datePublished":"2026-10-29T06:29:10Z","url":"https://github.com/oapi-codegen/oapi-codegen/issues/2640"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:4730a58c-606b-f234-7292-e5dcf2811c75
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idB826:7CC9A:14D2682:1B6C903:6AF9BAB7
html-safe-nonce518d56c1b8b2dc02fd3e63a5185015697f0fd279674d1f4e391851690e461110
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCODI2OjdDQzlBOjE0RDI2ODI6MUI2QzkwMzo2QUY5QkFCNyIsInZpc2l0b3JfaWQiOiI4OTIxMzIwNDQwNTU5NDE4MDM5IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac1efad75c94beb89ea138beafea7bbe84fbde8e09cfcc7f2c2b995e0b53e58f3e
hovercard-subject-tagissue:6094276579
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/oapi-codegen/oapi-codegen/2640/issue_layout
twitter:imagehttps://opengraph.githubassets.com/67a9bbfe7618618876918e88af3c909728fb112f4c25e60a5873d8ca2b801ca1/oapi-codegen/oapi-codegen/issues/2640
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/67a9bbfe7618618876918e88af3c909728fb112f4c25e60a5873d8ca2b801ca1/oapi-codegen/oapi-codegen/issues/2640
og:image:altWhen a union branch is an array whose items are an inline enum, the branch's type and the items' enum type get the same name (...Roles1). In a request body or a parameter, generation succeeds and t...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameBogdanYarotsky
hostnamegithub.com
expected-hostnamegithub.com
None612d3e6ffd693e7ea8d9fcf452370995872baef31d825b1fedef704cd3d24ac7
turbo-cache-controlno-preview
go-importgithub.com/oapi-codegen/oapi-codegen git https://github.com/oapi-codegen/oapi-codegen.git
octolytics-dimension-user_id142752710
octolytics-dimension-user_loginoapi-codegen
octolytics-dimension-repository_id173009358
octolytics-dimension-repository_nwooapi-codegen/oapi-codegen
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id173009358
octolytics-dimension-repository_network_root_nwooapi-codegen/oapi-codegen
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release072e34035c13c31543fba9f025cbbbda4210dae4
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/oapi-codegen/oapi-codegen/issues/2640#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Foapi-codegen%2Foapi-codegen%2Fissues%2F2640
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Foapi-codegen%2Foapi-codegen%2Fissues%2F2640
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=oapi-codegen%2Foapi-codegen
Reloadhttps://github.com/oapi-codegen/oapi-codegen/issues/2640
Reloadhttps://github.com/oapi-codegen/oapi-codegen/issues/2640
Reloadhttps://github.com/oapi-codegen/oapi-codegen/issues/2640
oapi-codegenhttps://github.com/oapi-codegen
oapi-codegenhttps://github.com/oapi-codegen/oapi-codegen
Codehttps://github.com/oapi-codegen/oapi-codegen
Issues228 (228)https://github.com/oapi-codegen/oapi-codegen/issues
Pull requests70 (70)https://github.com/oapi-codegen/oapi-codegen/pulls
Discussionshttps://github.com/oapi-codegen/oapi-codegen/discussions
Actionshttps://github.com/oapi-codegen/oapi-codegen/actions
Projectshttps://github.com/oapi-codegen/oapi-codegen/projects
Security and quality11 (11)https://github.com/oapi-codegen/oapi-codegen/security
Insightshttps://github.com/oapi-codegen/oapi-codegen/pulse
https://github.com/oapi-codegen/oapi-codegen
New issuehttps://github.com/login?return_to=https://github.com/oapi-codegen/oapi-codegen/issues/2640
New issuehttps://github.com/login?return_to=https://github.com/oapi-codegen/oapi-codegen/issues/2640
#2653https://github.com/oapi-codegen/oapi-codegen/pull/2653
A oneOf/anyOf branch that is an array of an inline enum gets the same type name as its itemshttps://github.com/oapi-codegen/oapi-codegen/issues/2640#top
#2653https://github.com/oapi-codegen/oapi-codegen/pull/2653
https://github.com/BogdanYarotsky
BogdanYarotskyhttps://github.com/BogdanYarotsky
on Oct 29, 2026https://github.com/oapi-codegen/oapi-codegen/issues/2640#issue-6094276579
15f5714https://github.com/oapi-codegen/oapi-codegen/commit/15f571472ff8ad02665635d9254ada6c1f32c214
#1878https://github.com/oapi-codegen/oapi-codegen/issues/1878
ahm3dwasimhttps://github.com/ahm3dwasim
on Nov 1, 2026https://github.com/oapi-codegen/oapi-codegen/issues/2640#event-34824075520
fix: give inline-enum items of a oneOf/anyOf array branch their own t…https://github.com/ahm3dwasim/oapi-codegen/commit/4e902749548bfaff06cec0428b7911f10f957a9d
https://docs.github.com/articles/closing-issues-via-commit-messages
4e90274https://github.com/ahm3dwasim/oapi-codegen/commit/4e902749548bfaff06cec0428b7911f10f957a9d
Sign up for freehttps://github.com/signup?return_to=https://github.com/oapi-codegen/oapi-codegen/issues/2640
Sign in to commenthttps://github.com/login?return_to=https://github.com/oapi-codegen/oapi-codegen/issues/2640
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.