diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonNextgenClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonNextgenClientCodegen.java index 9988ddba425..3f981f5b08b 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonNextgenClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonNextgenClientCodegen.java @@ -1289,6 +1289,12 @@ public class PythonNextgenClientCodegen extends AbstractPythonCodegen implements fieldCustomization = String.format(Locale.ROOT, "Field(%s)", StringUtils.join(fields, ", ")); } + if ("...".equals(fieldCustomization)) { + // use Field() to avoid pylint warnings + pydanticImports.add("Field"); + fieldCustomization = "Field(...)"; + } + cp.vendorExtensions.put("x-py-typing", typing + " = " + fieldCustomization); // setup x-py-name for each oneOf/anyOf schema diff --git a/samples/client/echo_api/python-nextgen/openapi_client/models/pet.py b/samples/client/echo_api/python-nextgen/openapi_client/models/pet.py index 383e8691b35..1d41038d83a 100644 --- a/samples/client/echo_api/python-nextgen/openapi_client/models/pet.py +++ b/samples/client/echo_api/python-nextgen/openapi_client/models/pet.py @@ -30,7 +30,7 @@ class Pet(BaseModel): Pet """ id: Optional[StrictInt] = None - name: StrictStr = ... + name: StrictStr = Field(...) category: Optional[Category] = None photo_urls: conlist(StrictStr) = Field(..., alias="photoUrls") tags: Optional[conlist(Tag)] = None diff --git a/samples/openapi3/client/petstore/python-nextgen-aiohttp/petstore_api/models/basque_pig.py b/samples/openapi3/client/petstore/python-nextgen-aiohttp/petstore_api/models/basque_pig.py index 7a9bc1624e2..2c9210a9fa1 100644 --- a/samples/openapi3/client/petstore/python-nextgen-aiohttp/petstore_api/models/basque_pig.py +++ b/samples/openapi3/client/petstore/python-nextgen-aiohttp/petstore_api/models/basque_pig.py @@ -27,7 +27,7 @@ class BasquePig(BaseModel): BasquePig """ class_name: StrictStr = Field(..., alias="className") - color: StrictStr = ... + color: StrictStr = Field(...) __properties = ["className", "color"] class Config: diff --git a/samples/openapi3/client/petstore/python-nextgen-aiohttp/petstore_api/models/category.py b/samples/openapi3/client/petstore/python-nextgen-aiohttp/petstore_api/models/category.py index e738609efd5..311634b1081 100644 --- a/samples/openapi3/client/petstore/python-nextgen-aiohttp/petstore_api/models/category.py +++ b/samples/openapi3/client/petstore/python-nextgen-aiohttp/petstore_api/models/category.py @@ -20,14 +20,14 @@ import json from typing import Optional -from pydantic import BaseModel, StrictInt, StrictStr +from pydantic import BaseModel, Field, StrictInt, StrictStr class Category(BaseModel): """ Category """ id: Optional[StrictInt] = None - name: StrictStr = ... + name: StrictStr = Field(...) __properties = ["id", "name"] class Config: diff --git a/samples/openapi3/client/petstore/python-nextgen-aiohttp/petstore_api/models/danish_pig.py b/samples/openapi3/client/petstore/python-nextgen-aiohttp/petstore_api/models/danish_pig.py index 1e79f3db26e..9a45a77b607 100644 --- a/samples/openapi3/client/petstore/python-nextgen-aiohttp/petstore_api/models/danish_pig.py +++ b/samples/openapi3/client/petstore/python-nextgen-aiohttp/petstore_api/models/danish_pig.py @@ -27,7 +27,7 @@ class DanishPig(BaseModel): DanishPig """ class_name: StrictStr = Field(..., alias="className") - size: StrictInt = ... + size: StrictInt = Field(...) __properties = ["className", "size"] class Config: diff --git a/samples/openapi3/client/petstore/python-nextgen-aiohttp/petstore_api/models/enum_test.py b/samples/openapi3/client/petstore/python-nextgen-aiohttp/petstore_api/models/enum_test.py index aa8fd784f08..2f62f6d76e5 100644 --- a/samples/openapi3/client/petstore/python-nextgen-aiohttp/petstore_api/models/enum_test.py +++ b/samples/openapi3/client/petstore/python-nextgen-aiohttp/petstore_api/models/enum_test.py @@ -31,7 +31,7 @@ class EnumTest(BaseModel): EnumTest """ enum_string: Optional[StrictStr] = None - enum_string_required: StrictStr = ... + enum_string_required: StrictStr = Field(...) enum_integer_default: Optional[StrictInt] = 5 enum_integer: Optional[StrictInt] = None enum_number: Optional[float] = None diff --git a/samples/openapi3/client/petstore/python-nextgen-aiohttp/petstore_api/models/format_test.py b/samples/openapi3/client/petstore/python-nextgen-aiohttp/petstore_api/models/format_test.py index f961ba92fe4..ce02674ff3b 100644 --- a/samples/openapi3/client/petstore/python-nextgen-aiohttp/petstore_api/models/format_test.py +++ b/samples/openapi3/client/petstore/python-nextgen-aiohttp/petstore_api/models/format_test.py @@ -29,7 +29,7 @@ class FormatTest(BaseModel): integer: Optional[conint(strict=True, le=100, ge=10)] = None int32: Optional[conint(strict=True, le=200, ge=20)] = None int64: Optional[StrictInt] = None - number: confloat(le=543.2, ge=32.1) = ... + number: confloat(le=543.2, ge=32.1) = Field(...) float: Optional[confloat(le=987.6, ge=54.3)] = None double: Optional[confloat(le=123.4, ge=67.8)] = None decimal: Optional[condecimal()] = None @@ -40,7 +40,7 @@ class FormatTest(BaseModel): var_date: date = Field(..., alias="date") date_time: Optional[datetime] = Field(None, alias="dateTime") uuid: Optional[StrictStr] = None - password: constr(strict=True, max_length=64, min_length=10) = ... + password: constr(strict=True, max_length=64, min_length=10) = Field(...) pattern_with_digits: Optional[constr(strict=True)] = Field(None, description="A string that is a 10 digit number. Can have leading zeros.") pattern_with_digits_and_delimiter: Optional[constr(strict=True)] = Field(None, description="A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01.") __properties = ["integer", "int32", "int64", "number", "float", "double", "decimal", "string", "string_with_double_quote_pattern", "byte", "binary", "date", "dateTime", "uuid", "password", "pattern_with_digits", "pattern_with_digits_and_delimiter"] diff --git a/samples/openapi3/client/petstore/python-nextgen-aiohttp/petstore_api/models/name.py b/samples/openapi3/client/petstore/python-nextgen-aiohttp/petstore_api/models/name.py index 2bd141055bb..bf9ab74413b 100644 --- a/samples/openapi3/client/petstore/python-nextgen-aiohttp/petstore_api/models/name.py +++ b/samples/openapi3/client/petstore/python-nextgen-aiohttp/petstore_api/models/name.py @@ -26,7 +26,7 @@ class Name(BaseModel): """ Model for testing model name same as property name """ - name: StrictInt = ... + name: StrictInt = Field(...) snake_case: Optional[StrictInt] = None var_property: Optional[StrictStr] = Field(None, alias="property") var_123_number: Optional[StrictInt] = Field(None, alias="123Number") diff --git a/samples/openapi3/client/petstore/python-nextgen-aiohttp/petstore_api/models/nullable_class.py b/samples/openapi3/client/petstore/python-nextgen-aiohttp/petstore_api/models/nullable_class.py index 32d313365d6..969acaeca05 100644 --- a/samples/openapi3/client/petstore/python-nextgen-aiohttp/petstore_api/models/nullable_class.py +++ b/samples/openapi3/client/petstore/python-nextgen-aiohttp/petstore_api/models/nullable_class.py @@ -20,13 +20,13 @@ import json from datetime import date, datetime from typing import Any, Dict, List, Optional -from pydantic import BaseModel, StrictBool, StrictInt, StrictStr, conlist +from pydantic import BaseModel, Field, StrictBool, StrictInt, StrictStr, conlist class NullableClass(BaseModel): """ NullableClass """ - required_integer_prop: Optional[StrictInt] = ... + required_integer_prop: Optional[StrictInt] = Field(...) integer_prop: Optional[StrictInt] = None number_prop: Optional[float] = None boolean_prop: Optional[StrictBool] = None diff --git a/samples/openapi3/client/petstore/python-nextgen-aiohttp/petstore_api/models/outer_object_with_enum_property.py b/samples/openapi3/client/petstore/python-nextgen-aiohttp/petstore_api/models/outer_object_with_enum_property.py index db3e40fb412..78ea1841d7b 100644 --- a/samples/openapi3/client/petstore/python-nextgen-aiohttp/petstore_api/models/outer_object_with_enum_property.py +++ b/samples/openapi3/client/petstore/python-nextgen-aiohttp/petstore_api/models/outer_object_with_enum_property.py @@ -20,7 +20,7 @@ import json from typing import Optional -from pydantic import BaseModel +from pydantic import BaseModel, Field from petstore_api.models.outer_enum import OuterEnum from petstore_api.models.outer_enum_integer import OuterEnumInteger @@ -29,7 +29,7 @@ class OuterObjectWithEnumProperty(BaseModel): OuterObjectWithEnumProperty """ str_value: Optional[OuterEnum] = None - value: OuterEnumInteger = ... + value: OuterEnumInteger = Field(...) __properties = ["str_value", "value"] class Config: diff --git a/samples/openapi3/client/petstore/python-nextgen-aiohttp/petstore_api/models/pet.py b/samples/openapi3/client/petstore/python-nextgen-aiohttp/petstore_api/models/pet.py index edaed4375f9..af7b3e37fdc 100644 --- a/samples/openapi3/client/petstore/python-nextgen-aiohttp/petstore_api/models/pet.py +++ b/samples/openapi3/client/petstore/python-nextgen-aiohttp/petstore_api/models/pet.py @@ -30,7 +30,7 @@ class Pet(BaseModel): """ id: Optional[StrictInt] = None category: Optional[Category] = None - name: StrictStr = ... + name: StrictStr = Field(...) photo_urls: conlist(StrictStr, min_items=0, unique_items=True) = Field(..., alias="photoUrls") tags: Optional[conlist(Tag)] = None status: Optional[StrictStr] = Field(None, description="pet status in the store") diff --git a/samples/openapi3/client/petstore/python-nextgen/petstore_api/models/basque_pig.py b/samples/openapi3/client/petstore/python-nextgen/petstore_api/models/basque_pig.py index 48ac4d818b7..cc775a10e26 100644 --- a/samples/openapi3/client/petstore/python-nextgen/petstore_api/models/basque_pig.py +++ b/samples/openapi3/client/petstore/python-nextgen/petstore_api/models/basque_pig.py @@ -27,7 +27,7 @@ class BasquePig(BaseModel): BasquePig """ class_name: StrictStr = Field(..., alias="className") - color: StrictStr = ... + color: StrictStr = Field(...) additional_properties: Dict[str, Any] = {} __properties = ["className", "color"] diff --git a/samples/openapi3/client/petstore/python-nextgen/petstore_api/models/category.py b/samples/openapi3/client/petstore/python-nextgen/petstore_api/models/category.py index 65579839f32..d1cfde84d0f 100644 --- a/samples/openapi3/client/petstore/python-nextgen/petstore_api/models/category.py +++ b/samples/openapi3/client/petstore/python-nextgen/petstore_api/models/category.py @@ -20,14 +20,14 @@ import json from typing import Optional -from pydantic import BaseModel, StrictInt, StrictStr +from pydantic import BaseModel, Field, StrictInt, StrictStr class Category(BaseModel): """ Category """ id: Optional[StrictInt] = None - name: StrictStr = ... + name: StrictStr = Field(...) additional_properties: Dict[str, Any] = {} __properties = ["id", "name"] diff --git a/samples/openapi3/client/petstore/python-nextgen/petstore_api/models/danish_pig.py b/samples/openapi3/client/petstore/python-nextgen/petstore_api/models/danish_pig.py index 93e6105b2b2..88cf28e3b67 100644 --- a/samples/openapi3/client/petstore/python-nextgen/petstore_api/models/danish_pig.py +++ b/samples/openapi3/client/petstore/python-nextgen/petstore_api/models/danish_pig.py @@ -27,7 +27,7 @@ class DanishPig(BaseModel): DanishPig """ class_name: StrictStr = Field(..., alias="className") - size: StrictInt = ... + size: StrictInt = Field(...) additional_properties: Dict[str, Any] = {} __properties = ["className", "size"] diff --git a/samples/openapi3/client/petstore/python-nextgen/petstore_api/models/enum_test.py b/samples/openapi3/client/petstore/python-nextgen/petstore_api/models/enum_test.py index ac1490a8a7d..6da81fb921e 100644 --- a/samples/openapi3/client/petstore/python-nextgen/petstore_api/models/enum_test.py +++ b/samples/openapi3/client/petstore/python-nextgen/petstore_api/models/enum_test.py @@ -31,7 +31,7 @@ class EnumTest(BaseModel): EnumTest """ enum_string: Optional[StrictStr] = None - enum_string_required: StrictStr = ... + enum_string_required: StrictStr = Field(...) enum_integer_default: Optional[StrictInt] = 5 enum_integer: Optional[StrictInt] = None enum_number: Optional[StrictFloat] = None diff --git a/samples/openapi3/client/petstore/python-nextgen/petstore_api/models/format_test.py b/samples/openapi3/client/petstore/python-nextgen/petstore_api/models/format_test.py index a543c85c81a..f2718790a0b 100644 --- a/samples/openapi3/client/petstore/python-nextgen/petstore_api/models/format_test.py +++ b/samples/openapi3/client/petstore/python-nextgen/petstore_api/models/format_test.py @@ -29,7 +29,7 @@ class FormatTest(BaseModel): integer: Optional[conint(strict=True, le=100, ge=10)] = None int32: Optional[conint(strict=True, le=200, ge=20)] = None int64: Optional[StrictInt] = None - number: confloat(le=543.2, ge=32.1, strict=True) = ... + number: confloat(le=543.2, ge=32.1, strict=True) = Field(...) float: Optional[confloat(le=987.6, ge=54.3, strict=True)] = None double: Optional[confloat(le=123.4, ge=67.8, strict=True)] = None decimal: Optional[condecimal()] = None @@ -40,7 +40,7 @@ class FormatTest(BaseModel): var_date: date = Field(..., alias="date") date_time: Optional[datetime] = Field(None, alias="dateTime") uuid: Optional[StrictStr] = None - password: constr(strict=True, max_length=64, min_length=10) = ... + password: constr(strict=True, max_length=64, min_length=10) = Field(...) pattern_with_digits: Optional[constr(strict=True)] = Field(None, description="A string that is a 10 digit number. Can have leading zeros.") pattern_with_digits_and_delimiter: Optional[constr(strict=True)] = Field(None, description="A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01.") additional_properties: Dict[str, Any] = {} diff --git a/samples/openapi3/client/petstore/python-nextgen/petstore_api/models/name.py b/samples/openapi3/client/petstore/python-nextgen/petstore_api/models/name.py index 08ad6361c5e..b17307dc3a3 100644 --- a/samples/openapi3/client/petstore/python-nextgen/petstore_api/models/name.py +++ b/samples/openapi3/client/petstore/python-nextgen/petstore_api/models/name.py @@ -26,7 +26,7 @@ class Name(BaseModel): """ Model for testing model name same as property name """ - name: StrictInt = ... + name: StrictInt = Field(...) snake_case: Optional[StrictInt] = None var_property: Optional[StrictStr] = Field(None, alias="property") var_123_number: Optional[StrictInt] = Field(None, alias="123Number") diff --git a/samples/openapi3/client/petstore/python-nextgen/petstore_api/models/nullable_class.py b/samples/openapi3/client/petstore/python-nextgen/petstore_api/models/nullable_class.py index 6c77bc263fa..f29c76b594d 100644 --- a/samples/openapi3/client/petstore/python-nextgen/petstore_api/models/nullable_class.py +++ b/samples/openapi3/client/petstore/python-nextgen/petstore_api/models/nullable_class.py @@ -20,13 +20,13 @@ import json from datetime import date, datetime from typing import Any, Dict, List, Optional -from pydantic import BaseModel, StrictBool, StrictFloat, StrictInt, StrictStr, conlist +from pydantic import BaseModel, Field, StrictBool, StrictFloat, StrictInt, StrictStr, conlist class NullableClass(BaseModel): """ NullableClass """ - required_integer_prop: Optional[StrictInt] = ... + required_integer_prop: Optional[StrictInt] = Field(...) integer_prop: Optional[StrictInt] = None number_prop: Optional[StrictFloat] = None boolean_prop: Optional[StrictBool] = None diff --git a/samples/openapi3/client/petstore/python-nextgen/petstore_api/models/outer_object_with_enum_property.py b/samples/openapi3/client/petstore/python-nextgen/petstore_api/models/outer_object_with_enum_property.py index 93e47d8b48b..c29ef3b4312 100644 --- a/samples/openapi3/client/petstore/python-nextgen/petstore_api/models/outer_object_with_enum_property.py +++ b/samples/openapi3/client/petstore/python-nextgen/petstore_api/models/outer_object_with_enum_property.py @@ -20,7 +20,7 @@ import json from typing import Optional -from pydantic import BaseModel +from pydantic import BaseModel, Field from petstore_api.models.outer_enum import OuterEnum from petstore_api.models.outer_enum_integer import OuterEnumInteger @@ -29,7 +29,7 @@ class OuterObjectWithEnumProperty(BaseModel): OuterObjectWithEnumProperty """ str_value: Optional[OuterEnum] = None - value: OuterEnumInteger = ... + value: OuterEnumInteger = Field(...) additional_properties: Dict[str, Any] = {} __properties = ["str_value", "value"] diff --git a/samples/openapi3/client/petstore/python-nextgen/petstore_api/models/pet.py b/samples/openapi3/client/petstore/python-nextgen/petstore_api/models/pet.py index 2a028cde3c7..446e5de9c45 100644 --- a/samples/openapi3/client/petstore/python-nextgen/petstore_api/models/pet.py +++ b/samples/openapi3/client/petstore/python-nextgen/petstore_api/models/pet.py @@ -30,7 +30,7 @@ class Pet(BaseModel): """ id: Optional[StrictInt] = None category: Optional[Category] = None - name: StrictStr = ... + name: StrictStr = Field(...) photo_urls: conlist(StrictStr, min_items=0, unique_items=True) = Field(..., alias="photoUrls") tags: Optional[conlist(Tag)] = None status: Optional[StrictStr] = Field(None, description="pet status in the store")