René's URL Explorer Experiment


Title: Invalid generated code on reusing responses · Issue #2190 · oapi-codegen/oapi-codegen · GitHub

Open Graph Title: Invalid generated code on reusing responses · Issue #2190 · oapi-codegen/oapi-codegen

X Title: Invalid generated code on reusing responses · Issue #2190 · oapi-codegen/oapi-codegen

Description: Hi, we just upgraded from oapi-codegen 2.3.0 to 2.5.1 and our go code generated from OpenAPI isn't valid anymore. I pinned down the issue to response components being referenced in endpoints and came up with this minimal reproducible spe...

Open Graph Description: Hi, we just upgraded from oapi-codegen 2.3.0 to 2.5.1 and our go code generated from OpenAPI isn't valid anymore. I pinned down the issue to response components being referenced in endpoints and ca...

X Description: Hi, we just upgraded from oapi-codegen 2.3.0 to 2.5.1 and our go code generated from OpenAPI isn't valid anymore. I pinned down the issue to response components being referenced in endpoints an...

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

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Invalid generated code on reusing responses","articleBody":"Hi,\n\nwe just upgraded from oapi-codegen 2.3.0 to 2.5.1 and our go code generated from OpenAPI isn't valid anymore. I pinned down the issue to response components being referenced in endpoints and came up with this minimal reproducible spec:\n\n```\nopenapi: 3.0.3\ninfo:\n  title: test\n  version: 1.0.0\nservers:\n  - url: https://te.st\npaths:\n  /v1/test:\n    get:\n      operationId: GetTest\n      responses:\n        \"200\":\n          $ref: \"#/components/responses/Success\"\n        \"401\":\n          $ref: \"#/components/responses/Unauthorized\"\ncomponents:\n  responses:\n    Success:\n      description: Success\n      content:\n        application/json:\n          schema:\n            type: string\n    Unauthorized:\n      description: Unauthorized\n      content:\n        text/plain:\n          schema:\n            type: string\n          example: \"Unauthorized\"\n```\n\nWe execute oapi-codegen with this configuration:\n```\npackage: test\noutput: api.gen.go\ngenerate:\n  std-http-server: true\n  strict-server: true\n  models: true\n  client: true\noutput-options:\n  nullable-type: true\n```\n\nThe generated go code contains this:\n```\ntype UnauthorizedTextResponse string\n\ntype GetTest401TextResponse struct{ UnauthorizedTextResponse }\n\nfunc (response GetTest401TextResponse) VisitGetTestResponse(w http.ResponseWriter) error {\n\tw.Header().Set(\"Content-Type\", \"text/plain\")\n\tw.WriteHeader(401)\n\n\t_, err := w.Write([]byte(response))\n\treturn err\n}\n```\n\nwhich is invalid as `response` is of type `GetTest401TextResponse` and cannot be converted to `[]byte`.\n\nWe are using Go version 1.25.7.\n\nI would appreciate if you could have a look, would also be happy to contribute.\nCheers ","author":{"url":"https://github.com/bravenut","@type":"Person","name":"bravenut"},"datePublished":"2026-01-28T11:48:58.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":4},"url":"https://github.com/2190/oapi-codegen/issues/2190"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:dd02ec1c-efc9-44d0-9ec3-30f66dc005d0
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idCCCA:A8D95:BC821F:FBDEFC:6A51AA4E
html-safe-nonce65bba19dec3cbe2b500b6b7d04694394b933c40b8d713444df8d9dda6cf5ace4
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDQ0NBOkE4RDk1OkJDODIxRjpGQkRFRkM6NkE1MUFBNEUiLCJ2aXNpdG9yX2lkIjoiOTA3MTk4MjA2MDcyNjQ5NTgyMiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac5373b57ae4c11e4856e7a4943ae39b655d77e29868fe3f115e0549fd9fd35b23
hovercard-subject-tagissue:3865041868
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/2190/issue_layout
twitter:imagehttps://opengraph.githubassets.com/ad560a33b165a6e278cc8b1600d54f89cfc6f7e7e0497603c93e420419a29cad/oapi-codegen/oapi-codegen/issues/2190
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/ad560a33b165a6e278cc8b1600d54f89cfc6f7e7e0497603c93e420419a29cad/oapi-codegen/oapi-codegen/issues/2190
og:image:altHi, we just upgraded from oapi-codegen 2.3.0 to 2.5.1 and our go code generated from OpenAPI isn't valid anymore. I pinned down the issue to response components being referenced in endpoints and ca...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamebravenut
hostnamegithub.com
expected-hostnamegithub.com
Noneb9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb
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
release7aed05249554b889eb33d002851a973eebcc7e91
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/oapi-codegen/oapi-codegen/issues/2190#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Foapi-codegen%2Foapi-codegen%2Fissues%2F2190
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
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
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/open-source/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/open-source/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://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
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Foapi-codegen%2Foapi-codegen%2Fissues%2F2190
Sign up https://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/2190
Reloadhttps://github.com/oapi-codegen/oapi-codegen/issues/2190
Reloadhttps://github.com/oapi-codegen/oapi-codegen/issues/2190
Please reload this pagehttps://github.com/oapi-codegen/oapi-codegen/issues/2190
oapi-codegen https://github.com/oapi-codegen
oapi-codegenhttps://github.com/oapi-codegen/oapi-codegen
Please reload this pagehttps://github.com/oapi-codegen/oapi-codegen/issues/2190
Notifications https://github.com/login?return_to=%2Foapi-codegen%2Foapi-codegen
Fork 1k https://github.com/login?return_to=%2Foapi-codegen%2Foapi-codegen
Star 8.4k https://github.com/login?return_to=%2Foapi-codegen%2Foapi-codegen
Code https://github.com/oapi-codegen/oapi-codegen
Issues 291 https://github.com/oapi-codegen/oapi-codegen/issues
Pull requests 65 https://github.com/oapi-codegen/oapi-codegen/pulls
Discussions https://github.com/oapi-codegen/oapi-codegen/discussions
Actions https://github.com/oapi-codegen/oapi-codegen/actions
Projects https://github.com/oapi-codegen/oapi-codegen/projects
Security and quality 3 https://github.com/oapi-codegen/oapi-codegen/security
Insights https://github.com/oapi-codegen/oapi-codegen/pulse
Code https://github.com/oapi-codegen/oapi-codegen
Issues https://github.com/oapi-codegen/oapi-codegen/issues
Pull requests https://github.com/oapi-codegen/oapi-codegen/pulls
Discussions https://github.com/oapi-codegen/oapi-codegen/discussions
Actions https://github.com/oapi-codegen/oapi-codegen/actions
Projects https://github.com/oapi-codegen/oapi-codegen/projects
Security and quality https://github.com/oapi-codegen/oapi-codegen/security
Insights https://github.com/oapi-codegen/oapi-codegen/pulse
Bughttps://github.com/oapi-codegen/oapi-codegen/issues?q=type:"Bug"
#2225https://github.com/oapi-codegen/oapi-codegen/pull/2225
Invalid generated code on reusing responseshttps://github.com/oapi-codegen/oapi-codegen/issues/2190#top
#2225https://github.com/oapi-codegen/oapi-codegen/pull/2225
https://github.com/mromaszewicz
regressionhttps://github.com/oapi-codegen/oapi-codegen/issues?q=state%3Aopen%20label%3A%22regression%22
server:stricthttps://github.com/oapi-codegen/oapi-codegen/issues?q=state%3Aopen%20label%3A%22server%3Astrict%22
v2.6.0https://github.com/oapi-codegen/oapi-codegen/milestone/13
https://github.com/bravenut
bravenuthttps://github.com/bravenut
on Jan 28, 2026https://github.com/oapi-codegen/oapi-codegen/issues/2190#issue-3865041868
mromaszewiczhttps://github.com/mromaszewicz
regressionhttps://github.com/oapi-codegen/oapi-codegen/issues?q=state%3Aopen%20label%3A%22regression%22
server:stricthttps://github.com/oapi-codegen/oapi-codegen/issues?q=state%3Aopen%20label%3A%22server%3Astrict%22
Bughttps://github.com/oapi-codegen/oapi-codegen/issues?q=type:"Bug"
v2.6.0https://github.com/oapi-codegen/oapi-codegen/milestone/13
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.