diff --git a/modules/openapi-generator/src/main/resources/python/model_anyof.mustache b/modules/openapi-generator/src/main/resources/python/model_anyof.mustache index 3c275f1d5157..29b04f5ad242 100644 --- a/modules/openapi-generator/src/main/resources/python/model_anyof.mustache +++ b/modules/openapi-generator/src/main/resources/python/model_anyof.mustache @@ -80,7 +80,7 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}} return v {{/isNullable}} - instance = {{{classname}}}.construct() + instance = {{{classname}}}.{{#usePydanticV2}}model_construct{{/usePydanticV2}}{{^usePydanticV2}}construct{{/usePydanticV2}}() error_messages = [] {{#composedSchemas.anyOf}} # validate data type: {{{dataType}}} @@ -121,7 +121,7 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}} @classmethod def from_json(cls, json_str: str) -> {{{classname}}}: """Returns the object represented by the json string""" - instance = {{{classname}}}.construct() + instance = {{{classname}}}.{{#usePydanticV2}}model_construct{{/usePydanticV2}}{{^usePydanticV2}}construct{{/usePydanticV2}}() {{#isNullable}} if json_str is None: return instance diff --git a/modules/openapi-generator/src/main/resources/python/model_oneof.mustache b/modules/openapi-generator/src/main/resources/python/model_oneof.mustache index ab47b11b90bd..deff859d13da 100644 --- a/modules/openapi-generator/src/main/resources/python/model_oneof.mustache +++ b/modules/openapi-generator/src/main/resources/python/model_oneof.mustache @@ -80,7 +80,7 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}} return v {{/isNullable}} - instance = {{{classname}}}.construct() + instance = {{{classname}}}.{{#usePydanticV2}}model_construct{{/usePydanticV2}}{{^usePydanticV2}}construct{{/usePydanticV2}}() error_messages = [] match = 0 {{#composedSchemas.oneOf}} @@ -124,7 +124,7 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}} @classmethod def from_json(cls, json_str: str) -> {{{classname}}}: """Returns the object represented by the json string""" - instance = {{{classname}}}.construct() + instance = {{{classname}}}.{{#usePydanticV2}}model_construct{{/usePydanticV2}}{{^usePydanticV2}}construct{{/usePydanticV2}}() {{#isNullable}} if json_str is None: return instance