Skip to content

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

@fridex

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}}

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