Title: Represent empty responses as None · Issue #770 · openapi-generators/openapi-python-client · GitHub
Open Graph Title: Represent empty responses as None · Issue #770 · openapi-generators/openapi-python-client
X Title: Represent empty responses as None · Issue #770 · openapi-generators/openapi-python-client
Description: When I specify no content for a response, I would expect to generate a sync method and async method that returns None. Currently, I work against an api that has a few endpoints returning no data (that could be with status code 200 or sta...
Open Graph Description: When I specify no content for a response, I would expect to generate a sync method and async method that returns None. Currently, I work against an api that has a few endpoints returning no data (t...
X Description: When I specify no content for a response, I would expect to generate a sync method and async method that returns None. Currently, I work against an api that has a few endpoints returning no data (t...
Opengraph URL: https://github.com/openapi-generators/openapi-python-client/issues/770
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Represent empty responses as None","articleBody":"When I specify no content for a response, I would expect to generate a `sync` method and `async` method that returns `None`.\r\n\r\nCurrently, I work against an api that has a few endpoints returning no data (that could be with status code 200 or status code 204).\r\nExample:\r\n```\r\n \"/something\" : {\r\n \"patch\" : {\r\n ...\r\n \"responses\" : {\r\n \"200\" : {\r\n \"description\" : \"something\"\r\n }\r\n }\r\n }\r\n }\r\n```\r\n\r\nWhen I generate a client with this project, this endpoint will not have a `sync` or `async` method, but only the `sync_detailed` and `async_detailed`. This works, but it looks weird because for all other methods I use `sync/async`. I would be great to have them implemented to return None (like a void/unit method in python).\r\n\r\nI think, the problem manifests here: https://github.com/openapi-generators/openapi-python-client/blob/4823d96c4a85ce797bc6df529b6080f38f7390ce/openapi_python_client/templates/endpoint_module.py.jinja#L18\r\n\r\nThe sync method is only generated if the return type is not any - which makes sense. But I think, the return type here is not actually `Any` - but None. The response type comes from here: https://github.com/openapi-generators/openapi-python-client/blob/4823d96c4a85ce797bc6df529b6080f38f7390ce/openapi_python_client/parser/openapi.py#L525\r\n\r\nHere is a link with documentation on handling empty responses and any type: https://swagger.io/docs/specification/data-models/data-types/\r\n\r\nAccording to that, the difference is having either no `content` field for empty responses and having a `content` field defined with an empty object for any type.","author":{"url":"https://github.com/cornerman","@type":"Person","name":"cornerman"},"datePublished":"2023-06-04T19:37:33.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/770/openapi-python-client/issues/770"}
| 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:d482ef39-3c9c-9067-cc8f-60d58e8bdfc1 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9F74:25AFF0:81D33D:A5F18B:697F9CA1 |
| html-safe-nonce | 8035696c7ed7f94c5dab9d37455b16cc32e8099c17cbba69992c64ab0608c60e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5Rjc0OjI1QUZGMDo4MUQzM0Q6QTVGMThCOjY5N0Y5Q0ExIiwidmlzaXRvcl9pZCI6IjU2NzY3ODA3MzkyOTU2ODE2OTciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 45e72e8242e35a4b7b705f39337579e20b656e54128345021c6be58e12bdf0a2 |
| hovercard-subject-tag | issue:1740548508 |
| 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/770/issue_layout |
| twitter:image | https://opengraph.githubassets.com/1bbed8aed89001253f39897de8144711140a5d4894269ef61cfac1740c1ff3bf/openapi-generators/openapi-python-client/issues/770 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/1bbed8aed89001253f39897de8144711140a5d4894269ef61cfac1740c1ff3bf/openapi-generators/openapi-python-client/issues/770 |
| og:image:alt | When I specify no content for a response, I would expect to generate a sync method and async method that returns None. Currently, I work against an api that has a few endpoints returning no data (t... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | cornerman |
| hostname | github.com |
| expected-hostname | github.com |
| None | 60279d4097367e16897439d16d6bbe4180663db828c666eeed2656988ffe59f6 |
| 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 | 7c85641c598ad130c74f7bcc27f58575cac69551 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width