[python-nextgen] re-generate exapmles for #14809

This commit is contained in:
Tomas Karasek 2023-03-16 13:40:06 +01:00
parent aed041ac67
commit e39d2cea9f
17 changed files with 35 additions and 54 deletions

View File

@ -42,9 +42,9 @@ class DefaultValue(BaseModel):
def array_string_enum_default_validate_enum(cls, v): def array_string_enum_default_validate_enum(cls, v):
if v is None: if v is None:
return v return v
for i in v:
if v not in ('success', 'failure', 'unclassified'): if i not in ('success', 'failure', 'unclassified'):
raise ValueError("must validate the enum values ('success', 'failure', 'unclassified')") raise ValueError("each list item must be one of ('success', 'failure', 'unclassified')")
return v return v
class Config: class Config:

View File

@ -41,9 +41,8 @@ class Pet(BaseModel):
def status_validate_enum(cls, v): def status_validate_enum(cls, v):
if v is None: if v is None:
return v return v
if v not in ('available', 'pending', 'sold'): if v not in ('available', 'pending', 'sold'):
raise ValueError("must validate the enum values ('available', 'pending', 'sold')") raise ValueError("must be one of enum values ('available', 'pending', 'sold')")
return v return v
class Config: class Config:

View File

@ -35,9 +35,9 @@ class Query(BaseModel):
def outcomes_validate_enum(cls, v): def outcomes_validate_enum(cls, v):
if v is None: if v is None:
return v return v
for i in v:
if v not in ('SUCCESS', 'FAILURE', 'SKIPPED'): if i not in ('SUCCESS', 'FAILURE', 'SKIPPED'):
raise ValueError("must validate the enum values ('SUCCESS', 'FAILURE', 'SKIPPED')") raise ValueError("each list item must be one of ('SUCCESS', 'FAILURE', 'SKIPPED')")
return v return v
class Config: class Config:

View File

@ -34,18 +34,17 @@ class EnumArrays(BaseModel):
def just_symbol_validate_enum(cls, v): def just_symbol_validate_enum(cls, v):
if v is None: if v is None:
return v return v
if v not in ('>=', '$'): if v not in ('>=', '$'):
raise ValueError("must validate the enum values ('>=', '$')") raise ValueError("must be one of enum values ('>=', '$')")
return v return v
@validator('array_enum') @validator('array_enum')
def array_enum_validate_enum(cls, v): def array_enum_validate_enum(cls, v):
if v is None: if v is None:
return v return v
for i in v:
if v not in ('fish', 'crab'): if i not in ('fish', 'crab'):
raise ValueError("must validate the enum values ('fish', 'crab')") raise ValueError("each list item must be one of ('fish', 'crab')")
return v return v
class Config: class Config:

View File

@ -45,42 +45,38 @@ class EnumTest(BaseModel):
def enum_string_validate_enum(cls, v): def enum_string_validate_enum(cls, v):
if v is None: if v is None:
return v return v
if v not in ('UPPER', 'lower', ''): if v not in ('UPPER', 'lower', ''):
raise ValueError("must validate the enum values ('UPPER', 'lower', '')") raise ValueError("must be one of enum values ('UPPER', 'lower', '')")
return v return v
@validator('enum_string_required') @validator('enum_string_required')
def enum_string_required_validate_enum(cls, v): def enum_string_required_validate_enum(cls, v):
if v not in ('UPPER', 'lower', ''): if v not in ('UPPER', 'lower', ''):
raise ValueError("must validate the enum values ('UPPER', 'lower', '')") raise ValueError("must be one of enum values ('UPPER', 'lower', '')")
return v return v
@validator('enum_integer_default') @validator('enum_integer_default')
def enum_integer_default_validate_enum(cls, v): def enum_integer_default_validate_enum(cls, v):
if v is None: if v is None:
return v return v
if v not in (1, 5, 14): if v not in (1, 5, 14):
raise ValueError("must validate the enum values (1, 5, 14)") raise ValueError("must be one of enum values (1, 5, 14)")
return v return v
@validator('enum_integer') @validator('enum_integer')
def enum_integer_validate_enum(cls, v): def enum_integer_validate_enum(cls, v):
if v is None: if v is None:
return v return v
if v not in (1, -1): if v not in (1, -1):
raise ValueError("must validate the enum values (1, -1)") raise ValueError("must be one of enum values (1, -1)")
return v return v
@validator('enum_number') @validator('enum_number')
def enum_number_validate_enum(cls, v): def enum_number_validate_enum(cls, v):
if v is None: if v is None:
return v return v
if v not in (1.1, -1.2): if v not in (1.1, -1.2):
raise ValueError("must validate the enum values (1.1, -1.2)") raise ValueError("must be one of enum values (1.1, -1.2)")
return v return v
class Config: class Config:

View File

@ -36,9 +36,8 @@ class MapTest(BaseModel):
def map_of_enum_string_validate_enum(cls, v): def map_of_enum_string_validate_enum(cls, v):
if v is None: if v is None:
return v return v
if v not in ('UPPER', 'lower'): if v not in ('UPPER', 'lower'):
raise ValueError("must validate the enum values ('UPPER', 'lower')") raise ValueError("must be one of enum values ('UPPER', 'lower')")
return v return v
class Config: class Config:

View File

@ -38,9 +38,8 @@ class Order(BaseModel):
def status_validate_enum(cls, v): def status_validate_enum(cls, v):
if v is None: if v is None:
return v return v
if v not in ('placed', 'approved', 'delivered'): if v not in ('placed', 'approved', 'delivered'):
raise ValueError("must validate the enum values ('placed', 'approved', 'delivered')") raise ValueError("must be one of enum values ('placed', 'approved', 'delivered')")
return v return v
class Config: class Config:

View File

@ -40,9 +40,8 @@ class Pet(BaseModel):
def status_validate_enum(cls, v): def status_validate_enum(cls, v):
if v is None: if v is None:
return v return v
if v not in ('available', 'pending', 'sold'): if v not in ('available', 'pending', 'sold'):
raise ValueError("must validate the enum values ('available', 'pending', 'sold')") raise ValueError("must be one of enum values ('available', 'pending', 'sold')")
return v return v
class Config: class Config:

View File

@ -36,9 +36,8 @@ class SpecialName(BaseModel):
def var_schema_validate_enum(cls, v): def var_schema_validate_enum(cls, v):
if v is None: if v is None:
return v return v
if v not in ('available', 'pending', 'sold'): if v not in ('available', 'pending', 'sold'):
raise ValueError("must validate the enum values ('available', 'pending', 'sold')") raise ValueError("must be one of enum values ('available', 'pending', 'sold')")
return v return v
class Config: class Config:

View File

@ -235,4 +235,4 @@ class ModelTests(unittest.TestCase):
self.pet.status = "error" self.pet.status = "error"
self.assertTrue(False) # this line shouldn't execute self.assertTrue(False) # this line shouldn't execute
except ValueError as e: except ValueError as e:
self.assertTrue("must validate the enum values ('available', 'pending', 'sold')" in str(e)) self.assertTrue("must be one of enum values ('available', 'pending', 'sold')" in str(e))

View File

@ -35,18 +35,17 @@ class EnumArrays(BaseModel):
def just_symbol_validate_enum(cls, v): def just_symbol_validate_enum(cls, v):
if v is None: if v is None:
return v return v
if v not in ('>=', '$'): if v not in ('>=', '$'):
raise ValueError("must validate the enum values ('>=', '$')") raise ValueError("must be one of enum values ('>=', '$')")
return v return v
@validator('array_enum') @validator('array_enum')
def array_enum_validate_enum(cls, v): def array_enum_validate_enum(cls, v):
if v is None: if v is None:
return v return v
for i in v:
if v not in ('fish', 'crab'): if i not in ('fish', 'crab'):
raise ValueError("must validate the enum values ('fish', 'crab')") raise ValueError("each list item must be one of ('fish', 'crab')")
return v return v
class Config: class Config:

View File

@ -46,42 +46,38 @@ class EnumTest(BaseModel):
def enum_string_validate_enum(cls, v): def enum_string_validate_enum(cls, v):
if v is None: if v is None:
return v return v
if v not in ('UPPER', 'lower', ''): if v not in ('UPPER', 'lower', ''):
raise ValueError("must validate the enum values ('UPPER', 'lower', '')") raise ValueError("must be one of enum values ('UPPER', 'lower', '')")
return v return v
@validator('enum_string_required') @validator('enum_string_required')
def enum_string_required_validate_enum(cls, v): def enum_string_required_validate_enum(cls, v):
if v not in ('UPPER', 'lower', ''): if v not in ('UPPER', 'lower', ''):
raise ValueError("must validate the enum values ('UPPER', 'lower', '')") raise ValueError("must be one of enum values ('UPPER', 'lower', '')")
return v return v
@validator('enum_integer_default') @validator('enum_integer_default')
def enum_integer_default_validate_enum(cls, v): def enum_integer_default_validate_enum(cls, v):
if v is None: if v is None:
return v return v
if v not in (1, 5, 14): if v not in (1, 5, 14):
raise ValueError("must validate the enum values (1, 5, 14)") raise ValueError("must be one of enum values (1, 5, 14)")
return v return v
@validator('enum_integer') @validator('enum_integer')
def enum_integer_validate_enum(cls, v): def enum_integer_validate_enum(cls, v):
if v is None: if v is None:
return v return v
if v not in (1, -1): if v not in (1, -1):
raise ValueError("must validate the enum values (1, -1)") raise ValueError("must be one of enum values (1, -1)")
return v return v
@validator('enum_number') @validator('enum_number')
def enum_number_validate_enum(cls, v): def enum_number_validate_enum(cls, v):
if v is None: if v is None:
return v return v
if v not in (1.1, -1.2): if v not in (1.1, -1.2):
raise ValueError("must validate the enum values (1.1, -1.2)") raise ValueError("must be one of enum values (1.1, -1.2)")
return v return v
class Config: class Config:

View File

@ -37,9 +37,8 @@ class MapTest(BaseModel):
def map_of_enum_string_validate_enum(cls, v): def map_of_enum_string_validate_enum(cls, v):
if v is None: if v is None:
return v return v
if v not in ('UPPER', 'lower'): if v not in ('UPPER', 'lower'):
raise ValueError("must validate the enum values ('UPPER', 'lower')") raise ValueError("must be one of enum values ('UPPER', 'lower')")
return v return v
class Config: class Config:

View File

@ -39,9 +39,8 @@ class Order(BaseModel):
def status_validate_enum(cls, v): def status_validate_enum(cls, v):
if v is None: if v is None:
return v return v
if v not in ('placed', 'approved', 'delivered'): if v not in ('placed', 'approved', 'delivered'):
raise ValueError("must validate the enum values ('placed', 'approved', 'delivered')") raise ValueError("must be one of enum values ('placed', 'approved', 'delivered')")
return v return v
class Config: class Config:

View File

@ -41,9 +41,8 @@ class Pet(BaseModel):
def status_validate_enum(cls, v): def status_validate_enum(cls, v):
if v is None: if v is None:
return v return v
if v not in ('available', 'pending', 'sold'): if v not in ('available', 'pending', 'sold'):
raise ValueError("must validate the enum values ('available', 'pending', 'sold')") raise ValueError("must be one of enum values ('available', 'pending', 'sold')")
return v return v
class Config: class Config:

View File

@ -37,9 +37,8 @@ class SpecialName(BaseModel):
def var_schema_validate_enum(cls, v): def var_schema_validate_enum(cls, v):
if v is None: if v is None:
return v return v
if v not in ('available', 'pending', 'sold'): if v not in ('available', 'pending', 'sold'):
raise ValueError("must validate the enum values ('available', 'pending', 'sold')") raise ValueError("must be one of enum values ('available', 'pending', 'sold')")
return v return v
class Config: class Config:

View File

@ -319,7 +319,7 @@ class ModelTests(unittest.TestCase):
self.pet.status = "error" self.pet.status = "error"
self.assertTrue(False) # this line shouldn't execute self.assertTrue(False) # this line shouldn't execute
except ValueError as e: except ValueError as e:
self.assertTrue("must validate the enum values ('available', 'pending', 'sold')" in str(e)) self.assertTrue("must be one of enum values ('available', 'pending', 'sold')" in str(e))
def test_object_id(self): def test_object_id(self):
pet_ap = petstore_api.Pet(name="test name", photo_urls=["string"]) pet_ap = petstore_api.Pet(name="test name", photo_urls=["string"])