Skip to content

Ignores 'required' tag in model.mustache in python #3922

@vishalsanfran

Description

@vishalsanfran
Description

Swagger ignores 'required' tag in model.mustache in python.
The setter function for these properties does not allow null values, unlike ruby and other languages

Swagger-codegen version

2.2.1 (latest)

Steps to reproduce
  1. Required is false

"license":
{"type":"string","description":"license key", required: false}

Expected output:
@license.setter
def license(self, license):
self._license = license

  1. Required is true
    "license":
    {"type":"string","description":"license key", required: true}

Expected output:
@license.setter
def license(self, license):
if not license:
raise ValueError("Invalid value for license, must not be None")
self._license = license

Currently, output is always 2) whether 'required' is true or false

Suggest a Fix

Its a simple 2 line fix, very similar to the ruby code
i'll submit it

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions