Title: _get_kwargs does not produce correct payload when there are data and files present · Issue #508 · openapi-generators/openapi-python-client · GitHub
Open Graph Title: _get_kwargs does not produce correct payload when there are data and files present · Issue #508 · openapi-generators/openapi-python-client
X Title: _get_kwargs does not produce correct payload when there are data and files present · Issue #508 · openapi-generators/openapi-python-client
Description: Describe the bug When an API endpoint accepts data and files as a part of a multipart form data, the generated code puts the data fields (expected by httpx) into files, which leads to a TypeError in httpx when trying to encode the multip...
Open Graph Description: Describe the bug When an API endpoint accepts data and files as a part of a multipart form data, the generated code puts the data fields (expected by httpx) into files, which leads to a TypeError i...
X Description: Describe the bug When an API endpoint accepts data and files as a part of a multipart form data, the generated code puts the data fields (expected by httpx) into files, which leads to a TypeError i...
Opengraph URL: https://github.com/openapi-generators/openapi-python-client/issues/508
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"_get_kwargs does not produce correct payload when there are data and files present","articleBody":"**Describe the bug**\r\nWhen an API endpoint accepts data and files as a part of a multipart form data, the generated code puts the `data` fields (expected by `httpx`) into `files`, which leads to a `TypeError` in httpx when trying to encode the multipart form data.\r\n\r\n**To Reproduce**\r\nSteps to reproduce the behavior:\r\n1. Generate client\r\n2. Try to use the endpoint\r\n\r\n**Expected behavior**\r\nShould not encounter `TypeError` in `httpx`. More specifically, the `_get_kwargs()` function of the module for the endpoint needs to return an additional field, `data`, in addition to `files` for the plain text fields. That probably means `multipart_data.to_multipart()` should return both `data` and `files`. Currently, it only returns `files`.\r\n\r\n**OpenAPI Spec File**\r\nThe openapi.yaml is private, but I can do my best to produce a snippet that would reproduce the error. The actual endpoint shouldn't matter because the `TypeError` is encountered before sending any requests.\r\n\r\n```yaml\r\nopenapi: 3.0.1\r\ninfo:\r\n title: Rest API\r\n version: \"3\"\r\nservers:\r\n- url: /rest\r\nsecurity:\r\n- JwtAuth: []\r\n- ApiKeyAuth: []\r\npaths:\r\n /api/projects/{projectId}/depositFile:\r\n post:\r\n tags:\r\n - Deposit File\r\n summary: Deposit a file.\r\n operationId: depositFile\r\n parameters:\r\n - name: projectId\r\n in: path\r\n description: The ID of the project\r\n required: true\r\n schema:\r\n type: string\r\n requestBody:\r\n content:\r\n multipart/form-data:\r\n schema:\r\n $ref: '#/components/schemas/DepositFileDto'\r\n responses:\r\n \"201\":\r\n description: The file is deposited successfully.\r\n content:\r\n application/json: {}\r\ncomponents:\r\n schemas:\r\n DepositFileDto:\r\n required:\r\n - code\r\n - description\r\n - mainFile\r\n - parametersXmlFile\r\n type: object\r\n properties:\r\n code:\r\n maxLength: 255\r\n minLength: 1\r\n type: string\r\n description: The code of the file\r\n description:\r\n maxLength: 4000\r\n minLength: 1\r\n type: string\r\n description: The description of the file\r\n mainFile:\r\n type: string\r\n description: The main file.\r\n format: binary\r\n versionComment:\r\n type: string\r\n nullable: true\r\n```\r\n\r\n**Desktop (please complete the following information):**\r\n - OS: Windows 10\r\n - Python Version: 3.9.4\r\n - openapi-python-client version: 0.10.4\r\n","author":{"url":"https://github.com/skuo1-ilmn","@type":"Person","name":"skuo1-ilmn"},"datePublished":"2021-10-04T17:42:15.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":8},"url":"https://github.com/508/openapi-python-client/issues/508"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:029e8da6-7739-ec36-dc81-8d00e31b9bbb |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D840:E616D:1C8FA48:263C953:6981B69F |
| html-safe-nonce | b4437eaffa25386f4e2d9c9e719ec9339e71a65db74487fdda908f9eb16952fc |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEODQwOkU2MTZEOjFDOEZBNDg6MjYzQzk1Mzo2OTgxQjY5RiIsInZpc2l0b3JfaWQiOiI5MDk3NDQyNDAzNTA1MjU2MDk1IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 88dc0a162deaf2a4caea487a7c5f8145e830d39a25708e2fcf96948cab04b899 |
| hovercard-subject-tag | issue:1015451338 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/openapi-generators/openapi-python-client/508/issue_layout |
| twitter:image | https://opengraph.githubassets.com/684405a48a0944446d2499cd058f71c3cb3b7f060be282498695b66955202736/openapi-generators/openapi-python-client/issues/508 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/684405a48a0944446d2499cd058f71c3cb3b7f060be282498695b66955202736/openapi-generators/openapi-python-client/issues/508 |
| og:image:alt | Describe the bug When an API endpoint accepts data and files as a part of a multipart form data, the generated code puts the data fields (expected by httpx) into files, which leads to a TypeError i... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | skuo1-ilmn |
| hostname | github.com |
| expected-hostname | github.com |
| None | e137814e266030874fd2c86863529d0622b13889eeda04148c57654b6ea84ad6 |
| turbo-cache-control | no-preview |
| go-import | github.com/openapi-generators/openapi-python-client git https://github.com/openapi-generators/openapi-python-client.git |
| octolytics-dimension-user_id | 84925606 |
| octolytics-dimension-user_login | openapi-generators |
| octolytics-dimension-repository_id | 240776275 |
| octolytics-dimension-repository_nwo | openapi-generators/openapi-python-client |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 240776275 |
| octolytics-dimension-repository_network_root_nwo | openapi-generators/openapi-python-client |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | dd58d68a7813bbec9c91422c8c35f4af33832d70 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width