Skip to content

Types named datetime cause conflict with Python's datetime #557

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
kmray opened this issue Dec 23, 2021 · 0 comments · Fixed by #558
Closed

Types named datetime cause conflict with Python's datetime #557

kmray opened this issue Dec 23, 2021 · 0 comments · Fixed by #558
Labels
🐞bug Something isn't working

Comments

@kmray
Copy link
Contributor

kmray commented Dec 23, 2021

Describe the bug
I am creating an OAS3 file from an existing API and one of the schemas includes a property named datetime which causes an Attribute exception when the generated model is imported.

To Reproduce
Steps to reproduce the behavior:

  1. Convert a OAS3 file that contains a property named datatime:
  2. Conversion succeeds with no errors or warnings
  3. When executing generated code that has the offending model imported, an AttributeError will be thrown with message:

'Unset' object has no attribute 'datetime'

Expected behavior
A typed named datetime should be renamed with an underscore suffix like other built-in types

OpenAPI Spec File

components:
  schemas:
    fubar:
      type: object
      properties:
        datetime:
          type: string
          format: date-time

Desktop (please complete the following information):

  • OS: macOS 12.1
  • Python Version: 3.9.6
  • openapi-python-client version 0.10.8

Additional context
This looks like a simple fix. I'll work on a PR.

@kmray kmray added the 🐞bug Something isn't working label Dec 23, 2021
dbanty pushed a commit that referenced this issue Jan 17, 2022
…e" [#557 & #558]. Thanks @kmray!

Co-authored-by: Dylan Anthony <[email protected]>

BREAKING CHANGE: `datetime` is now considered a reserved word anywhere, so any properties which were named `datetime` will now be named `datetime_`.
dbanty pushed a commit that referenced this issue Jan 17, 2022
…e" [#557 & #558]. Thanks @kmray!

Co-authored-by: Dylan Anthony <[email protected]>

BREAKING CHANGE: `datetime` is now considered a reserved word anywhere, so any properties which were named `datetime` will now be named `datetime_`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant