René's URL Explorer Experiment


Title: Invalid Code is generated for lists inside a union · Issue #756 · openapi-generators/openapi-python-client · GitHub

Open Graph Title: Invalid Code is generated for lists inside a union · Issue #756 · openapi-generators/openapi-python-client

X Title: Invalid Code is generated for lists inside a union · Issue #756 · openapi-generators/openapi-python-client

Description: Describe the bug When a list occurs inside a union, this call causes the list template to initialize the value with UNSET instead of []. The list template then tries to call append on UNSET, which of course does not work. OpenAPI Spec Fi...

Open Graph Description: Describe the bug When a list occurs inside a union, this call causes the list template to initialize the value with UNSET instead of []. The list template then tries to call append on UNSET, which ...

X Description: Describe the bug When a list occurs inside a union, this call causes the list template to initialize the value with UNSET instead of []. The list template then tries to call append on UNSET, which ...

Opengraph URL: https://github.com/openapi-generators/openapi-python-client/issues/756

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Invalid Code is generated for lists inside a union","articleBody":"**Describe the bug**\r\nWhen a list occurs inside a union, [this call](https://github.com/openapi-generators/openapi-python-client/blob/508a841eea69da5f8e868ee20d785b16426212d4/openapi_python_client/templates/property_templates/union_property.py.jinja#L31) causes the list template to initialize the value with `UNSET` instead of `[]`. The list template then tries to call `append` on `UNSET`, which of course does not work.\r\n\r\n**OpenAPI Spec File**\r\n[A link to your openapi.json which produces this issue.](https://gist.github.com/diesieben07/267dd33e21a206ce4bc9a8906bba259e)\r\n\r\n**Desktop (please complete the following information):**\r\n - OS: Ubuntu 22.04.2\r\n - Python Version: 2.10.8\r\n - openapi-python-client version 0.14.0\r\n\r\n**Additional context**\r\nThe above OpneAPI spec file generates the following code, for reference:\r\n```python\r\ndef _parse_response(\r\n    *, client: Client, response: httpx.Response\r\n) -\u003e Optional[Union[\"GetExampleResponse200Type0\", List[\"GetExampleResponse200Type1Item\"]]]:\r\n    if response.status_code == HTTPStatus.OK:\r\n\r\n        def _parse_response_200(\r\n            data: object,\r\n        ) -\u003e Union[\"GetExampleResponse200Type0\", List[\"GetExampleResponse200Type1Item\"]]:\r\n            try:\r\n                if not isinstance(data, dict):\r\n                    raise TypeError()\r\n                response_200_type_0 = GetExampleResponse200Type0.from_dict(data)\r\n\r\n                return response_200_type_0\r\n            except:  # noqa: E722\r\n                pass\r\n            if not isinstance(data, list):\r\n                raise TypeError()\r\n            response_200_type_1 = UNSET # PROBLEM IS HERE\r\n            _response_200_type_1 = data\r\n            for response_200_type_1_item_data in _response_200_type_1:\r\n                response_200_type_1_item = GetExampleResponse200Type1Item.from_dict(response_200_type_1_item_data)\r\n\r\n                response_200_type_1.append(response_200_type_1_item)\r\n\r\n            return response_200_type_1\r\n\r\n        response_200 = _parse_response_200(response.json())\r\n\r\n        return response_200\r\n    if client.raise_on_unexpected_status:\r\n        raise errors.UnexpectedStatus(response.status_code, response.content)\r\n    else:\r\n        return None\r\n```\r\n","author":{"url":"https://github.com/diesieben07","@type":"Person","name":"diesieben07"},"datePublished":"2023-05-04T12:02:59.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/756/openapi-python-client/issues/756"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:943e99c9-a523-22d1-f32c-6aed00c0bac9
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idB3C2:BCA9F:2D2E86A:3C7FE38:69807ED4
html-safe-nonce86bc575570a9155993453250ff2bb199761e9e05ea428b5442b57327a14a7f94
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCM0MyOkJDQTlGOjJEMkU4NkE6M0M3RkUzODo2OTgwN0VENCIsInZpc2l0b3JfaWQiOiI4Mjc1MzYyNzUzNjk1MjE5NDEyIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac50fc9e7b0577b2149bef0be557bbe4b9f1729289f0a963dd75c0c75e3d7c90c0
hovercard-subject-tagissue:1695875013
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/openapi-generators/openapi-python-client/756/issue_layout
twitter:imagehttps://opengraph.githubassets.com/bd4c1726005406678a76ce8c4d69fd5aab2f4a1d6b0a6b291f59289356d94530/openapi-generators/openapi-python-client/issues/756
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/bd4c1726005406678a76ce8c4d69fd5aab2f4a1d6b0a6b291f59289356d94530/openapi-generators/openapi-python-client/issues/756
og:image:altDescribe the bug When a list occurs inside a union, this call causes the list template to initialize the value with UNSET instead of []. The list template then tries to call append on UNSET, which ...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamediesieben07
hostnamegithub.com
expected-hostnamegithub.com
None4590f1c00c56e5b3a3460b81e4236454a157a2159793b09a2ddee090670e75fb
turbo-cache-controlno-preview
go-importgithub.com/openapi-generators/openapi-python-client git https://github.com/openapi-generators/openapi-python-client.git
octolytics-dimension-user_id84925606
octolytics-dimension-user_loginopenapi-generators
octolytics-dimension-repository_id240776275
octolytics-dimension-repository_nwoopenapi-generators/openapi-python-client
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id240776275
octolytics-dimension-repository_network_root_nwoopenapi-generators/openapi-python-client
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
release242fda17fe105562f9eb7fe91a7a0dca07c527b3
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/openapi-generators/openapi-python-client/issues/756#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fopenapi-generators%2Fopenapi-python-client%2Fissues%2F756
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub SparkBuild and deploy intelligent appshttps://github.com/features/spark
GitHub ModelsManage and compare promptshttps://github.com/features/models
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
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
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/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%2Fopenapi-generators%2Fopenapi-python-client%2Fissues%2F756
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=openapi-generators%2Fopenapi-python-client
Reloadhttps://github.com/openapi-generators/openapi-python-client/issues/756
Reloadhttps://github.com/openapi-generators/openapi-python-client/issues/756
Reloadhttps://github.com/openapi-generators/openapi-python-client/issues/756
openapi-generators https://github.com/openapi-generators
openapi-python-clienthttps://github.com/openapi-generators/openapi-python-client
Please reload this pagehttps://github.com/openapi-generators/openapi-python-client/issues/756
Notifications https://github.com/login?return_to=%2Fopenapi-generators%2Fopenapi-python-client
Fork 264 https://github.com/login?return_to=%2Fopenapi-generators%2Fopenapi-python-client
Star 1.9k https://github.com/login?return_to=%2Fopenapi-generators%2Fopenapi-python-client
Code https://github.com/openapi-generators/openapi-python-client
Issues 77 https://github.com/openapi-generators/openapi-python-client/issues
Pull requests 14 https://github.com/openapi-generators/openapi-python-client/pulls
Discussions https://github.com/openapi-generators/openapi-python-client/discussions
Actions https://github.com/openapi-generators/openapi-python-client/actions
Security 2 https://github.com/openapi-generators/openapi-python-client/security
Insights https://github.com/openapi-generators/openapi-python-client/pulse
Code https://github.com/openapi-generators/openapi-python-client
Issues https://github.com/openapi-generators/openapi-python-client/issues
Pull requests https://github.com/openapi-generators/openapi-python-client/pulls
Discussions https://github.com/openapi-generators/openapi-python-client/discussions
Actions https://github.com/openapi-generators/openapi-python-client/actions
Security https://github.com/openapi-generators/openapi-python-client/security
Insights https://github.com/openapi-generators/openapi-python-client/pulse
New issuehttps://github.com/login?return_to=https://github.com/openapi-generators/openapi-python-client/issues/756
New issuehttps://github.com/login?return_to=https://github.com/openapi-generators/openapi-python-client/issues/756
#930https://github.com/openapi-generators/openapi-python-client/pull/930
Invalid Code is generated for lists inside a unionhttps://github.com/openapi-generators/openapi-python-client/issues/756#top
#930https://github.com/openapi-generators/openapi-python-client/pull/930
🐞bugSomething isn't workinghttps://github.com/openapi-generators/openapi-python-client/issues?q=state%3Aopen%20label%3A%22%F0%9F%90%9Ebug%22
https://github.com/diesieben07
https://github.com/diesieben07
diesieben07https://github.com/diesieben07
on May 4, 2023https://github.com/openapi-generators/openapi-python-client/issues/756#issue-1695875013
this callhttps://github.com/openapi-generators/openapi-python-client/blob/508a841eea69da5f8e868ee20d785b16426212d4/openapi_python_client/templates/property_templates/union_property.py.jinja#L31
A link to your openapi.json which produces this issue.https://gist.github.com/diesieben07/267dd33e21a206ce4bc9a8906bba259e
🐞bugSomething isn't workinghttps://github.com/openapi-generators/openapi-python-client/issues?q=state%3Aopen%20label%3A%22%F0%9F%90%9Ebug%22
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.