Skip to content

[Python] reserved keywords should include common types #7955

@gs11

Description

@gs11
Description

When a Swagger file includes fields named like common Python types (date, float etc), from_dict() will fail with:

TypeError: 'NoneType' object is not callable

Swagger-codegen version

2.3.1

Swagger declaration file content or url

https://gist.github.com/gs11/b314d66f10e1c795178b821cf46934e8

Command line used for generation

java -jar swagger-codegen-cli-2.3.1.jar generate -l python-flask -i swagger/petstore-minimal.yaml -o swagger

Steps to reproduce

In the controller, convert the Pet() object to a dict and then convert it back:

    pet = Pet()
    pet.id = 12345
    pet.name = "ACME pet"
    pet.tag = "generic"
    pet.date = "2018-04-02"
    pet.int = "test"
    pet.str = "test"
    pet.float = "test"
    pet.datetime = datetime.datetime.now()

    pet_as_dict = pet.to_dict()
    new_pet = Pet.from_dict(pet_as_dict)
Related issues/PRs

#6111

Suggest a fix/enhancement

Extend the lists with the following keywords:
float, int, str, date, datetime

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions