René's URL Explorer Experiment


Title: feat: Support responses with multiple media types in `content` by nkrishnaswami · Pull Request #1293 · openapi-generators/openapi-python-client · GitHub

Open Graph Title: feat: Support responses with multiple media types in `content` by nkrishnaswami · Pull Request #1293 · openapi-generators/openapi-python-client

X Title: feat: Support responses with multiple media types in `content` by nkrishnaswami · Pull Request #1293 · openapi-generators/openapi-python-client

Description: This PR modifies openapi-python-client to recognize multiple media types in OpenAPI response objects and to differentially parse HTTP responses based on their Content-Type header values. (Today, it generates code for a single content media type of the ones it encounters in the OpenAPI document.) This is useful eg for modeling services where a load balancer can send a 429 with plain text but the service behind it might send one with a schematized JSON response type. Feedback is welcome, especially on the overall approach. This PR adds unit tests and one end-to-end test, the latter of which includes sample generated code in the end_to_end_tests/multiple-media-types-golden-record/ subdirectory. To maintain backward compatibility and minimize impact on existing callers, unexpected response content types raise the existing UnexpectedStatus error, rather than introducing a new error class This uses exact string matching to compare returned content types with the media types from the schema. This offers only a subset of the available OpenAPI functionality: this PR does not provide support for wildcards, case insensitivity, or parameters. To add proper range matching (wildcard) support, we'd need something like the logic in python-mimeparse Uncovered diff lines: openapi_python_client/parser/openapi.py:204: This is a "belt-and-suspenders" check to avoid accessing an optional field if it is null. However, responses.py will not actually populate any MediaType instances with a null prop. for media_type in response.content: if not media_type.prop: # pragma: no cover continue endpoint.relative_imports |= media_type.prop.get_lazy_imports(prefix=models_relative_prefix) endpoint.relative_imports |= media_type.prop.get_imports(prefix=models_relative_prefix) endpoint.responses.append(response)

Open Graph Description: This PR modifies openapi-python-client to recognize multiple media types in OpenAPI response objects and to differentially parse HTTP responses based on their Content-Type header values. (Today, it...

X Description: This PR modifies openapi-python-client to recognize multiple media types in OpenAPI response objects and to differentially parse HTTP responses based on their Content-Type header values. (Today, it...

Opengraph URL: https://github.com/openapi-generators/openapi-python-client/pull/1293

X: @github

direct link

Domain: patch-diff.githubusercontent.com

route-pattern/:user_id/:repository/pull/:id/checks(.:format)
route-controllerpull_requests
route-actionchecks
fetch-noncev2:d10858f2-30ac-589b-1806-6910c7956e3c
current-catalog-service-hash87dc3bc62d9b466312751bfd5f889726f4f1337bdff4e8be7da7c93d6c00a25a
request-idC4D6:DBF78:37BE14B:4C3CB8D:6980B977
html-safe-nonce26e3fd56e847acdf9a6ce3db1f832ab522856d9351b4d7ad258e8b22b514aad4
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDNEQ2OkRCRjc4OjM3QkUxNEI6NEMzQ0I4RDo2OTgwQjk3NyIsInZpc2l0b3JfaWQiOiIzODgwMjYzNTYwODE4ODk5MzE5IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac792896501def60d51e4bda80ce3165867a119e11d1d02912b78c8bcdc8d5b99d
hovercard-subject-tagpull_request:2714138045
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,checks,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/checks
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/openapi-generators/openapi-python-client/pull/1293/checks
twitter:imagehttps://avatars.githubusercontent.com/u/5997156?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/5997156?s=400&v=4
og:image:altThis PR modifies openapi-python-client to recognize multiple media types in OpenAPI response objects and to differentially parse HTTP responses based on their Content-Type header values. (Today, it...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
Nonefb936832e40deb3175641d9cfedc8432372f91b0bc899576222953095fc7879e
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 full-width full-width-p-0
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releasead74180531de4861d5eee036a47b86c66a5b756e
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://patch-diff.githubusercontent.com/openapi-generators/openapi-python-client/pull/1293/checks#start-of-content
https://patch-diff.githubusercontent.com/
Sign in https://patch-diff.githubusercontent.com/login?return_to=https%3A%2F%2Fgithub.com%2Fopenapi-generators%2Fopenapi-python-client%2Fpull%2F1293%2Fchecks
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://patch-diff.githubusercontent.com/login?return_to=https%3A%2F%2Fgithub.com%2Fopenapi-generators%2Fopenapi-python-client%2Fpull%2F1293%2Fchecks
Sign up https://patch-diff.githubusercontent.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Fchecks&source=header-repo&source_repo=openapi-generators%2Fopenapi-python-client
Reloadhttps://patch-diff.githubusercontent.com/openapi-generators/openapi-python-client/pull/1293/checks
Reloadhttps://patch-diff.githubusercontent.com/openapi-generators/openapi-python-client/pull/1293/checks
Reloadhttps://patch-diff.githubusercontent.com/openapi-generators/openapi-python-client/pull/1293/checks
openapi-generators https://patch-diff.githubusercontent.com/openapi-generators
openapi-python-clienthttps://patch-diff.githubusercontent.com/openapi-generators/openapi-python-client
Please reload this pagehttps://patch-diff.githubusercontent.com/openapi-generators/openapi-python-client/pull/1293/checks
Notifications https://patch-diff.githubusercontent.com/login?return_to=%2Fopenapi-generators%2Fopenapi-python-client
Fork 264 https://patch-diff.githubusercontent.com/login?return_to=%2Fopenapi-generators%2Fopenapi-python-client
Star 1.9k https://patch-diff.githubusercontent.com/login?return_to=%2Fopenapi-generators%2Fopenapi-python-client
Code https://patch-diff.githubusercontent.com/openapi-generators/openapi-python-client
Issues 77 https://patch-diff.githubusercontent.com/openapi-generators/openapi-python-client/issues
Pull requests 14 https://patch-diff.githubusercontent.com/openapi-generators/openapi-python-client/pulls
Discussions https://patch-diff.githubusercontent.com/openapi-generators/openapi-python-client/discussions
Actions https://patch-diff.githubusercontent.com/openapi-generators/openapi-python-client/actions
Security 2 https://patch-diff.githubusercontent.com/openapi-generators/openapi-python-client/security
Insights https://patch-diff.githubusercontent.com/openapi-generators/openapi-python-client/pulse
Code https://patch-diff.githubusercontent.com/openapi-generators/openapi-python-client
Issues https://patch-diff.githubusercontent.com/openapi-generators/openapi-python-client/issues
Pull requests https://patch-diff.githubusercontent.com/openapi-generators/openapi-python-client/pulls
Discussions https://patch-diff.githubusercontent.com/openapi-generators/openapi-python-client/discussions
Actions https://patch-diff.githubusercontent.com/openapi-generators/openapi-python-client/actions
Security https://patch-diff.githubusercontent.com/openapi-generators/openapi-python-client/security
Insights https://patch-diff.githubusercontent.com/openapi-generators/openapi-python-client/pulse
Sign up for GitHub https://patch-diff.githubusercontent.com/signup?return_to=%2Fopenapi-generators%2Fopenapi-python-client%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://patch-diff.githubusercontent.com/login?return_to=%2Fopenapi-generators%2Fopenapi-python-client%2Fissues%2Fnew%2Fchoose
nkrishnaswamihttps://patch-diff.githubusercontent.com/nkrishnaswami
openapi-generators:mainhttps://patch-diff.githubusercontent.com/openapi-generators/openapi-python-client/tree/main
nkrishnaswami:multiple-media-typeshttps://patch-diff.githubusercontent.com/nkrishnaswami/openapi-python-client/tree/multiple-media-types
Conversation 1 https://patch-diff.githubusercontent.com/openapi-generators/openapi-python-client/pull/1293
Commits 5 https://patch-diff.githubusercontent.com/openapi-generators/openapi-python-client/pull/1293/commits
Checks 22 https://patch-diff.githubusercontent.com/openapi-generators/openapi-python-client/pull/1293/checks
Files changed https://patch-diff.githubusercontent.com/openapi-generators/openapi-python-client/pull/1293/files
Please reload this pagehttps://patch-diff.githubusercontent.com/openapi-generators/openapi-python-client/pull/1293/checks
Please reload this pagehttps://patch-diff.githubusercontent.com/openapi-generators/openapi-python-client/pull/1293/checks
feat: Support responses with multiple media types in content https://patch-diff.githubusercontent.com/openapi-generators/openapi-python-client/pull/1293/checks#top
Please reload this pagehttps://patch-diff.githubusercontent.com/openapi-generators/openapi-python-client/pull/1293/checks
Require changes to be documented https://patch-diff.githubusercontent.com/openapi-generators/openapi-python-client/pull/1293/checks?check_run_id=48319225557
Run Checks on: pull_request https://patch-diff.githubusercontent.com/openapi-generators/openapi-python-client/actions/runs/16946551276
test (3.9, ubuntu-latest) https://patch-diff.githubusercontent.com/openapi-generators/openapi-python-client/actions/runs/16946551276/job/48028871859?pr=1293
test (3.9, macos-latest) https://patch-diff.githubusercontent.com/openapi-generators/openapi-python-client/actions/runs/16946551276/job/48028871887?pr=1293
test (3.9, windows-latest) https://patch-diff.githubusercontent.com/openapi-generators/openapi-python-client/actions/runs/16946551276/job/48028871892?pr=1293
test (3.10, ubuntu-latest) https://patch-diff.githubusercontent.com/openapi-generators/openapi-python-client/actions/runs/16946551276/job/48028871893?pr=1293
test (3.10, macos-latest) https://patch-diff.githubusercontent.com/openapi-generators/openapi-python-client/actions/runs/16946551276/job/48028871929?pr=1293
test (3.10, windows-latest) https://patch-diff.githubusercontent.com/openapi-generators/openapi-python-client/actions/runs/16946551276/job/48028871952?pr=1293
test (3.11, ubuntu-latest) https://patch-diff.githubusercontent.com/openapi-generators/openapi-python-client/actions/runs/16946551276/job/48028871914?pr=1293
test (3.11, macos-latest) https://patch-diff.githubusercontent.com/openapi-generators/openapi-python-client/actions/runs/16946551276/job/48028872096?pr=1293
test (3.11, windows-latest) https://patch-diff.githubusercontent.com/openapi-generators/openapi-python-client/actions/runs/16946551276/job/48028871903?pr=1293
test (3.12, ubuntu-latest) https://patch-diff.githubusercontent.com/openapi-generators/openapi-python-client/actions/runs/16946551276/job/48028871991?pr=1293
test (3.12, macos-latest) https://patch-diff.githubusercontent.com/openapi-generators/openapi-python-client/actions/runs/16946551276/job/48028871931?pr=1293
test (3.12, windows-latest) https://patch-diff.githubusercontent.com/openapi-generators/openapi-python-client/actions/runs/16946551276/job/48028871949?pr=1293
test (3.13, ubuntu-latest) https://patch-diff.githubusercontent.com/openapi-generators/openapi-python-client/actions/runs/16946551276/job/48028871965?pr=1293
test (3.13, macos-latest) https://patch-diff.githubusercontent.com/openapi-generators/openapi-python-client/actions/runs/16946551276/job/48028871932?pr=1293
test (3.13, windows-latest) https://patch-diff.githubusercontent.com/openapi-generators/openapi-python-client/actions/runs/16946551276/job/48028871983?pr=1293
test_min_deps (ubuntu-latest) https://patch-diff.githubusercontent.com/openapi-generators/openapi-python-client/actions/runs/16946551276/job/48028871851?pr=1293
test_min_deps (macos-latest) https://patch-diff.githubusercontent.com/openapi-generators/openapi-python-client/actions/runs/16946551276/job/48028871843?pr=1293
test_min_deps (windows-latest) https://patch-diff.githubusercontent.com/openapi-generators/openapi-python-client/actions/runs/16946551276/job/48028871860?pr=1293
Integration Tests (pdm.lock) https://patch-diff.githubusercontent.com/openapi-generators/openapi-python-client/actions/runs/16946551276/job/48028871837?pr=1293
Integration Tests (pdm.minimal.lock) https://patch-diff.githubusercontent.com/openapi-generators/openapi-python-client/actions/runs/16946551276/job/48028871828?pr=1293
Combine & check coverage https://patch-diff.githubusercontent.com/openapi-generators/openapi-python-client/actions/runs/16946551276/job/48029036246?pr=1293
create more change fileshttps://knope.tech/reference/concepts/changeset/
View more details on Knope Bot https://knope.tech
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.