From b40e4d81b494804bc20f51eda5a325b55a813838 Mon Sep 17 00:00:00 2001 From: Ranjan Prasad Date: Sun, 28 Sep 2025 04:20:33 +0530 Subject: [PATCH 1/4] Added enumUnknownDefaultCase property to python generator --- .../languages/PythonClientCodegen.java | 5 + .../main/resources/python/model_enum.mustache | 7 + .../python/PythonClientCodegenTest.java | 121 ++++++++++++++++++ 3 files changed, 133 insertions(+) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonClientCodegen.java index 149ce57c317f..c5d1d77411e4 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonClientCodegen.java @@ -153,6 +153,7 @@ public PythonClientCodegen() { cliOptions.add(new CliOption(CodegenConstants.USE_ONEOF_DISCRIMINATOR_LOOKUP, CodegenConstants.USE_ONEOF_DISCRIMINATOR_LOOKUP_DESC).defaultValue("false")); cliOptions.add(new CliOption(POETRY1_FALLBACK, "Fallback to formatting pyproject.toml to Poetry 1.x format.")); cliOptions.add(new CliOption(LAZY_IMPORTS, "Enable lazy imports.").defaultValue(Boolean.FALSE.toString())); + cliOptions.add(new CliOption(CodegenConstants.ENUM_UNKNOWN_DEFAULT_CASE, CodegenConstants.ENUM_UNKNOWN_DEFAULT_CASE_DESC).defaultValue("false")); supportedLibraries.put("urllib3", "urllib3-based client"); supportedLibraries.put("asyncio", "asyncio-based client"); @@ -271,6 +272,10 @@ public void processOpts() { additionalProperties.put(LAZY_IMPORTS, Boolean.valueOf(additionalProperties.get(LAZY_IMPORTS).toString())); } + if (additionalProperties.containsKey(CodegenConstants.ENUM_UNKNOWN_DEFAULT_CASE)) { + setEnumUnknownDefaultCase(Boolean.parseBoolean(additionalProperties.get(CodegenConstants.ENUM_UNKNOWN_DEFAULT_CASE).toString())); + } + String modelPath = packagePath() + File.separatorChar + modelPackage.replace('.', File.separatorChar); String apiPath = packagePath() + File.separatorChar + apiPackage.replace('.', File.separatorChar); diff --git a/modules/openapi-generator/src/main/resources/python/model_enum.mustache b/modules/openapi-generator/src/main/resources/python/model_enum.mustache index 3f449b121a33..70307afae5a0 100644 --- a/modules/openapi-generator/src/main/resources/python/model_enum.mustache +++ b/modules/openapi-generator/src/main/resources/python/model_enum.mustache @@ -24,6 +24,13 @@ class {{classname}}({{vendorExtensions.x-py-enum-type}}, Enum): def from_json(cls, json_str: str) -> Self: """Create an instance of {{classname}} from a JSON string""" return cls(json.loads(json_str)) + {{#enumUnknownDefaultCase}} + + @classmethod + def _missing_(cls, value): + """Handle unknown enum values""" + return cls.UNKNOWN_DEFAULT_OPEN_API + {{/enumUnknownDefaultCase}} {{#defaultValue}} diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/python/PythonClientCodegenTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/python/PythonClientCodegenTest.java index a18f2f40d11b..382cc2cebf50 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/python/PythonClientCodegenTest.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/python/PythonClientCodegenTest.java @@ -26,6 +26,8 @@ import io.swagger.v3.parser.util.SchemaTypeUtil; import org.openapitools.codegen.*; import org.openapitools.codegen.config.CodegenConfigurator; +import org.openapitools.codegen.model.ModelMap; +import org.openapitools.codegen.model.ModelsMap; import org.openapitools.codegen.languages.PythonClientCodegen; import org.openapitools.codegen.languages.features.CXFServerFeatures; import org.testng.Assert; @@ -38,6 +40,8 @@ import java.nio.file.Paths; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.function.Function; @@ -47,6 +51,7 @@ import static org.junit.jupiter.api.Assertions.assertNull; import static org.openapitools.codegen.TestUtils.assertFileContains; import static org.openapitools.codegen.TestUtils.assertFileExists; +import static org.openapitools.codegen.TestUtils.assertFileNotContains; public class PythonClientCodegenTest { @@ -685,4 +690,120 @@ public void testNonPoetry1LicenseFormat() throws IOException { // Verify it does NOT use the legacy string format TestUtils.assertFileNotContains(pyprojectPath, "license = \"BSD-3-Clause\""); } + + @Test(description = "test enumUnknownDefaultCase option") + public void testEnumUnknownDefaultCaseOption() { + final PythonClientCodegen codegen = new PythonClientCodegen(); + + // Test default value is false + codegen.processOpts(); + Assert.assertEquals(codegen.getEnumUnknownDefaultCase(), Boolean.FALSE); + + // Test setting via additionalProperties + codegen.additionalProperties().put(CodegenConstants.ENUM_UNKNOWN_DEFAULT_CASE, "true"); + codegen.processOpts(); + Assert.assertEquals(codegen.getEnumUnknownDefaultCase(), Boolean.TRUE); + } + + @Test(description = "test enum model generation with enumUnknownDefaultCase") + public void testEnumModelWithUnknownDefaultCase() { + final OpenAPI openAPI = TestUtils.parseFlattenSpec("src/test/resources/3_0/enum_unknown_default_case.yaml"); + final PythonClientCodegen codegen = new PythonClientCodegen(); + + // Enable enumUnknownDefaultCase + codegen.additionalProperties().put(CodegenConstants.ENUM_UNKNOWN_DEFAULT_CASE, "true"); + codegen.setOpenAPI(openAPI); + codegen.processOpts(); + + // Verify that enumUnknownDefaultCase is set + Assert.assertEquals(codegen.getEnumUnknownDefaultCase(), Boolean.TRUE); + + // Process all models to trigger enum processing + Map schemas = openAPI.getComponents().getSchemas(); + Map allModels = new HashMap<>(); + for (String modelName : schemas.keySet()) { + Schema schema = schemas.get(modelName); + CodegenModel cm = codegen.fromModel(modelName, schema); + ModelsMap modelsMap = new ModelsMap(); + modelsMap.setModels(Collections.singletonList(new ModelMap(Collections.singletonMap("model", cm)))); + allModels.put(modelName, modelsMap); + } + + // Post-process to add enumVars + allModels = codegen.postProcessAllModels(allModels); + + // Get the ColorEnum model + CodegenModel colorEnum = null; + for (Map.Entry entry : allModels.entrySet()) { + if ("ColorEnum".equals(entry.getKey())) { + colorEnum = entry.getValue().getModels().get(0).getModel(); + break; + } + } + + Assert.assertNotNull(colorEnum); + Assert.assertNotNull(colorEnum.allowableValues); + + List> enumVars = (List>) colorEnum.allowableValues.get("enumVars"); + Assert.assertNotNull(enumVars); + + // Check that we have the expected enum values including UNKNOWN_DEFAULT_OPEN_API + Assert.assertTrue(enumVars.stream().anyMatch(var -> "'RED'".equals(var.get("value")))); + Assert.assertTrue(enumVars.stream().anyMatch(var -> "'GREEN'".equals(var.get("value")))); + Assert.assertTrue(enumVars.stream().anyMatch(var -> "'BLUE'".equals(var.get("value")))); + Assert.assertTrue(enumVars.stream().anyMatch(var -> "'YELLOW'".equals(var.get("value")))); + Assert.assertTrue(enumVars.stream().anyMatch(var -> "'unknown_default_open_api'".equals(var.get("value")))); + } + + @Test(description = "test enum generation with enumUnknownDefaultCase enabled") + public void testEnumGenerationWithUnknownDefaultCase() throws IOException { + File output = Files.createTempDirectory("test").toFile().getCanonicalFile(); + output.deleteOnExit(); + String outputPath = output.getAbsolutePath().replace('\\', '/'); + + final CodegenConfigurator configurator = new CodegenConfigurator() + .setGeneratorName("python") + .setInputSpec("src/test/resources/3_0/enum_unknown_default_case.yaml") + .setOutputDir(outputPath) + .addAdditionalProperty(CodegenConstants.ENUM_UNKNOWN_DEFAULT_CASE, "true"); + + DefaultGenerator generator = new DefaultGenerator(); + List files = generator.opts(configurator.toClientOptInput()).generate(); + files.forEach(File::deleteOnExit); + + Path enumFile = Paths.get(outputPath, "openapi_client", "models", "color_enum.py"); + + // Check that UNKNOWN_DEFAULT_OPEN_API is added (with single quotes as Python generates) + TestUtils.assertFileContains(enumFile, "UNKNOWN_DEFAULT_OPEN_API = 'unknown_default_open_api'"); + + // Check that _missing_ method is added + TestUtils.assertFileContains(enumFile, "@classmethod"); + TestUtils.assertFileContains(enumFile, "def _missing_(cls, value):"); + TestUtils.assertFileContains(enumFile, "return cls.UNKNOWN_DEFAULT_OPEN_API"); + } + + @Test(description = "test enum generation with enumUnknownDefaultCase disabled") + public void testEnumGenerationWithoutUnknownDefaultCase() throws IOException { + File output = Files.createTempDirectory("test").toFile().getCanonicalFile(); + output.deleteOnExit(); + String outputPath = output.getAbsolutePath().replace('\\', '/'); + + final CodegenConfigurator configurator = new CodegenConfigurator() + .setGeneratorName("python") + .setInputSpec("src/test/resources/3_0/enum_unknown_default_case.yaml") + .setOutputDir(outputPath) + .addAdditionalProperty(CodegenConstants.ENUM_UNKNOWN_DEFAULT_CASE, "false"); + + DefaultGenerator generator = new DefaultGenerator(); + List files = generator.opts(configurator.toClientOptInput()).generate(); + files.forEach(File::deleteOnExit); + + Path enumFile = Paths.get(outputPath, "openapi_client", "models", "color_enum.py"); + + // Check that UNKNOWN_DEFAULT_OPEN_API is NOT added + TestUtils.assertFileNotContains(enumFile, "UNKNOWN_DEFAULT_OPEN_API"); + + // Check that _missing_ method is NOT added + TestUtils.assertFileNotContains(enumFile, "def _missing_(cls, value):"); + } } From 0cee6d9419d5bdfa2cfca2d79dcc548c5004f0c2 Mon Sep 17 00:00:00 2001 From: Ranjan Prasad Date: Sun, 28 Sep 2025 05:10:35 +0530 Subject: [PATCH 2/4] Update docs --- docs/generators/python.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/generators/python.md b/docs/generators/python.md index 10a032dadacb..3aab0db3ab52 100644 --- a/docs/generators/python.md +++ b/docs/generators/python.md @@ -22,6 +22,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl |dateFormat|date format for query parameters| |%Y-%m-%d| |datetimeFormat|datetime format for query parameters| |%Y-%m-%dT%H:%M:%S%z| |disallowAdditionalPropertiesIfNotPresent|If false, the 'additionalProperties' implementation (set to true by default) is compliant with the OAS and JSON schema specifications. If true (default), keep the old (incorrect) behaviour that 'additionalProperties' is set to false by default.|
**false**
The 'additionalProperties' implementation is compliant with the OAS and JSON schema specifications.
**true**
Keep the old (incorrect) behaviour that 'additionalProperties' is set to false by default.
|true| +|enumUnknownDefaultCase|If the server adds new enum cases, that are unknown by an old spec/client, the client will fail to parse the network response.With this option enabled, each enum will have a new case, 'unknown_default_open_api', so that when the server sends an enum case that is not known by the client/spec, they can safely fallback to this case.| |false| |generateSourceCodeOnly|Specifies that only a library source code is to be generated.| |false| |hideGenerationTimestamp|Hides the generation timestamp when files are generated.| |true| |lazyImports|Enable lazy imports.| |false| From 17a184c2b0e8e38ba78d70e7e7e706b001dc845e Mon Sep 17 00:00:00 2001 From: Ranjan Prasad Date: Mon, 29 Sep 2025 05:51:09 +0530 Subject: [PATCH 3/4] Test cases fixes --- .../3_0/enum_unknown_default_case.yaml | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 modules/openapi-generator/src/test/resources/3_0/enum_unknown_default_case.yaml diff --git a/modules/openapi-generator/src/test/resources/3_0/enum_unknown_default_case.yaml b/modules/openapi-generator/src/test/resources/3_0/enum_unknown_default_case.yaml new file mode 100644 index 000000000000..05f23cbaef7b --- /dev/null +++ b/modules/openapi-generator/src/test/resources/3_0/enum_unknown_default_case.yaml @@ -0,0 +1,56 @@ +openapi: 3.0.0 +info: + title: Enum Test API + description: API for testing enum generation with enumUnknownDefaultCase + version: 1.0.0 +paths: + /colors: + get: + summary: Get color + operationId: getColor + responses: + '200': + description: Successful response + content: + application/json: + schema: + $ref: '#/components/schemas/ColorResponse' +components: + schemas: + ColorResponse: + type: object + required: + - color + - status + properties: + color: + $ref: '#/components/schemas/ColorEnum' + status: + $ref: '#/components/schemas/StatusEnum' + priority: + $ref: '#/components/schemas/PriorityEnum' + ColorEnum: + type: string + description: Available colors + enum: + - RED + - GREEN + - BLUE + - YELLOW + StatusEnum: + type: string + description: Status values + enum: + - PENDING + - APPROVED + - REJECTED + - IN_PROGRESS + PriorityEnum: + type: integer + description: Priority levels + enum: + - 1 + - 2 + - 3 + - 4 + - 5 \ No newline at end of file From 3a502aab8dcec170d57c7a670b0eb3641fe0a30b Mon Sep 17 00:00:00 2001 From: William Cheng Date: Tue, 30 Sep 2025 16:41:06 +0800 Subject: [PATCH 4/4] test the new option --- bin/configs/python-aiohttp.yaml | 1 + .../python-aiohttp/docs/DataOutputFormat.md | 2 ++ .../petstore/python-aiohttp/docs/EnumClass.md | 2 ++ .../docs/EnumNumberVendorExt.md | 2 ++ .../python-aiohttp/docs/EnumString1.md | 2 ++ .../python-aiohttp/docs/EnumString2.md | 2 ++ .../docs/EnumStringVendorExt.md | 2 ++ .../python-aiohttp/docs/OneOfEnumString.md | 2 ++ .../petstore/python-aiohttp/docs/OuterEnum.md | 2 ++ .../docs/OuterEnumDefaultValue.md | 2 ++ .../python-aiohttp/docs/OuterEnumInteger.md | 2 ++ .../docs/OuterEnumIntegerDefaultValue.md | 2 ++ .../python-aiohttp/docs/SingleRefType.md | 2 ++ .../docs/SpecialCharacterEnum.md | 2 ++ .../petstore/python-aiohttp/docs/TestEnum.md | 2 ++ .../docs/TestEnumWithDefault.md | 2 ++ .../petstore/python-aiohttp/docs/Type.md | 2 ++ .../petstore_api/models/bathing.py | 8 +++--- .../petstore_api/models/data_output_format.py | 6 ++++ .../petstore_api/models/enum_arrays.py | 8 +++--- .../petstore_api/models/enum_class.py | 6 ++++ .../models/enum_number_vendor_ext.py | 6 ++++ .../petstore_api/models/enum_string1.py | 6 ++++ .../petstore_api/models/enum_string2.py | 6 ++++ .../models/enum_string_vendor_ext.py | 6 ++++ .../petstore_api/models/enum_test.py | 28 +++++++++---------- .../petstore_api/models/feeding.py | 8 +++--- .../petstore_api/models/map_test.py | 4 +-- .../petstore_api/models/one_of_enum_string.py | 6 ++++ .../petstore_api/models/order.py | 4 +-- .../petstore_api/models/outer_enum.py | 6 ++++ .../models/outer_enum_default_value.py | 6 ++++ .../petstore_api/models/outer_enum_integer.py | 6 ++++ .../outer_enum_integer_default_value.py | 6 ++++ .../python-aiohttp/petstore_api/models/pet.py | 4 +-- .../petstore_api/models/poop_cleaning.py | 8 +++--- .../petstore_api/models/single_ref_type.py | 6 ++++ .../models/special_character_enum.py | 6 ++++ .../petstore_api/models/special_name.py | 4 +-- .../petstore_api/models/test_enum.py | 6 ++++ .../models/test_enum_with_default.py | 6 ++++ .../models/test_model_with_enum_default.py | 4 +-- .../petstore_api/models/type.py | 6 ++++ 43 files changed, 169 insertions(+), 40 deletions(-) diff --git a/bin/configs/python-aiohttp.yaml b/bin/configs/python-aiohttp.yaml index 14a1adeffd39..52f57d5f36d5 100644 --- a/bin/configs/python-aiohttp.yaml +++ b/bin/configs/python-aiohttp.yaml @@ -7,6 +7,7 @@ additionalProperties: packageName: petstore_api mapNumberTo: float poetry1: true + enumUnknownDefaultCase: true nameMappings: _type: underscore_type type_: type_with_underscore diff --git a/samples/openapi3/client/petstore/python-aiohttp/docs/DataOutputFormat.md b/samples/openapi3/client/petstore/python-aiohttp/docs/DataOutputFormat.md index d9df2a1cffdc..d16909b25801 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/DataOutputFormat.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/DataOutputFormat.md @@ -9,6 +9,8 @@ * `XML` (value: `'XML'`) +* `UNKNOWN_DEFAULT_OPEN_API` (value: `'unknown_default_open_api'`) + [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/openapi3/client/petstore/python-aiohttp/docs/EnumClass.md b/samples/openapi3/client/petstore/python-aiohttp/docs/EnumClass.md index 725b617bdade..f6d43e9be202 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/EnumClass.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/EnumClass.md @@ -9,6 +9,8 @@ * `LEFT_PARENTHESIS_XYZ_RIGHT_PARENTHESIS` (value: `'(xyz)'`) +* `UNKNOWN_DEFAULT_OPEN_API` (value: `'unknown_default_open_api'`) + [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/openapi3/client/petstore/python-aiohttp/docs/EnumNumberVendorExt.md b/samples/openapi3/client/petstore/python-aiohttp/docs/EnumNumberVendorExt.md index 4c1572b1d277..60e2541a8266 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/EnumNumberVendorExt.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/EnumNumberVendorExt.md @@ -9,6 +9,8 @@ * `FiftySix` (value: `56`) +* `unknown_default_open_api` (value: `11184809`) + [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/openapi3/client/petstore/python-aiohttp/docs/EnumString1.md b/samples/openapi3/client/petstore/python-aiohttp/docs/EnumString1.md index aa214538bca5..d177a4db51d9 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/EnumString1.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/EnumString1.md @@ -7,6 +7,8 @@ * `B` (value: `'b'`) +* `UNKNOWN_DEFAULT_OPEN_API` (value: `'unknown_default_open_api'`) + [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/openapi3/client/petstore/python-aiohttp/docs/EnumString2.md b/samples/openapi3/client/petstore/python-aiohttp/docs/EnumString2.md index d1b49f8dddd4..b430966dccea 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/EnumString2.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/EnumString2.md @@ -7,6 +7,8 @@ * `D` (value: `'d'`) +* `UNKNOWN_DEFAULT_OPEN_API` (value: `'unknown_default_open_api'`) + [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/openapi3/client/petstore/python-aiohttp/docs/EnumStringVendorExt.md b/samples/openapi3/client/petstore/python-aiohttp/docs/EnumStringVendorExt.md index ce6077c18a3b..f97739e8ea8c 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/EnumStringVendorExt.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/EnumStringVendorExt.md @@ -9,6 +9,8 @@ * `bazVar_XEnumVarname` (value: `'baz'`) +* `'unknown_default_open_api'` (value: `'unknown_default_open_api'`) + [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/openapi3/client/petstore/python-aiohttp/docs/OneOfEnumString.md b/samples/openapi3/client/petstore/python-aiohttp/docs/OneOfEnumString.md index 6f1b157c36ca..6fd81f92b941 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/OneOfEnumString.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/OneOfEnumString.md @@ -12,6 +12,8 @@ oneOf enum strings * `D` (value: `'d'`) +* `UNKNOWN_DEFAULT_OPEN_API` (value: `'unknown_default_open_api'`) + [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/openapi3/client/petstore/python-aiohttp/docs/OuterEnum.md b/samples/openapi3/client/petstore/python-aiohttp/docs/OuterEnum.md index 9ba4f91069a5..137be383829a 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/OuterEnum.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/OuterEnum.md @@ -9,6 +9,8 @@ * `DELIVERED` (value: `'delivered'`) +* `UNKNOWN_DEFAULT_OPEN_API` (value: `'unknown_default_open_api'`) + [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/openapi3/client/petstore/python-aiohttp/docs/OuterEnumDefaultValue.md b/samples/openapi3/client/petstore/python-aiohttp/docs/OuterEnumDefaultValue.md index 0c97f8c9cb60..c43eeab66d2c 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/OuterEnumDefaultValue.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/OuterEnumDefaultValue.md @@ -9,6 +9,8 @@ * `DELIVERED` (value: `'delivered'`) +* `UNKNOWN_DEFAULT_OPEN_API` (value: `'unknown_default_open_api'`) + [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/openapi3/client/petstore/python-aiohttp/docs/OuterEnumInteger.md b/samples/openapi3/client/petstore/python-aiohttp/docs/OuterEnumInteger.md index 052b51638145..fcc49edae9f4 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/OuterEnumInteger.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/OuterEnumInteger.md @@ -9,6 +9,8 @@ * `NUMBER_2` (value: `2`) +* `NUMBER_11184809` (value: `11184809`) + [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/openapi3/client/petstore/python-aiohttp/docs/OuterEnumIntegerDefaultValue.md b/samples/openapi3/client/petstore/python-aiohttp/docs/OuterEnumIntegerDefaultValue.md index 66cd0abdb0a5..2d95078fb0da 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/OuterEnumIntegerDefaultValue.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/OuterEnumIntegerDefaultValue.md @@ -11,6 +11,8 @@ * `NUMBER_2` (value: `2`) +* `NUMBER_11184809` (value: `11184809`) + [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/openapi3/client/petstore/python-aiohttp/docs/SingleRefType.md b/samples/openapi3/client/petstore/python-aiohttp/docs/SingleRefType.md index 8f0f60e5678c..9c9269b03f0b 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/SingleRefType.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/SingleRefType.md @@ -7,6 +7,8 @@ * `USER` (value: `'user'`) +* `UNKNOWN_DEFAULT_OPEN_API` (value: `'unknown_default_open_api'`) + [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/openapi3/client/petstore/python-aiohttp/docs/SpecialCharacterEnum.md b/samples/openapi3/client/petstore/python-aiohttp/docs/SpecialCharacterEnum.md index 71a3affc4fe5..a8a78276b083 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/SpecialCharacterEnum.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/SpecialCharacterEnum.md @@ -23,6 +23,8 @@ * `HELLO_WORLD` (value: `' hello world '`) +* `UNKNOWN_DEFAULT_OPEN_API` (value: `'unknown_default_open_api'`) + [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/openapi3/client/petstore/python-aiohttp/docs/TestEnum.md b/samples/openapi3/client/petstore/python-aiohttp/docs/TestEnum.md index 612b62bd4dc4..2fe27924ccb2 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/TestEnum.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/TestEnum.md @@ -11,6 +11,8 @@ * `FOUR` (value: `'foUr'`) +* `UNKNOWN_DEFAULT_OPEN_API` (value: `'unknown_default_open_api'`) + [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/openapi3/client/petstore/python-aiohttp/docs/TestEnumWithDefault.md b/samples/openapi3/client/petstore/python-aiohttp/docs/TestEnumWithDefault.md index ac8591c95c04..114bd1874598 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/TestEnumWithDefault.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/TestEnumWithDefault.md @@ -9,6 +9,8 @@ * `DREI` (value: `'DREI'`) +* `UNKNOWN_DEFAULT_OPEN_API` (value: `'unknown_default_open_api'`) + [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/openapi3/client/petstore/python-aiohttp/docs/Type.md b/samples/openapi3/client/petstore/python-aiohttp/docs/Type.md index f7ff2903a728..a132564bfaa5 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/Type.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/Type.md @@ -11,6 +11,8 @@ * `NUMBER_0_DOT_25` (value: `0.25`) +* `NUMBER_11184809` (value: `11184809`) + [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/bathing.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/bathing.py index 088e6ad3b873..2685383baced 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/bathing.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/bathing.py @@ -34,15 +34,15 @@ class Bathing(BaseModel): @field_validator('task_name') def task_name_validate_enum(cls, value): """Validates the enum""" - if value not in set(['cleaning_deep']): - raise ValueError("must be one of enum values ('cleaning_deep')") + if value not in set(['cleaning_deep', 'unknown_default_open_api']): + raise ValueError("must be one of enum values ('cleaning_deep', 'unknown_default_open_api')") return value @field_validator('function_name') def function_name_validate_enum(cls, value): """Validates the enum""" - if value not in set(['care_nourish']): - raise ValueError("must be one of enum values ('care_nourish')") + if value not in set(['care_nourish', 'unknown_default_open_api']): + raise ValueError("must be one of enum values ('care_nourish', 'unknown_default_open_api')") return value model_config = ConfigDict( diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/data_output_format.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/data_output_format.py index ee3df76c5169..6ba277d4a5cb 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/data_output_format.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/data_output_format.py @@ -29,10 +29,16 @@ class DataOutputFormat(str, Enum): JSON = 'JSON' CSV = 'CSV' XML = 'XML' + UNKNOWN_DEFAULT_OPEN_API = 'unknown_default_open_api' @classmethod def from_json(cls, json_str: str) -> Self: """Create an instance of DataOutputFormat from a JSON string""" return cls(json.loads(json_str)) + @classmethod + def _missing_(cls, value): + """Handle unknown enum values""" + return cls.UNKNOWN_DEFAULT_OPEN_API + diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_arrays.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_arrays.py index 68ceb962b03e..068d7c183845 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_arrays.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_arrays.py @@ -36,8 +36,8 @@ def just_symbol_validate_enum(cls, value): if value is None: return value - if value not in set(['>=', '$']): - raise ValueError("must be one of enum values ('>=', '$')") + if value not in set(['>=', '$', 'unknown_default_open_api']): + raise ValueError("must be one of enum values ('>=', '$', 'unknown_default_open_api')") return value @field_validator('array_enum') @@ -47,8 +47,8 @@ def array_enum_validate_enum(cls, value): return value for i in value: - if i not in set(['fish', 'crab']): - raise ValueError("each list item must be one of ('fish', 'crab')") + if i not in set(['fish', 'crab', 'unknown_default_open_api']): + raise ValueError("each list item must be one of ('fish', 'crab', 'unknown_default_open_api')") return value model_config = ConfigDict( diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_class.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_class.py index 1ba5af8036df..dd3b506f794c 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_class.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_class.py @@ -29,10 +29,16 @@ class EnumClass(str, Enum): ABC = '_abc' MINUS_EFG = '-efg' LEFT_PARENTHESIS_XYZ_RIGHT_PARENTHESIS = '(xyz)' + UNKNOWN_DEFAULT_OPEN_API = 'unknown_default_open_api' @classmethod def from_json(cls, json_str: str) -> Self: """Create an instance of EnumClass from a JSON string""" return cls(json.loads(json_str)) + @classmethod + def _missing_(cls, value): + """Handle unknown enum values""" + return cls.UNKNOWN_DEFAULT_OPEN_API + diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_number_vendor_ext.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_number_vendor_ext.py index 5588de5c7043..703db0a10e93 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_number_vendor_ext.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_number_vendor_ext.py @@ -29,10 +29,16 @@ class EnumNumberVendorExt(int, Enum): FortyTwo = 42 Eigtheen = 18 FiftySix = 56 + unknown_default_open_api = 11184809 @classmethod def from_json(cls, json_str: str) -> Self: """Create an instance of EnumNumberVendorExt from a JSON string""" return cls(json.loads(json_str)) + @classmethod + def _missing_(cls, value): + """Handle unknown enum values""" + return cls.UNKNOWN_DEFAULT_OPEN_API + diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_string1.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_string1.py index 678b4e12661f..e5211bc83c66 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_string1.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_string1.py @@ -28,10 +28,16 @@ class EnumString1(str, Enum): """ A = 'a' B = 'b' + UNKNOWN_DEFAULT_OPEN_API = 'unknown_default_open_api' @classmethod def from_json(cls, json_str: str) -> Self: """Create an instance of EnumString1 from a JSON string""" return cls(json.loads(json_str)) + @classmethod + def _missing_(cls, value): + """Handle unknown enum values""" + return cls.UNKNOWN_DEFAULT_OPEN_API + diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_string2.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_string2.py index a959f554e0af..92f9f3a437f3 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_string2.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_string2.py @@ -28,10 +28,16 @@ class EnumString2(str, Enum): """ C = 'c' D = 'd' + UNKNOWN_DEFAULT_OPEN_API = 'unknown_default_open_api' @classmethod def from_json(cls, json_str: str) -> Self: """Create an instance of EnumString2 from a JSON string""" return cls(json.loads(json_str)) + @classmethod + def _missing_(cls, value): + """Handle unknown enum values""" + return cls.UNKNOWN_DEFAULT_OPEN_API + diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_string_vendor_ext.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_string_vendor_ext.py index 821812e9b088..3a48ef50c1bc 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_string_vendor_ext.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_string_vendor_ext.py @@ -29,10 +29,16 @@ class EnumStringVendorExt(str, Enum): FOO_XEnumVarname = 'FOO' BarVar_XEnumVarname = 'Bar' bazVar_XEnumVarname = 'baz' + 'unknown_default_open_api' = 'unknown_default_open_api' @classmethod def from_json(cls, json_str: str) -> Self: """Create an instance of EnumStringVendorExt from a JSON string""" return cls(json.loads(json_str)) + @classmethod + def _missing_(cls, value): + """Handle unknown enum values""" + return cls.UNKNOWN_DEFAULT_OPEN_API + diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_test.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_test.py index b7e6ec36230f..1fe3bab0936a 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_test.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_test.py @@ -53,15 +53,15 @@ def enum_string_validate_enum(cls, value): if value is None: return value - if value not in set(['UPPER', 'lower', '']): - raise ValueError("must be one of enum values ('UPPER', 'lower', '')") + if value not in set(['UPPER', 'lower', '', 'unknown_default_open_api']): + raise ValueError("must be one of enum values ('UPPER', 'lower', '', 'unknown_default_open_api')") return value @field_validator('enum_string_required') def enum_string_required_validate_enum(cls, value): """Validates the enum""" - if value not in set(['UPPER', 'lower', '']): - raise ValueError("must be one of enum values ('UPPER', 'lower', '')") + if value not in set(['UPPER', 'lower', '', 'unknown_default_open_api']): + raise ValueError("must be one of enum values ('UPPER', 'lower', '', 'unknown_default_open_api')") return value @field_validator('enum_integer_default') @@ -70,8 +70,8 @@ def enum_integer_default_validate_enum(cls, value): if value is None: return value - if value not in set([1, 5, 14]): - raise ValueError("must be one of enum values (1, 5, 14)") + if value not in set([1, 5, 14, 11184809]): + raise ValueError("must be one of enum values (1, 5, 14, 11184809)") return value @field_validator('enum_integer') @@ -80,8 +80,8 @@ def enum_integer_validate_enum(cls, value): if value is None: return value - if value not in set([1, -1]): - raise ValueError("must be one of enum values (1, -1)") + if value not in set([1, -1, 11184809]): + raise ValueError("must be one of enum values (1, -1, 11184809)") return value @field_validator('enum_number') @@ -90,8 +90,8 @@ def enum_number_validate_enum(cls, value): if value is None: return value - if value not in set([1.1, -1.2]): - raise ValueError("must be one of enum values (1.1, -1.2)") + if value not in set([1.1, -1.2, 11184809]): + raise ValueError("must be one of enum values (1.1, -1.2, 11184809)") return value @field_validator('enum_string_single_member') @@ -100,8 +100,8 @@ def enum_string_single_member_validate_enum(cls, value): if value is None: return value - if value not in set(['abc']): - raise ValueError("must be one of enum values ('abc')") + if value not in set(['abc', 'unknown_default_open_api']): + raise ValueError("must be one of enum values ('abc', 'unknown_default_open_api')") return value @field_validator('enum_integer_single_member') @@ -110,8 +110,8 @@ def enum_integer_single_member_validate_enum(cls, value): if value is None: return value - if value not in set([100]): - raise ValueError("must be one of enum values (100)") + if value not in set([100, 11184809]): + raise ValueError("must be one of enum values (100, 11184809)") return value model_config = ConfigDict( diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/feeding.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/feeding.py index 1183b314fdd0..798001a36db1 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/feeding.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/feeding.py @@ -34,15 +34,15 @@ class Feeding(BaseModel): @field_validator('task_name') def task_name_validate_enum(cls, value): """Validates the enum""" - if value not in set(['cleaning']): - raise ValueError("must be one of enum values ('cleaning')") + if value not in set(['cleaning', 'unknown_default_open_api']): + raise ValueError("must be one of enum values ('cleaning', 'unknown_default_open_api')") return value @field_validator('function_name') def function_name_validate_enum(cls, value): """Validates the enum""" - if value not in set(['care_nourish']): - raise ValueError("must be one of enum values ('care_nourish')") + if value not in set(['care_nourish', 'unknown_default_open_api']): + raise ValueError("must be one of enum values ('care_nourish', 'unknown_default_open_api')") return value model_config = ConfigDict( diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/map_test.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/map_test.py index 2a056ab5532a..a620b82535b4 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/map_test.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/map_test.py @@ -39,8 +39,8 @@ def map_of_enum_string_validate_enum(cls, value): return value for i in value.values(): - if i not in set(['UPPER', 'lower']): - raise ValueError("dict values must be one of enum values ('UPPER', 'lower')") + if i not in set(['UPPER', 'lower', 'unknown_default_open_api']): + raise ValueError("dict values must be one of enum values ('UPPER', 'lower', 'unknown_default_open_api')") return value model_config = ConfigDict( diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/one_of_enum_string.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/one_of_enum_string.py index 53101c37cc8b..0eeeffe8c6fb 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/one_of_enum_string.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/one_of_enum_string.py @@ -30,10 +30,16 @@ class OneOfEnumString(str, Enum): B = 'b' C = 'c' D = 'd' + UNKNOWN_DEFAULT_OPEN_API = 'unknown_default_open_api' @classmethod def from_json(cls, json_str: str) -> Self: """Create an instance of OneOfEnumString from a JSON string""" return cls(json.loads(json_str)) + @classmethod + def _missing_(cls, value): + """Handle unknown enum values""" + return cls.UNKNOWN_DEFAULT_OPEN_API + diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/order.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/order.py index f742027e088a..97ac2bdaaa68 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/order.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/order.py @@ -41,8 +41,8 @@ def status_validate_enum(cls, value): if value is None: return value - if value not in set(['placed', 'approved', 'delivered']): - raise ValueError("must be one of enum values ('placed', 'approved', 'delivered')") + if value not in set(['placed', 'approved', 'delivered', 'unknown_default_open_api']): + raise ValueError("must be one of enum values ('placed', 'approved', 'delivered', 'unknown_default_open_api')") return value model_config = ConfigDict( diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_enum.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_enum.py index ac48cc0dc4d8..a8a5f7b9d223 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_enum.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_enum.py @@ -29,10 +29,16 @@ class OuterEnum(str, Enum): PLACED = 'placed' APPROVED = 'approved' DELIVERED = 'delivered' + UNKNOWN_DEFAULT_OPEN_API = 'unknown_default_open_api' @classmethod def from_json(cls, json_str: str) -> Self: """Create an instance of OuterEnum from a JSON string""" return cls(json.loads(json_str)) + @classmethod + def _missing_(cls, value): + """Handle unknown enum values""" + return cls.UNKNOWN_DEFAULT_OPEN_API + diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_enum_default_value.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_enum_default_value.py index 99d6fd5fc042..717d1688a4a2 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_enum_default_value.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_enum_default_value.py @@ -29,10 +29,16 @@ class OuterEnumDefaultValue(str, Enum): PLACED = 'placed' APPROVED = 'approved' DELIVERED = 'delivered' + UNKNOWN_DEFAULT_OPEN_API = 'unknown_default_open_api' @classmethod def from_json(cls, json_str: str) -> Self: """Create an instance of OuterEnumDefaultValue from a JSON string""" return cls(json.loads(json_str)) + @classmethod + def _missing_(cls, value): + """Handle unknown enum values""" + return cls.UNKNOWN_DEFAULT_OPEN_API + diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_enum_integer.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_enum_integer.py index b771b7a61f55..fd0265ef2c29 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_enum_integer.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_enum_integer.py @@ -29,10 +29,16 @@ class OuterEnumInteger(int, Enum): NUMBER_0 = 0 NUMBER_1 = 1 NUMBER_2 = 2 + NUMBER_11184809 = 11184809 @classmethod def from_json(cls, json_str: str) -> Self: """Create an instance of OuterEnumInteger from a JSON string""" return cls(json.loads(json_str)) + @classmethod + def _missing_(cls, value): + """Handle unknown enum values""" + return cls.UNKNOWN_DEFAULT_OPEN_API + diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_enum_integer_default_value.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_enum_integer_default_value.py index 8df41b2bd320..eb48bfb3b5ef 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_enum_integer_default_value.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_enum_integer_default_value.py @@ -30,10 +30,16 @@ class OuterEnumIntegerDefaultValue(int, Enum): NUMBER_0 = 0 NUMBER_1 = 1 NUMBER_2 = 2 + NUMBER_11184809 = 11184809 @classmethod def from_json(cls, json_str: str) -> Self: """Create an instance of OuterEnumIntegerDefaultValue from a JSON string""" return cls(json.loads(json_str)) + @classmethod + def _missing_(cls, value): + """Handle unknown enum values""" + return cls.UNKNOWN_DEFAULT_OPEN_API + diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/pet.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/pet.py index be47c3b1a894..1c9aee8e56eb 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/pet.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/pet.py @@ -43,8 +43,8 @@ def status_validate_enum(cls, value): if value is None: return value - if value not in set(['available', 'pending', 'sold']): - raise ValueError("must be one of enum values ('available', 'pending', 'sold')") + if value not in set(['available', 'pending', 'sold', 'unknown_default_open_api']): + raise ValueError("must be one of enum values ('available', 'pending', 'sold', 'unknown_default_open_api')") return value model_config = ConfigDict( diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/poop_cleaning.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/poop_cleaning.py index 047cf0d481a9..78c3ea97cc04 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/poop_cleaning.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/poop_cleaning.py @@ -34,15 +34,15 @@ class PoopCleaning(BaseModel): @field_validator('task_name') def task_name_validate_enum(cls, value): """Validates the enum""" - if value not in set(['cleaning']): - raise ValueError("must be one of enum values ('cleaning')") + if value not in set(['cleaning', 'unknown_default_open_api']): + raise ValueError("must be one of enum values ('cleaning', 'unknown_default_open_api')") return value @field_validator('function_name') def function_name_validate_enum(cls, value): """Validates the enum""" - if value not in set(['care']): - raise ValueError("must be one of enum values ('care')") + if value not in set(['care', 'unknown_default_open_api']): + raise ValueError("must be one of enum values ('care', 'unknown_default_open_api')") return value model_config = ConfigDict( diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/single_ref_type.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/single_ref_type.py index 91ab07e2535c..2a2b2b4888b7 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/single_ref_type.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/single_ref_type.py @@ -28,10 +28,16 @@ class SingleRefType(str, Enum): """ ADMIN = 'admin' USER = 'user' + UNKNOWN_DEFAULT_OPEN_API = 'unknown_default_open_api' @classmethod def from_json(cls, json_str: str) -> Self: """Create an instance of SingleRefType from a JSON string""" return cls(json.loads(json_str)) + @classmethod + def _missing_(cls, value): + """Handle unknown enum values""" + return cls.UNKNOWN_DEFAULT_OPEN_API + diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/special_character_enum.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/special_character_enum.py index 1d85fd148d4b..072a330ff18e 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/special_character_enum.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/special_character_enum.py @@ -36,10 +36,16 @@ class SpecialCharacterEnum(str, Enum): THIS_IS_EXCLAMATION = 'this_is_!' IMPORT = 'import' HELLO_WORLD = ' hello world ' + UNKNOWN_DEFAULT_OPEN_API = 'unknown_default_open_api' @classmethod def from_json(cls, json_str: str) -> Self: """Create an instance of SpecialCharacterEnum from a JSON string""" return cls(json.loads(json_str)) + @classmethod + def _missing_(cls, value): + """Handle unknown enum values""" + return cls.UNKNOWN_DEFAULT_OPEN_API + diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/special_name.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/special_name.py index d3c8f6185683..e175613d5cc4 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/special_name.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/special_name.py @@ -38,8 +38,8 @@ def var_schema_validate_enum(cls, value): if value is None: return value - if value not in set(['available', 'pending', 'sold']): - raise ValueError("must be one of enum values ('available', 'pending', 'sold')") + if value not in set(['available', 'pending', 'sold', 'unknown_default_open_api']): + raise ValueError("must be one of enum values ('available', 'pending', 'sold', 'unknown_default_open_api')") return value model_config = ConfigDict( diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_enum.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_enum.py index 8eae227a84e9..f864a8f8ddea 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_enum.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_enum.py @@ -30,10 +30,16 @@ class TestEnum(str, Enum): TWO = 'TWO' THREE = 'THREE' FOUR = 'foUr' + UNKNOWN_DEFAULT_OPEN_API = 'unknown_default_open_api' @classmethod def from_json(cls, json_str: str) -> Self: """Create an instance of TestEnum from a JSON string""" return cls(json.loads(json_str)) + @classmethod + def _missing_(cls, value): + """Handle unknown enum values""" + return cls.UNKNOWN_DEFAULT_OPEN_API + diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_enum_with_default.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_enum_with_default.py index 9304d3ab8497..f3e5c2018509 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_enum_with_default.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_enum_with_default.py @@ -29,10 +29,16 @@ class TestEnumWithDefault(str, Enum): EIN = 'EIN' ZWEI = 'ZWEI' DREI = 'DREI' + UNKNOWN_DEFAULT_OPEN_API = 'unknown_default_open_api' @classmethod def from_json(cls, json_str: str) -> Self: """Create an instance of TestEnumWithDefault from a JSON string""" return cls(json.loads(json_str)) + @classmethod + def _missing_(cls, value): + """Handle unknown enum values""" + return cls.UNKNOWN_DEFAULT_OPEN_API + diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_model_with_enum_default.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_model_with_enum_default.py index 218fa8f16d22..611b5e5f8e05 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_model_with_enum_default.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_model_with_enum_default.py @@ -41,8 +41,8 @@ def test_inline_defined_enum_with_default_validate_enum(cls, value): if value is None: return value - if value not in set(['A', 'B', 'C']): - raise ValueError("must be one of enum values ('A', 'B', 'C')") + if value not in set(['A', 'B', 'C', 'unknown_default_open_api']): + raise ValueError("must be one of enum values ('A', 'B', 'C', 'unknown_default_open_api')") return value model_config = ConfigDict( diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/type.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/type.py index 35a847de894f..3dffd4a61cae 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/type.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/type.py @@ -30,10 +30,16 @@ class Type(int, Enum): NUMBER_1_DOT_0 = 1.0 NUMBER_0_DOT_5 = 0.5 NUMBER_0_DOT_25 = 0.25 + NUMBER_11184809 = 11184809 @classmethod def from_json(cls, json_str: str) -> Self: """Create an instance of Type from a JSON string""" return cls(json.loads(json_str)) + @classmethod + def _missing_(cls, value): + """Handle unknown enum values""" + return cls.UNKNOWN_DEFAULT_OPEN_API +