Skip to content

[Python] Generated code does not respect nullable values #8710

Description

@fridex
Description

There is always generated following code which prevents from None (null) values:

        if requirements_lock is None:
            raise ValueError("Invalid value for `<attr_name>`, must not be `None`")  # noqa: E501

Unfortunately this check is generated even if the swagger definition explicitly says the given model attribute is nullable (by providing nullable: true).

Swagger-codegen version

The latest master to this date - master SHA 554d443.

Swagger declaration file content or url
Command line used for generation
java -jar swagger-codegen/modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate -i "${SWAGGER_YAML}" -l python
Steps to reproduce

Use any swagger definition and set nullable to true to any model attribute.

Related issues/PRs

None found.

Suggest a fix/enhancement

{{#required}}
if {{name}} is None:
raise ValueError("Invalid value for `{{name}}`, must not be `None`") # noqa: E501
{{/required}}

{{#required}}
if {{name}} is None:
raise ValueError("Invalid value for `{{name}}`, must not be `None`") # noqa: E501
{{/required}}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

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