Title: Change
Open Graph Title: Change
X Title: Change
Description: Is your feature request related to a problem? Please describe. I want to be able to extend a model generated by this project in my business logic. A basic example would be: # GeneratedModel generated by openapi-python-client class Enhanc...
Open Graph Description: Is your feature request related to a problem? Please describe. I want to be able to extend a model generated by this project in my business logic. A basic example would be: # GeneratedModel generat...
X Description: Is your feature request related to a problem? Please describe. I want to be able to extend a model generated by this project in my business logic. A basic example would be: # GeneratedModel generat...
Opengraph URL: https://github.com/openapi-generators/openapi-python-client/issues/215
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Change \u003cModel\u003e.from_dict() to a @classmethod","articleBody":"**Is your feature request related to a problem? Please describe.**\r\nI want to be able to extend a model generated by this project in my business logic. A basic example would be:\r\n\r\n```python\r\n# GeneratedModel generated by openapi-python-client\r\n\r\nclass EnhancedGeneratedModel(GeneratedModel):\r\n def id_eq(self, other: GeneratedModel) -\u003e bool:\r\n return self.id == other.id\r\n```\r\n\r\nI cannot use `EnhancedGeneratedModel.from_dict` as that would return a `GeneratedModel`.\r\n\r\n\r\n\r\n**Describe the solution you'd like**\r\nUpdate the [`from_dict`](https://github.com/triaxtec/openapi-python-client/blob/196a8fc7c6c0abeb0b9b690a4cb9cbfed7fbe994/openapi_python_client/templates/model.pyi#L34) template in `openapi_python_client/templates/model.pyi` to be a `@classmethod` instead of a `@staticmethod` and use the passed class object to instantiate the model.\r\n\r\ni.e. change from\r\n```python\r\n@staticmethod\r\ndef from_dict(d: Dict[str, Any]) -\u003e \"{{ model.reference.class_name }}\":\r\n # ... \r\n return {{ model.reference.class_name }}(...)\r\n```\r\nto\r\n\r\n```python\r\n@classmethod\r\ndef from_dict(cls, d: Dict[str, Any]) -\u003e \"{{ model.reference.class_name }}\":\r\n # ... \r\n return cls(...)\r\n```\r\n\r\n**Describe alternatives you've considered**\r\nManually creating a `from_dict` method on the extended class.","author":{"url":"https://github.com/packyg","@type":"Person","name":"packyg"},"datePublished":"2020-10-13T21:34:45.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/215/openapi-python-client/issues/215"}
| 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:ec277c91-0718-0230-4453-b82cdfbe16d8 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8C34:53715:3ADAFF:4CF9ED:69800A36 |
| html-safe-nonce | 43a38c2784c64585dd02cef986e9e5064096319418ad064b3c8ed2cf7e4ea32b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4QzM0OjUzNzE1OjNBREFGRjo0Q0Y5RUQ6Njk4MDBBMzYiLCJ2aXNpdG9yX2lkIjoiNTgzMTMwMzIzMDEzMDIyNzc2NiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | ae0ac8f64a14dc0367b4c15a22159093d5f06657ce68689cedf4bf597fb4f40c |
| hovercard-subject-tag | issue:720869594 |
| 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/215/issue_layout |
| twitter:image | https://opengraph.githubassets.com/d6c2f0b2a0684e05034bf7ee330f107b6969557b81957f50b7423b8cc7e09a6a/openapi-generators/openapi-python-client/issues/215 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/d6c2f0b2a0684e05034bf7ee330f107b6969557b81957f50b7423b8cc7e09a6a/openapi-generators/openapi-python-client/issues/215 |
| og:image:alt | Is your feature request related to a problem? Please describe. I want to be able to extend a model generated by this project in my business logic. A basic example would be: # GeneratedModel generat... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | packyg |
| 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 | canary-2 |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width