Skip to content

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

Closed
@kmray

Description

@kmray

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    🐞bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions