diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonExperimentalClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonExperimentalClientCodegen.java index 442bb8bb466..391d1d823da 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonExperimentalClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonExperimentalClientCodegen.java @@ -55,6 +55,7 @@ import org.openapitools.codegen.api.TemplateProcessor; import java.io.File; import java.io.IOException; +import java.math.BigDecimal; import java.nio.file.Path; import java.time.OffsetDateTime; import java.time.ZoneOffset; @@ -1226,6 +1227,8 @@ public class PythonExperimentalClientCodegen extends AbstractPythonCodegen { // our enum var names are keys in a python dict, so change spaces to underscores if (value.length() == 0) { return "EMPTY"; + } else if (value.equals("null")) { + return "NONE"; } String intPattern = "^[-\\+]?\\d+$"; @@ -1289,26 +1292,80 @@ public class PythonExperimentalClientCodegen extends AbstractPythonCodegen { return varName; } - /** - * Return the enum value in the language specified format - * e.g. status becomes "status" - * - * @param value enum variable name - * @param datatype data type - * @return the sanitized value for enum - */ - public String toEnumValue(String value, String datatype) { - if ("int".equals(datatype) || "float".equals(datatype) || datatype.equals("int, float")) { - return value; - } else if ("bool".equals(datatype)) { - if (value.equals("true")) { - return "schemas.BoolClass.TRUE"; - } - return "schemas.BoolClass.FALSE"; - } else { - String fixedValue = (String) processTestExampleData(value); - return ensureQuotes(fixedValue); + protected List> buildEnumVars(List values, String dataType) { + List> enumVars = new ArrayList<>(); + int truncateIdx = 0; + + if (isRemoveEnumValuePrefix()) { + String commonPrefix = findCommonPrefixOfVars(values); + truncateIdx = commonPrefix.length(); } + + for (Object value : values) { + Map enumVar = new HashMap<>(); + String enumName; + if (truncateIdx == 0) { + enumName = String.valueOf(value); + } else { + enumName = value.toString().substring(truncateIdx); + if (enumName.isEmpty()) { + enumName = value.toString(); + } + } + + enumVar.put("name", toEnumVarName(enumName, dataType)); + if (value instanceof Integer) { + enumVar.put("value", value); + } else if (value instanceof Double) { + enumVar.put("value", value); + } else if (value instanceof Long) { + enumVar.put("value", value); + } else if (value instanceof Float) { + enumVar.put("value", value); + } else if (value instanceof BigDecimal) { + enumVar.put("value", value); + } else if (value == null) { + enumVar.put("value", "schemas.NoneClass.NONE"); + } else if (value instanceof Boolean) { + if (value.equals(Boolean.TRUE)) { + enumVar.put("value", "schemas.BoolClass.TRUE"); + } else { + enumVar.put("value", "schemas.BoolClass.FALSE"); + } + } else { + String fixedValue = (String) processTestExampleData(value); + enumVar.put("value", ensureQuotes(fixedValue)); + } + enumVar.put("isString", isDataTypeString(dataType)); + enumVars.add(enumVar); + } + + if (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. + Map enumVar = new HashMap<>(); + String enumName = enumUnknownDefaultCaseName; + + String enumValue; + if (isDataTypeString(dataType)) { + enumValue = enumUnknownDefaultCaseName; + } else { + // This is a dummy value that attempts to avoid collisions with previously specified cases. + // Int.max / 192 + // The number 192 that is used to calculate this random value, is the Swift Evolution proposal for frozen/non-frozen enums. + // [SE-0192](https://github.com/apple/swift-evolution/blob/master/proposals/0192-non-exhaustive-enums.md) + // Since this functionality was born in the Swift 5 generator and latter on broth to all generators + // https://github.com/OpenAPITools/openapi-generator/pull/11013 + enumValue = String.valueOf(11184809); + } + + enumVar.put("name", toEnumVarName(enumName, dataType)); + enumVar.put("value", toEnumValue(enumValue, dataType)); + enumVar.put("isString", isDataTypeString(dataType)); + enumVars.add(enumVar); + } + + return enumVars; } @Override diff --git a/modules/openapi-generator/src/main/resources/python-experimental/model_templates/enum_value_to_name.handlebars b/modules/openapi-generator/src/main/resources/python-experimental/model_templates/enum_value_to_name.handlebars deleted file mode 100644 index 2ed517385a2..00000000000 --- a/modules/openapi-generator/src/main/resources/python-experimental/model_templates/enum_value_to_name.handlebars +++ /dev/null @@ -1,12 +0,0 @@ -schemas.SchemaEnumMakerClsFactory( - enum_value_to_name={ -{{#if isNull}} - schemas.NoneClass.NONE: "NONE", -{{/if}} -{{#with allowableValues}} -{{#each enumVars}} - {{{value}}}: "{{name}}", -{{/each}} -{{/with}} - } -), diff --git a/modules/openapi-generator/src/main/resources/python-experimental/model_templates/enums.handlebars b/modules/openapi-generator/src/main/resources/python-experimental/model_templates/enums.handlebars index 72861be45d6..8c3108e4257 100644 --- a/modules/openapi-generator/src/main/resources/python-experimental/model_templates/enums.handlebars +++ b/modules/openapi-generator/src/main/resources/python-experimental/model_templates/enums.handlebars @@ -1,14 +1,20 @@ -{{#if isNull}} - -@schemas.classproperty -def NONE(cls): - return cls(None) -{{/if}} {{#with allowableValues}} {{#each enumVars}} @schemas.classproperty def {{name}}(cls): + {{#eq value "schemas.NoneClass.NONE"}} + return cls(None) + {{else}} + {{#eq value "schemas.BoolClass.TRUE"}} + return cls(True) + {{else}} + {{#eq value "schemas.BoolClass.FALSE"}} + return cls(False) + {{else}} return cls({{{value}}}) + {{/eq}} + {{/eq}} + {{/eq}} {{/each}} {{/with}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/python-experimental/model_templates/notes_msg.handlebars b/modules/openapi-generator/src/main/resources/python-experimental/model_templates/notes_msg.handlebars index d5d0092ee8f..43d1163b5c0 100644 --- a/modules/openapi-generator/src/main/resources/python-experimental/model_templates/notes_msg.handlebars +++ b/modules/openapi-generator/src/main/resources/python-experimental/model_templates/notes_msg.handlebars @@ -1 +1 @@ -{{#unless isArray}}{{#unless complexType}}{{#with allowableValues}}must be one of [{{#each enumVars}}{{{value}}}, {{/each}}] {{/with}}{{#if defaultValue}}{{#unless hasRequired}}if omitted the server will use the default value of {{{defaultValue}}}{{/unless}}{{/if}}{{#eq getFormat "uuid"}}value must be a uuid{{/eq}}{{#eq getFormat "date"}}value must conform to RFC-3339 full-date YYYY-MM-DD{{/eq}}{{#eq getFormat "date-time"}}value must conform to RFC-3339 date-time{{/eq}}{{#eq getFormat "number"}}value must be numeric and storable in decimal.Decimal{{/eq}}{{#eq getFormat "int32"}}value must be a 32 bit integer{{/eq}}{{#eq getFormat "int64"}}value must be a 64 bit integer{{/eq}}{{#eq getFormat "double"}}value must be a 64 bit float{{/eq}}{{#eq getFormat "float"}}value must be a 32 bit float{{/eq}}{{/unless}}{{/unless}} \ No newline at end of file +{{#unless isArray}}{{#unless complexType}}{{#with allowableValues}}must be one of [{{#each enumVars}}{{#eq value "schemas.NoneClass.NONE"}}None{{else}}{{#eq value "schemas.BoolClass.TRUE"}}True{{else}}{{#eq value "schemas.BoolClass.FALSE"}}False{{else}}{{{value}}}{{/eq}}{{/eq}}{{/eq}}, {{/each}}] {{/with}}{{#if defaultValue}}{{#unless hasRequired}}if omitted the server will use the default value of {{{defaultValue}}}{{/unless}}{{/if}}{{#eq getFormat "uuid"}}value must be a uuid{{/eq}}{{#eq getFormat "date"}}value must conform to RFC-3339 full-date YYYY-MM-DD{{/eq}}{{#eq getFormat "date-time"}}value must conform to RFC-3339 date-time{{/eq}}{{#eq getFormat "number"}}value must be numeric and storable in decimal.Decimal{{/eq}}{{#eq getFormat "int32"}}value must be a 32 bit integer{{/eq}}{{#eq getFormat "int64"}}value must be a 64 bit integer{{/eq}}{{#eq getFormat "double"}}value must be a 64 bit float{{/eq}}{{#eq getFormat "float"}}value must be a 32 bit float{{/eq}}{{/unless}}{{/unless}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/python-experimental/model_templates/schema_composed_or_anytype.handlebars b/modules/openapi-generator/src/main/resources/python-experimental/model_templates/schema_composed_or_anytype.handlebars index a43d5c67e6e..8c7b667493f 100644 --- a/modules/openapi-generator/src/main/resources/python-experimental/model_templates/schema_composed_or_anytype.handlebars +++ b/modules/openapi-generator/src/main/resources/python-experimental/model_templates/schema_composed_or_anytype.handlebars @@ -15,7 +15,7 @@ class {{#if this.classname}}{{classname}}{{else}}{{#if nameInSnakeCase}}{{name}} schemas.ComposedBase, {{/if}} {{#if isEnum}} - {{> model_templates/enum_value_to_name }} + schemas.EnumBase, {{/if}} {{> model_templates/xbase_schema }} {{/if}} @@ -31,13 +31,22 @@ class {{#if this.classname}}{{classname}}{{else}}{{#if nameInSnakeCase}}{{name}} {{/if}} """ {{/if}} -{{#or hasValidation composedSchemas getItems additionalProperties getRequiredVarsMap getHasDiscriminatorWithNonEmptyMapping vars getFormat}} +{{#or hasValidation composedSchemas getItems additionalProperties getRequiredVarsMap getHasDiscriminatorWithNonEmptyMapping vars getFormat isEnum}} class MetaOapg: {{#if getFormat}} format = '{{getFormat}}' {{/if}} +{{#if isEnum}} +{{#with allowableValues}} + enum_value_to_name = { +{{#each enumVars}} + {{{value}}}: "{{name}}", +{{/each}} + } +{{/with}} +{{/if}} {{#if getItems}} {{> model_templates/list_partial }} {{/if}} diff --git a/modules/openapi-generator/src/main/resources/python-experimental/model_templates/schema_simple.handlebars b/modules/openapi-generator/src/main/resources/python-experimental/model_templates/schema_simple.handlebars index b5e7ee24269..0d880043e4f 100644 --- a/modules/openapi-generator/src/main/resources/python-experimental/model_templates/schema_simple.handlebars +++ b/modules/openapi-generator/src/main/resources/python-experimental/model_templates/schema_simple.handlebars @@ -2,7 +2,7 @@ class {{#if this.classname}}{{classname}}{{else}}{{#if nameInSnakeCase}}{{name}}{{else}}{{baseName}}{{/if}}{{/if}}( {{#if isEnum}} - {{> model_templates/enum_value_to_name }} + schemas.EnumBase, {{/if}} {{> model_templates/xbase_schema }} ): @@ -18,12 +18,24 @@ class {{#if this.classname}}{{classname}}{{else}}{{#if nameInSnakeCase}}{{name}} """ {{/if}} {{#unless isStub}} -{{#if hasValidation}} +{{#or hasValidation isEnum getFormat}} class MetaOapg: - {{> model_templates/validations }} +{{#if getFormat}} + format = '{{getFormat}}' {{/if}} + {{> model_templates/validations }} +{{#if isEnum}} +{{#with allowableValues}} + enum_value_to_name = { +{{#each enumVars}} + {{{value}}}: "{{name}}", +{{/each}} + } +{{/with}} +{{/if}} +{{/or}} {{/unless}} {{#if isEnum}} {{> model_templates/enums }} diff --git a/modules/openapi-generator/src/main/resources/python-experimental/schemas.handlebars b/modules/openapi-generator/src/main/resources/python-experimental/schemas.handlebars index 7da16df2269..c251e24552c 100644 --- a/modules/openapi-generator/src/main/resources/python-experimental/schemas.handlebars +++ b/modules/openapi-generator/src/main/resources/python-experimental/schemas.handlebars @@ -404,7 +404,7 @@ class Schema: """ cls._process_schema_classes_oapg(schema_classes) enum_schema = any( - hasattr(this_cls, '_enum_value_to_name') for this_cls in schema_classes) + issubclass(this_cls, EnumBase) for this_cls in schema_classes) inheritable_primitive_type = schema_classes.intersection(cls.__inheritable_primitive_types_set) chosen_schema_classes = schema_classes - inheritable_primitive_type suffix = tuple(inheritable_primitive_type) @@ -873,41 +873,22 @@ class ValidatorBase: ) -class EnumMakerBase: - pass - - -def SchemaEnumMakerClsFactory(enum_value_to_name: typing.Dict[typing.Union[str, decimal.Decimal, bool, none_type], str]) -> 'SchemaEnumMaker': - class SchemaEnumMaker(EnumMakerBase): - @classmethod - def _enum_value_to_name( - cls - ) -> typing.Dict[typing.Union[str, decimal.Decimal, bool, none_type], str]: - pass - try: - super_enum_value_to_name = super()._enum_value_to_name() - except AttributeError: - return enum_value_to_name - intersection = dict(enum_value_to_name.items() & super_enum_value_to_name.items()) - return intersection - - @classmethod - def _validate_oapg( - cls, - arg, - validation_metadata: ValidationMetadata, - ) -> typing.Dict[typing.Tuple[typing.Union[str, int], ...], typing.Set[typing.Union['Schema', str, decimal.Decimal, BoolClass, NoneClass, frozendict.frozendict, tuple]]]: - """ - SchemaEnumMaker _validate_oapg - Validates that arg is in the enum's allowed values - """ - try: - cls._enum_value_to_name()[arg] - except KeyError: - raise ApiValueError("Invalid value {} passed in to {}, {}".format(arg, cls, cls._enum_value_to_name())) - return super()._validate_oapg(arg, validation_metadata=validation_metadata) - - return SchemaEnumMaker +class EnumBase: + @classmethod + def _validate_oapg( + cls, + arg, + validation_metadata: ValidationMetadata, + ) -> typing.Dict[typing.Tuple[typing.Union[str, int], ...], typing.Set[typing.Union['Schema', str, decimal.Decimal, BoolClass, NoneClass, frozendict.frozendict, tuple]]]: + """ + EnumBase _validate_oapg + Validates that arg is in the enum's allowed values + """ + try: + cls.MetaOapg.enum_value_to_name[arg] + except KeyError: + raise ApiValueError("Invalid value {} passed in to {}, allowed_values={}".format(arg, cls, cls.MetaOapg.enum_value_to_name.keys())) + return super()._validate_oapg(arg, validation_metadata=validation_metadata) class BoolBase: diff --git a/modules/openapi-generator/src/test/resources/3_0/python-experimental/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml b/modules/openapi-generator/src/test/resources/3_0/python-experimental/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml index 8868f602389..3357b0ae118 100644 --- a/modules/openapi-generator/src/test/resources/3_0/python-experimental/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml +++ b/modules/openapi-generator/src/test/resources/3_0/python-experimental/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml @@ -2224,6 +2224,7 @@ components: multiple lines - "double quote \n with newline" + - null IntegerEnum: type: integer enum: diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/models/EnumWithFalseDoesNotMatch0.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/models/EnumWithFalseDoesNotMatch0.md index 1b689953a35..19b1b49815d 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/models/EnumWithFalseDoesNotMatch0.md +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/models/EnumWithFalseDoesNotMatch0.md @@ -3,7 +3,7 @@ ## Model Type Info Input Type | Accessed Type | Description | Notes ------------ | ------------- | ------------- | ------------- -bool, | BoolClass, | | must be one of [schemas.BoolClass.FALSE, ] +bool, | BoolClass, | | must be one of [False, ] [[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/3_0_3_unit_test/python-experimental/docs/models/EnumWithTrueDoesNotMatch1.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/models/EnumWithTrueDoesNotMatch1.md index 4ddd5d9093a..469529fa841 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/models/EnumWithTrueDoesNotMatch1.md +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/models/EnumWithTrueDoesNotMatch1.md @@ -3,7 +3,7 @@ ## Model Type Info Input Type | Accessed Type | Description | Notes ------------ | ------------- | ------------- | ------------- -bool, | BoolClass, | | must be one of [schemas.BoolClass.TRUE, ] +bool, | BoolClass, | | must be one of [True, ] [[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/3_0_3_unit_test/python-experimental/unit_test_api/model/enum_with0_does_not_match_false.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enum_with0_does_not_match_false.py index 8a04dd018df..2f77c5996f4 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enum_with0_does_not_match_false.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enum_with0_does_not_match_false.py @@ -24,11 +24,7 @@ from unit_test_api import schemas # noqa: F401 class EnumWith0DoesNotMatchFalse( - schemas.SchemaEnumMakerClsFactory( - enum_value_to_name={ - 0: "POSITIVE_0", - } - ), + schemas.EnumBase, schemas.NumberSchema ): """NOTE: This class is auto generated by OpenAPI Generator. @@ -36,6 +32,12 @@ class EnumWith0DoesNotMatchFalse( Do not edit the class manually. """ + + + class MetaOapg: + enum_value_to_name = { + 0: "POSITIVE_0", + } @schemas.classproperty def POSITIVE_0(cls): diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enum_with0_does_not_match_false.pyi b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enum_with0_does_not_match_false.pyi index 8a04dd018df..337edc4956d 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enum_with0_does_not_match_false.pyi +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enum_with0_does_not_match_false.pyi @@ -24,11 +24,7 @@ from unit_test_api import schemas # noqa: F401 class EnumWith0DoesNotMatchFalse( - schemas.SchemaEnumMakerClsFactory( - enum_value_to_name={ - 0: "POSITIVE_0", - } - ), + schemas.EnumBase, schemas.NumberSchema ): """NOTE: This class is auto generated by OpenAPI Generator. diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enum_with1_does_not_match_true.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enum_with1_does_not_match_true.py index 078b9e19aa6..2acbb376d63 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enum_with1_does_not_match_true.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enum_with1_does_not_match_true.py @@ -24,11 +24,7 @@ from unit_test_api import schemas # noqa: F401 class EnumWith1DoesNotMatchTrue( - schemas.SchemaEnumMakerClsFactory( - enum_value_to_name={ - 1: "POSITIVE_1", - } - ), + schemas.EnumBase, schemas.NumberSchema ): """NOTE: This class is auto generated by OpenAPI Generator. @@ -36,6 +32,12 @@ class EnumWith1DoesNotMatchTrue( Do not edit the class manually. """ + + + class MetaOapg: + enum_value_to_name = { + 1: "POSITIVE_1", + } @schemas.classproperty def POSITIVE_1(cls): diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enum_with1_does_not_match_true.pyi b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enum_with1_does_not_match_true.pyi index 078b9e19aa6..8664a7f747f 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enum_with1_does_not_match_true.pyi +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enum_with1_does_not_match_true.pyi @@ -24,11 +24,7 @@ from unit_test_api import schemas # noqa: F401 class EnumWith1DoesNotMatchTrue( - schemas.SchemaEnumMakerClsFactory( - enum_value_to_name={ - 1: "POSITIVE_1", - } - ), + schemas.EnumBase, schemas.NumberSchema ): """NOTE: This class is auto generated by OpenAPI Generator. diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enum_with_escaped_characters.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enum_with_escaped_characters.py index bf03d2da8b4..c8f68c1000d 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enum_with_escaped_characters.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enum_with_escaped_characters.py @@ -24,12 +24,7 @@ from unit_test_api import schemas # noqa: F401 class EnumWithEscapedCharacters( - schemas.SchemaEnumMakerClsFactory( - enum_value_to_name={ - "foo\nbar": "FOO_BAR", - "foo\rbar": "FOO_BAR", - } - ), + schemas.EnumBase, schemas.StrSchema ): """NOTE: This class is auto generated by OpenAPI Generator. @@ -37,6 +32,13 @@ class EnumWithEscapedCharacters( Do not edit the class manually. """ + + + class MetaOapg: + enum_value_to_name = { + "foo\nbar": "FOO_BAR", + "foo\rbar": "FOO_BAR", + } @schemas.classproperty def FOO_BAR(cls): diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enum_with_escaped_characters.pyi b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enum_with_escaped_characters.pyi index bf03d2da8b4..6fb1827e441 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enum_with_escaped_characters.pyi +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enum_with_escaped_characters.pyi @@ -24,12 +24,7 @@ from unit_test_api import schemas # noqa: F401 class EnumWithEscapedCharacters( - schemas.SchemaEnumMakerClsFactory( - enum_value_to_name={ - "foo\nbar": "FOO_BAR", - "foo\rbar": "FOO_BAR", - } - ), + schemas.EnumBase, schemas.StrSchema ): """NOTE: This class is auto generated by OpenAPI Generator. diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enum_with_false_does_not_match0.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enum_with_false_does_not_match0.py index 232e3dc37b8..c4992b57a35 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enum_with_false_does_not_match0.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enum_with_false_does_not_match0.py @@ -24,11 +24,7 @@ from unit_test_api import schemas # noqa: F401 class EnumWithFalseDoesNotMatch0( - schemas.SchemaEnumMakerClsFactory( - enum_value_to_name={ - schemas.BoolClass.FALSE: "FALSE", - } - ), + schemas.EnumBase, schemas.BoolSchema ): """NOTE: This class is auto generated by OpenAPI Generator. @@ -36,7 +32,13 @@ class EnumWithFalseDoesNotMatch0( Do not edit the class manually. """ + + + class MetaOapg: + enum_value_to_name = { + schemas.BoolClass.FALSE: "FALSE", + } @schemas.classproperty def FALSE(cls): - return cls(schemas.BoolClass.FALSE) + return cls(False) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enum_with_false_does_not_match0.pyi b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enum_with_false_does_not_match0.pyi index 232e3dc37b8..35ef43076ce 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enum_with_false_does_not_match0.pyi +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enum_with_false_does_not_match0.pyi @@ -24,11 +24,7 @@ from unit_test_api import schemas # noqa: F401 class EnumWithFalseDoesNotMatch0( - schemas.SchemaEnumMakerClsFactory( - enum_value_to_name={ - schemas.BoolClass.FALSE: "FALSE", - } - ), + schemas.EnumBase, schemas.BoolSchema ): """NOTE: This class is auto generated by OpenAPI Generator. @@ -39,4 +35,4 @@ class EnumWithFalseDoesNotMatch0( @schemas.classproperty def FALSE(cls): - return cls(schemas.BoolClass.FALSE) + return cls(False) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enum_with_true_does_not_match1.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enum_with_true_does_not_match1.py index f2dd03ea78e..a8e80747103 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enum_with_true_does_not_match1.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enum_with_true_does_not_match1.py @@ -24,11 +24,7 @@ from unit_test_api import schemas # noqa: F401 class EnumWithTrueDoesNotMatch1( - schemas.SchemaEnumMakerClsFactory( - enum_value_to_name={ - schemas.BoolClass.TRUE: "TRUE", - } - ), + schemas.EnumBase, schemas.BoolSchema ): """NOTE: This class is auto generated by OpenAPI Generator. @@ -36,7 +32,13 @@ class EnumWithTrueDoesNotMatch1( Do not edit the class manually. """ + + + class MetaOapg: + enum_value_to_name = { + schemas.BoolClass.TRUE: "TRUE", + } @schemas.classproperty def TRUE(cls): - return cls(schemas.BoolClass.TRUE) + return cls(True) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enum_with_true_does_not_match1.pyi b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enum_with_true_does_not_match1.pyi index f2dd03ea78e..f86fc0d2810 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enum_with_true_does_not_match1.pyi +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enum_with_true_does_not_match1.pyi @@ -24,11 +24,7 @@ from unit_test_api import schemas # noqa: F401 class EnumWithTrueDoesNotMatch1( - schemas.SchemaEnumMakerClsFactory( - enum_value_to_name={ - schemas.BoolClass.TRUE: "TRUE", - } - ), + schemas.EnumBase, schemas.BoolSchema ): """NOTE: This class is auto generated by OpenAPI Generator. @@ -39,4 +35,4 @@ class EnumWithTrueDoesNotMatch1( @schemas.classproperty def TRUE(cls): - return cls(schemas.BoolClass.TRUE) + return cls(True) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enums_in_properties.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enums_in_properties.py index 87c87f94b6d..0010f712aba 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enums_in_properties.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enums_in_properties.py @@ -42,13 +42,15 @@ class EnumsInProperties( class bar( - schemas.SchemaEnumMakerClsFactory( - enum_value_to_name={ - "bar": "BAR", - } - ), + schemas.EnumBase, schemas.StrSchema ): + + + class MetaOapg: + enum_value_to_name = { + "bar": "BAR", + } @schemas.classproperty def BAR(cls): @@ -56,13 +58,15 @@ class EnumsInProperties( class foo( - schemas.SchemaEnumMakerClsFactory( - enum_value_to_name={ - "foo": "FOO", - } - ), + schemas.EnumBase, schemas.StrSchema ): + + + class MetaOapg: + enum_value_to_name = { + "foo": "FOO", + } @schemas.classproperty def FOO(cls): diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enums_in_properties.pyi b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enums_in_properties.pyi index 87c87f94b6d..d45a82aad04 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enums_in_properties.pyi +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enums_in_properties.pyi @@ -42,11 +42,7 @@ class EnumsInProperties( class bar( - schemas.SchemaEnumMakerClsFactory( - enum_value_to_name={ - "bar": "BAR", - } - ), + schemas.EnumBase, schemas.StrSchema ): @@ -56,11 +52,7 @@ class EnumsInProperties( class foo( - schemas.SchemaEnumMakerClsFactory( - enum_value_to_name={ - "foo": "FOO", - } - ), + schemas.EnumBase, schemas.StrSchema ): diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/nul_characters_in_strings.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/nul_characters_in_strings.py index 02c363ec5f4..3aa6a9fe9ba 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/nul_characters_in_strings.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/nul_characters_in_strings.py @@ -24,11 +24,7 @@ from unit_test_api import schemas # noqa: F401 class NulCharactersInStrings( - schemas.SchemaEnumMakerClsFactory( - enum_value_to_name={ - "hello\x00there": "HELLOTHERE", - } - ), + schemas.EnumBase, schemas.StrSchema ): """NOTE: This class is auto generated by OpenAPI Generator. @@ -36,6 +32,12 @@ class NulCharactersInStrings( Do not edit the class manually. """ + + + class MetaOapg: + enum_value_to_name = { + "hello\x00there": "HELLOTHERE", + } @schemas.classproperty def HELLOTHERE(cls): diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/nul_characters_in_strings.pyi b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/nul_characters_in_strings.pyi index 02c363ec5f4..eb9d42800cf 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/nul_characters_in_strings.pyi +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/nul_characters_in_strings.pyi @@ -24,11 +24,7 @@ from unit_test_api import schemas # noqa: F401 class NulCharactersInStrings( - schemas.SchemaEnumMakerClsFactory( - enum_value_to_name={ - "hello\x00there": "HELLOTHERE", - } - ), + schemas.EnumBase, schemas.StrSchema ): """NOTE: This class is auto generated by OpenAPI Generator. diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/simple_enum_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/simple_enum_validation.py index bfa9cd3e29c..26641b8c99f 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/simple_enum_validation.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/simple_enum_validation.py @@ -24,13 +24,7 @@ from unit_test_api import schemas # noqa: F401 class SimpleEnumValidation( - schemas.SchemaEnumMakerClsFactory( - enum_value_to_name={ - 1: "POSITIVE_1", - 2: "POSITIVE_2", - 3: "POSITIVE_3", - } - ), + schemas.EnumBase, schemas.NumberSchema ): """NOTE: This class is auto generated by OpenAPI Generator. @@ -38,6 +32,14 @@ class SimpleEnumValidation( Do not edit the class manually. """ + + + class MetaOapg: + enum_value_to_name = { + 1: "POSITIVE_1", + 2: "POSITIVE_2", + 3: "POSITIVE_3", + } @schemas.classproperty def POSITIVE_1(cls): diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/simple_enum_validation.pyi b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/simple_enum_validation.pyi index bfa9cd3e29c..61ed175912c 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/simple_enum_validation.pyi +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/simple_enum_validation.pyi @@ -24,13 +24,7 @@ from unit_test_api import schemas # noqa: F401 class SimpleEnumValidation( - schemas.SchemaEnumMakerClsFactory( - enum_value_to_name={ - 1: "POSITIVE_1", - 2: "POSITIVE_2", - 3: "POSITIVE_3", - } - ), + schemas.EnumBase, schemas.NumberSchema ): """NOTE: This class is auto generated by OpenAPI Generator. diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/schemas.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/schemas.py index b9539f2c244..3ffd38e7cf9 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/schemas.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/schemas.py @@ -411,7 +411,7 @@ class Schema: """ cls._process_schema_classes_oapg(schema_classes) enum_schema = any( - hasattr(this_cls, '_enum_value_to_name') for this_cls in schema_classes) + issubclass(this_cls, EnumBase) for this_cls in schema_classes) inheritable_primitive_type = schema_classes.intersection(cls.__inheritable_primitive_types_set) chosen_schema_classes = schema_classes - inheritable_primitive_type suffix = tuple(inheritable_primitive_type) @@ -880,41 +880,22 @@ class ValidatorBase: ) -class EnumMakerBase: - pass - - -def SchemaEnumMakerClsFactory(enum_value_to_name: typing.Dict[typing.Union[str, decimal.Decimal, bool, none_type], str]) -> 'SchemaEnumMaker': - class SchemaEnumMaker(EnumMakerBase): - @classmethod - def _enum_value_to_name( - cls - ) -> typing.Dict[typing.Union[str, decimal.Decimal, bool, none_type], str]: - pass - try: - super_enum_value_to_name = super()._enum_value_to_name() - except AttributeError: - return enum_value_to_name - intersection = dict(enum_value_to_name.items() & super_enum_value_to_name.items()) - return intersection - - @classmethod - def _validate_oapg( - cls, - arg, - validation_metadata: ValidationMetadata, - ) -> typing.Dict[typing.Tuple[typing.Union[str, int], ...], typing.Set[typing.Union['Schema', str, decimal.Decimal, BoolClass, NoneClass, frozendict.frozendict, tuple]]]: - """ - SchemaEnumMaker _validate_oapg - Validates that arg is in the enum's allowed values - """ - try: - cls._enum_value_to_name()[arg] - except KeyError: - raise ApiValueError("Invalid value {} passed in to {}, {}".format(arg, cls, cls._enum_value_to_name())) - return super()._validate_oapg(arg, validation_metadata=validation_metadata) - - return SchemaEnumMaker +class EnumBase: + @classmethod + def _validate_oapg( + cls, + arg, + validation_metadata: ValidationMetadata, + ) -> typing.Dict[typing.Tuple[typing.Union[str, int], ...], typing.Set[typing.Union['Schema', str, decimal.Decimal, BoolClass, NoneClass, frozendict.frozendict, tuple]]]: + """ + EnumBase _validate_oapg + Validates that arg is in the enum's allowed values + """ + try: + cls.MetaOapg.enum_value_to_name[arg] + except KeyError: + raise ApiValueError("Invalid value {} passed in to {}, allowed_values={}".format(arg, cls, cls.MetaOapg.enum_value_to_name.keys())) + return super()._validate_oapg(arg, validation_metadata=validation_metadata) class BoolBase: diff --git a/samples/openapi3/client/petstore/python-experimental/docs/models/BooleanEnum.md b/samples/openapi3/client/petstore/python-experimental/docs/models/BooleanEnum.md index 5d807cf82d5..a84330415cb 100644 --- a/samples/openapi3/client/petstore/python-experimental/docs/models/BooleanEnum.md +++ b/samples/openapi3/client/petstore/python-experimental/docs/models/BooleanEnum.md @@ -3,7 +3,7 @@ ## Model Type Info Input Type | Accessed Type | Description | Notes ------------ | ------------- | ------------- | ------------- -bool, | BoolClass, | | must be one of [schemas.BoolClass.TRUE, ] +bool, | BoolClass, | | must be one of [True, ] [[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-experimental/docs/models/StringEnum.md b/samples/openapi3/client/petstore/python-experimental/docs/models/StringEnum.md index 219962d2054..06c26a7a1ac 100644 --- a/samples/openapi3/client/petstore/python-experimental/docs/models/StringEnum.md +++ b/samples/openapi3/client/petstore/python-experimental/docs/models/StringEnum.md @@ -3,7 +3,7 @@ ## Model Type Info Input Type | Accessed Type | Description | Notes ------------ | ------------- | ------------- | ------------- -None, str, | NoneClass, str, | | must be one of ["placed", "approved", "delivered", "single quoted", "multiple\nlines", "double quote \n with newline", ] +None, str, | NoneClass, str, | | must be one of ["placed", "approved", "delivered", "single quoted", "multiple\nlines", "double quote \n with newline", None, ] [[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-experimental/petstore_api/model/array_with_validations_in_items.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/array_with_validations_in_items.py index bfa5fe4afc9..f68cb1a4c27 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/array_with_validations_in_items.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/array_with_validations_in_items.py @@ -43,6 +43,7 @@ class ArrayWithValidationsInItems( class MetaOapg: + format = 'int64' inclusive_maximum = 7 def __new__( diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/basque_pig.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/basque_pig.py index 761184a89c4..528cfa498b0 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/basque_pig.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/basque_pig.py @@ -42,13 +42,15 @@ class BasquePig( class className( - schemas.SchemaEnumMakerClsFactory( - enum_value_to_name={ - "BasquePig": "BASQUE_PIG", - } - ), + schemas.EnumBase, schemas.StrSchema ): + + + class MetaOapg: + enum_value_to_name = { + "BasquePig": "BASQUE_PIG", + } @schemas.classproperty def BASQUE_PIG(cls): diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/basque_pig.pyi b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/basque_pig.pyi index 761184a89c4..8b36451f849 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/basque_pig.pyi +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/basque_pig.pyi @@ -42,11 +42,7 @@ class BasquePig( class className( - schemas.SchemaEnumMakerClsFactory( - enum_value_to_name={ - "BasquePig": "BASQUE_PIG", - } - ), + schemas.EnumBase, schemas.StrSchema ): diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/boolean_enum.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/boolean_enum.py index 7f98942e76d..66d5be71312 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/boolean_enum.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/boolean_enum.py @@ -24,11 +24,7 @@ from petstore_api import schemas # noqa: F401 class BooleanEnum( - schemas.SchemaEnumMakerClsFactory( - enum_value_to_name={ - schemas.BoolClass.TRUE: "TRUE", - } - ), + schemas.EnumBase, schemas.BoolSchema ): """NOTE: This class is auto generated by OpenAPI Generator. @@ -36,7 +32,13 @@ class BooleanEnum( Do not edit the class manually. """ + + + class MetaOapg: + enum_value_to_name = { + schemas.BoolClass.TRUE: "TRUE", + } @schemas.classproperty def TRUE(cls): - return cls(schemas.BoolClass.TRUE) + return cls(True) diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/boolean_enum.pyi b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/boolean_enum.pyi index 7f98942e76d..69fe2e6af4e 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/boolean_enum.pyi +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/boolean_enum.pyi @@ -24,11 +24,7 @@ from petstore_api import schemas # noqa: F401 class BooleanEnum( - schemas.SchemaEnumMakerClsFactory( - enum_value_to_name={ - schemas.BoolClass.TRUE: "TRUE", - } - ), + schemas.EnumBase, schemas.BoolSchema ): """NOTE: This class is auto generated by OpenAPI Generator. @@ -39,4 +35,4 @@ class BooleanEnum( @schemas.classproperty def TRUE(cls): - return cls(schemas.BoolClass.TRUE) + return cls(True) diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/complex_quadrilateral.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/complex_quadrilateral.py index 4cf54c5ff04..434c2c0c77a 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/complex_quadrilateral.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/complex_quadrilateral.py @@ -47,13 +47,15 @@ class ComplexQuadrilateral( class quadrilateralType( - schemas.SchemaEnumMakerClsFactory( - enum_value_to_name={ - "ComplexQuadrilateral": "COMPLEX_QUADRILATERAL", - } - ), + schemas.EnumBase, schemas.StrSchema ): + + + class MetaOapg: + enum_value_to_name = { + "ComplexQuadrilateral": "COMPLEX_QUADRILATERAL", + } @schemas.classproperty def COMPLEX_QUADRILATERAL(cls): diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/complex_quadrilateral.pyi b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/complex_quadrilateral.pyi index 4cf54c5ff04..43d8724caa8 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/complex_quadrilateral.pyi +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/complex_quadrilateral.pyi @@ -47,11 +47,7 @@ class ComplexQuadrilateral( class quadrilateralType( - schemas.SchemaEnumMakerClsFactory( - enum_value_to_name={ - "ComplexQuadrilateral": "COMPLEX_QUADRILATERAL", - } - ), + schemas.EnumBase, schemas.StrSchema ): diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/composed_one_of_different_types.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/composed_one_of_different_types.py index 790afa263ea..b3cf4aea1c4 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/composed_one_of_different_types.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/composed_one_of_different_types.py @@ -94,6 +94,7 @@ class ComposedOneOfDifferentTypes( class MetaOapg: + format = 'date-time' regex=[{ 'pattern': r'^2020.*', # noqa: E501 }] diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/currency.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/currency.py index e1869aac84e..8714c9adcc7 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/currency.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/currency.py @@ -24,12 +24,7 @@ from petstore_api import schemas # noqa: F401 class Currency( - schemas.SchemaEnumMakerClsFactory( - enum_value_to_name={ - "eur": "EUR", - "usd": "USD", - } - ), + schemas.EnumBase, schemas.StrSchema ): """NOTE: This class is auto generated by OpenAPI Generator. @@ -37,6 +32,13 @@ class Currency( Do not edit the class manually. """ + + + class MetaOapg: + enum_value_to_name = { + "eur": "EUR", + "usd": "USD", + } @schemas.classproperty def EUR(cls): diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/currency.pyi b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/currency.pyi index e1869aac84e..7706629add2 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/currency.pyi +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/currency.pyi @@ -24,12 +24,7 @@ from petstore_api import schemas # noqa: F401 class Currency( - schemas.SchemaEnumMakerClsFactory( - enum_value_to_name={ - "eur": "EUR", - "usd": "USD", - } - ), + schemas.EnumBase, schemas.StrSchema ): """NOTE: This class is auto generated by OpenAPI Generator. diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/danish_pig.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/danish_pig.py index 119950e031d..bcffd8ff006 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/danish_pig.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/danish_pig.py @@ -42,13 +42,15 @@ class DanishPig( class className( - schemas.SchemaEnumMakerClsFactory( - enum_value_to_name={ - "DanishPig": "DANISH_PIG", - } - ), + schemas.EnumBase, schemas.StrSchema ): + + + class MetaOapg: + enum_value_to_name = { + "DanishPig": "DANISH_PIG", + } @schemas.classproperty def DANISH_PIG(cls): diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/danish_pig.pyi b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/danish_pig.pyi index 119950e031d..9f64db82744 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/danish_pig.pyi +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/danish_pig.pyi @@ -42,11 +42,7 @@ class DanishPig( class className( - schemas.SchemaEnumMakerClsFactory( - enum_value_to_name={ - "DanishPig": "DANISH_PIG", - } - ), + schemas.EnumBase, schemas.StrSchema ): diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/date_time_with_validations.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/date_time_with_validations.py index 8d9eaf992be..a5a7858195a 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/date_time_with_validations.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/date_time_with_validations.py @@ -34,6 +34,7 @@ class DateTimeWithValidations( class MetaOapg: + format = 'date-time' regex=[{ 'pattern': r'^2020.*', # noqa: E501 }] diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/date_with_validations.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/date_with_validations.py index 45d5ba99459..82d0122a279 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/date_with_validations.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/date_with_validations.py @@ -34,6 +34,7 @@ class DateWithValidations( class MetaOapg: + format = 'date' regex=[{ 'pattern': r'^2020.*', # noqa: E501 }] diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/enum_arrays.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/enum_arrays.py index 0c2e685bcaf..1e7e0843da1 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/enum_arrays.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/enum_arrays.py @@ -39,14 +39,16 @@ class EnumArrays( class just_symbol( - schemas.SchemaEnumMakerClsFactory( - enum_value_to_name={ + schemas.EnumBase, + schemas.StrSchema + ): + + + class MetaOapg: + enum_value_to_name = { ">=": "GREATER_THAN_EQUALS", "$": "DOLLAR", } - ), - schemas.StrSchema - ): @schemas.classproperty def GREATER_THAN_EQUALS(cls): @@ -66,14 +68,16 @@ class EnumArrays( class items( - schemas.SchemaEnumMakerClsFactory( - enum_value_to_name={ + schemas.EnumBase, + schemas.StrSchema + ): + + + class MetaOapg: + enum_value_to_name = { "fish": "FISH", "crab": "CRAB", } - ), - schemas.StrSchema - ): @schemas.classproperty def FISH(cls): diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/enum_arrays.pyi b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/enum_arrays.pyi index 0c2e685bcaf..31b854f7d16 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/enum_arrays.pyi +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/enum_arrays.pyi @@ -39,12 +39,7 @@ class EnumArrays( class just_symbol( - schemas.SchemaEnumMakerClsFactory( - enum_value_to_name={ - ">=": "GREATER_THAN_EQUALS", - "$": "DOLLAR", - } - ), + schemas.EnumBase, schemas.StrSchema ): @@ -66,12 +61,7 @@ class EnumArrays( class items( - schemas.SchemaEnumMakerClsFactory( - enum_value_to_name={ - "fish": "FISH", - "crab": "CRAB", - } - ), + schemas.EnumBase, schemas.StrSchema ): diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/enum_class.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/enum_class.py index 8addfe28920..27018e19a6d 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/enum_class.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/enum_class.py @@ -24,15 +24,7 @@ from petstore_api import schemas # noqa: F401 class EnumClass( - schemas.SchemaEnumMakerClsFactory( - enum_value_to_name={ - "_abc": "_ABC", - "-efg": "EFG", - "(xyz)": "XYZ", - "COUNT_1M": "COUNT_1M", - "COUNT_50M": "COUNT_50M", - } - ), + schemas.EnumBase, schemas.StrSchema ): """NOTE: This class is auto generated by OpenAPI Generator. @@ -40,6 +32,16 @@ class EnumClass( Do not edit the class manually. """ + + + class MetaOapg: + enum_value_to_name = { + "_abc": "_ABC", + "-efg": "EFG", + "(xyz)": "XYZ", + "COUNT_1M": "COUNT_1M", + "COUNT_50M": "COUNT_50M", + } @schemas.classproperty def _ABC(cls): diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/enum_class.pyi b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/enum_class.pyi index 8addfe28920..7d43347fd84 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/enum_class.pyi +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/enum_class.pyi @@ -24,15 +24,7 @@ from petstore_api import schemas # noqa: F401 class EnumClass( - schemas.SchemaEnumMakerClsFactory( - enum_value_to_name={ - "_abc": "_ABC", - "-efg": "EFG", - "(xyz)": "XYZ", - "COUNT_1M": "COUNT_1M", - "COUNT_50M": "COUNT_50M", - } - ), + schemas.EnumBase, schemas.StrSchema ): """NOTE: This class is auto generated by OpenAPI Generator. diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/enum_test.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/enum_test.py index d96902e0d12..094073cddc7 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/enum_test.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/enum_test.py @@ -42,15 +42,17 @@ class EnumTest( class enum_string_required( - schemas.SchemaEnumMakerClsFactory( - enum_value_to_name={ + schemas.EnumBase, + schemas.StrSchema + ): + + + class MetaOapg: + enum_value_to_name = { "UPPER": "UPPER", "lower": "LOWER", "": "EMPTY", } - ), - schemas.StrSchema - ): @schemas.classproperty def UPPER(cls): @@ -66,15 +68,17 @@ class EnumTest( class enum_string( - schemas.SchemaEnumMakerClsFactory( - enum_value_to_name={ + schemas.EnumBase, + schemas.StrSchema + ): + + + class MetaOapg: + enum_value_to_name = { "UPPER": "UPPER", "lower": "LOWER", "": "EMPTY", } - ), - schemas.StrSchema - ): @schemas.classproperty def UPPER(cls): @@ -90,14 +94,17 @@ class EnumTest( class enum_integer( - schemas.SchemaEnumMakerClsFactory( - enum_value_to_name={ + schemas.EnumBase, + schemas.Int32Schema + ): + + + class MetaOapg: + format = 'int32' + enum_value_to_name = { 1: "POSITIVE_1", -1: "NEGATIVE_1", } - ), - schemas.Int32Schema - ): @schemas.classproperty def POSITIVE_1(cls): @@ -109,14 +116,17 @@ class EnumTest( class enum_number( - schemas.SchemaEnumMakerClsFactory( - enum_value_to_name={ + schemas.EnumBase, + schemas.Float64Schema + ): + + + class MetaOapg: + format = 'double' + enum_value_to_name = { 1.1: "POSITIVE_1_PT_1", -1.2: "NEGATIVE_1_PT_2", } - ), - schemas.Float64Schema - ): @schemas.classproperty def POSITIVE_1_PT_1(cls): diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/enum_test.pyi b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/enum_test.pyi index d96902e0d12..1f885dcf361 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/enum_test.pyi +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/enum_test.pyi @@ -42,13 +42,7 @@ class EnumTest( class enum_string_required( - schemas.SchemaEnumMakerClsFactory( - enum_value_to_name={ - "UPPER": "UPPER", - "lower": "LOWER", - "": "EMPTY", - } - ), + schemas.EnumBase, schemas.StrSchema ): @@ -66,13 +60,7 @@ class EnumTest( class enum_string( - schemas.SchemaEnumMakerClsFactory( - enum_value_to_name={ - "UPPER": "UPPER", - "lower": "LOWER", - "": "EMPTY", - } - ), + schemas.EnumBase, schemas.StrSchema ): @@ -90,12 +78,7 @@ class EnumTest( class enum_integer( - schemas.SchemaEnumMakerClsFactory( - enum_value_to_name={ - 1: "POSITIVE_1", - -1: "NEGATIVE_1", - } - ), + schemas.EnumBase, schemas.Int32Schema ): @@ -109,12 +92,7 @@ class EnumTest( class enum_number( - schemas.SchemaEnumMakerClsFactory( - enum_value_to_name={ - 1.1: "POSITIVE_1_PT_1", - -1.2: "NEGATIVE_1_PT_2", - } - ), + schemas.EnumBase, schemas.Float64Schema ): diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/equilateral_triangle.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/equilateral_triangle.py index c184a9de47e..a45ac99de80 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/equilateral_triangle.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/equilateral_triangle.py @@ -47,13 +47,15 @@ class EquilateralTriangle( class triangleType( - schemas.SchemaEnumMakerClsFactory( - enum_value_to_name={ - "EquilateralTriangle": "EQUILATERAL_TRIANGLE", - } - ), + schemas.EnumBase, schemas.StrSchema ): + + + class MetaOapg: + enum_value_to_name = { + "EquilateralTriangle": "EQUILATERAL_TRIANGLE", + } @schemas.classproperty def EQUILATERAL_TRIANGLE(cls): diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/equilateral_triangle.pyi b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/equilateral_triangle.pyi index c184a9de47e..7e9d4d38025 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/equilateral_triangle.pyi +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/equilateral_triangle.pyi @@ -47,11 +47,7 @@ class EquilateralTriangle( class triangleType( - schemas.SchemaEnumMakerClsFactory( - enum_value_to_name={ - "EquilateralTriangle": "EQUILATERAL_TRIANGLE", - } - ), + schemas.EnumBase, schemas.StrSchema ): diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/format_test.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/format_test.py index 7f99f5b51ec..b16b10a0488 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/format_test.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/format_test.py @@ -63,6 +63,7 @@ class FormatTest( class MetaOapg: + format = 'password' max_length = 64 min_length = 10 @@ -85,6 +86,7 @@ class FormatTest( class MetaOapg: + format = 'int32' inclusive_maximum = 200 inclusive_minimum = 20 int64 = schemas.Int64Schema @@ -96,6 +98,7 @@ class FormatTest( class MetaOapg: + format = 'float' inclusive_maximum = 987.6 inclusive_minimum = 54.3 float32 = schemas.Float32Schema @@ -107,6 +110,7 @@ class FormatTest( class MetaOapg: + format = 'double' inclusive_maximum = 123.4 inclusive_minimum = 67.8 float64 = schemas.Float64Schema diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/integer_enum.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/integer_enum.py index fa53ad2959f..18cd8df6434 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/integer_enum.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/integer_enum.py @@ -24,13 +24,7 @@ from petstore_api import schemas # noqa: F401 class IntegerEnum( - schemas.SchemaEnumMakerClsFactory( - enum_value_to_name={ - 0: "POSITIVE_0", - 1: "POSITIVE_1", - 2: "POSITIVE_2", - } - ), + schemas.EnumBase, schemas.IntSchema ): """NOTE: This class is auto generated by OpenAPI Generator. @@ -38,6 +32,14 @@ class IntegerEnum( Do not edit the class manually. """ + + + class MetaOapg: + enum_value_to_name = { + 0: "POSITIVE_0", + 1: "POSITIVE_1", + 2: "POSITIVE_2", + } @schemas.classproperty def POSITIVE_0(cls): diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/integer_enum.pyi b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/integer_enum.pyi index fa53ad2959f..5f88412337f 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/integer_enum.pyi +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/integer_enum.pyi @@ -24,13 +24,7 @@ from petstore_api import schemas # noqa: F401 class IntegerEnum( - schemas.SchemaEnumMakerClsFactory( - enum_value_to_name={ - 0: "POSITIVE_0", - 1: "POSITIVE_1", - 2: "POSITIVE_2", - } - ), + schemas.EnumBase, schemas.IntSchema ): """NOTE: This class is auto generated by OpenAPI Generator. diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/integer_enum_big.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/integer_enum_big.py index 6e931d02fd4..615680bd126 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/integer_enum_big.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/integer_enum_big.py @@ -24,13 +24,7 @@ from petstore_api import schemas # noqa: F401 class IntegerEnumBig( - schemas.SchemaEnumMakerClsFactory( - enum_value_to_name={ - 10: "POSITIVE_10", - 11: "POSITIVE_11", - 12: "POSITIVE_12", - } - ), + schemas.EnumBase, schemas.IntSchema ): """NOTE: This class is auto generated by OpenAPI Generator. @@ -38,6 +32,14 @@ class IntegerEnumBig( Do not edit the class manually. """ + + + class MetaOapg: + enum_value_to_name = { + 10: "POSITIVE_10", + 11: "POSITIVE_11", + 12: "POSITIVE_12", + } @schemas.classproperty def POSITIVE_10(cls): diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/integer_enum_big.pyi b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/integer_enum_big.pyi index 6e931d02fd4..939443fcaaa 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/integer_enum_big.pyi +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/integer_enum_big.pyi @@ -24,13 +24,7 @@ from petstore_api import schemas # noqa: F401 class IntegerEnumBig( - schemas.SchemaEnumMakerClsFactory( - enum_value_to_name={ - 10: "POSITIVE_10", - 11: "POSITIVE_11", - 12: "POSITIVE_12", - } - ), + schemas.EnumBase, schemas.IntSchema ): """NOTE: This class is auto generated by OpenAPI Generator. diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/integer_enum_one_value.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/integer_enum_one_value.py index 29e4afe9416..6ab7f2f2130 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/integer_enum_one_value.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/integer_enum_one_value.py @@ -24,11 +24,7 @@ from petstore_api import schemas # noqa: F401 class IntegerEnumOneValue( - schemas.SchemaEnumMakerClsFactory( - enum_value_to_name={ - 0: "POSITIVE_0", - } - ), + schemas.EnumBase, schemas.IntSchema ): """NOTE: This class is auto generated by OpenAPI Generator. @@ -36,6 +32,12 @@ class IntegerEnumOneValue( Do not edit the class manually. """ + + + class MetaOapg: + enum_value_to_name = { + 0: "POSITIVE_0", + } @schemas.classproperty def POSITIVE_0(cls): diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/integer_enum_one_value.pyi b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/integer_enum_one_value.pyi index 29e4afe9416..1e911e5f24b 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/integer_enum_one_value.pyi +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/integer_enum_one_value.pyi @@ -24,11 +24,7 @@ from petstore_api import schemas # noqa: F401 class IntegerEnumOneValue( - schemas.SchemaEnumMakerClsFactory( - enum_value_to_name={ - 0: "POSITIVE_0", - } - ), + schemas.EnumBase, schemas.IntSchema ): """NOTE: This class is auto generated by OpenAPI Generator. diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/integer_enum_with_default_value.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/integer_enum_with_default_value.py index 11f2d028bef..87b44b36f16 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/integer_enum_with_default_value.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/integer_enum_with_default_value.py @@ -24,13 +24,7 @@ from petstore_api import schemas # noqa: F401 class IntegerEnumWithDefaultValue( - schemas.SchemaEnumMakerClsFactory( - enum_value_to_name={ - 0: "POSITIVE_0", - 1: "POSITIVE_1", - 2: "POSITIVE_2", - } - ), + schemas.EnumBase, schemas.IntSchema ): """NOTE: This class is auto generated by OpenAPI Generator. @@ -38,6 +32,14 @@ class IntegerEnumWithDefaultValue( Do not edit the class manually. """ + + + class MetaOapg: + enum_value_to_name = { + 0: "POSITIVE_0", + 1: "POSITIVE_1", + 2: "POSITIVE_2", + } @schemas.classproperty def POSITIVE_0(cls): diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/integer_enum_with_default_value.pyi b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/integer_enum_with_default_value.pyi index 11f2d028bef..9ecbb8d1630 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/integer_enum_with_default_value.pyi +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/integer_enum_with_default_value.pyi @@ -24,13 +24,7 @@ from petstore_api import schemas # noqa: F401 class IntegerEnumWithDefaultValue( - schemas.SchemaEnumMakerClsFactory( - enum_value_to_name={ - 0: "POSITIVE_0", - 1: "POSITIVE_1", - 2: "POSITIVE_2", - } - ), + schemas.EnumBase, schemas.IntSchema ): """NOTE: This class is auto generated by OpenAPI Generator. diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/integer_max10.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/integer_max10.py index c39215af60f..ac4541fad1f 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/integer_max10.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/integer_max10.py @@ -34,4 +34,5 @@ class IntegerMax10( class MetaOapg: + format = 'int64' inclusive_maximum = 10 diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/integer_min15.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/integer_min15.py index 7430ad6f5e4..8424c1012a0 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/integer_min15.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/integer_min15.py @@ -34,4 +34,5 @@ class IntegerMin15( class MetaOapg: + format = 'int64' inclusive_minimum = 15 diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/isosceles_triangle.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/isosceles_triangle.py index 408ba30ae8a..ddce91c9b96 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/isosceles_triangle.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/isosceles_triangle.py @@ -47,13 +47,15 @@ class IsoscelesTriangle( class triangleType( - schemas.SchemaEnumMakerClsFactory( - enum_value_to_name={ - "IsoscelesTriangle": "ISOSCELES_TRIANGLE", - } - ), + schemas.EnumBase, schemas.StrSchema ): + + + class MetaOapg: + enum_value_to_name = { + "IsoscelesTriangle": "ISOSCELES_TRIANGLE", + } @schemas.classproperty def ISOSCELES_TRIANGLE(cls): diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/isosceles_triangle.pyi b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/isosceles_triangle.pyi index 408ba30ae8a..5addd141602 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/isosceles_triangle.pyi +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/isosceles_triangle.pyi @@ -47,11 +47,7 @@ class IsoscelesTriangle( class triangleType( - schemas.SchemaEnumMakerClsFactory( - enum_value_to_name={ - "IsoscelesTriangle": "ISOSCELES_TRIANGLE", - } - ), + schemas.EnumBase, schemas.StrSchema ): diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/json_patch_request_add_replace_test.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/json_patch_request_add_replace_test.py index d013295fd99..bf95ea98af7 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/json_patch_request_add_replace_test.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/json_patch_request_add_replace_test.py @@ -46,15 +46,17 @@ class JSONPatchRequestAddReplaceTest( class op( - schemas.SchemaEnumMakerClsFactory( - enum_value_to_name={ + schemas.EnumBase, + schemas.StrSchema + ): + + + class MetaOapg: + enum_value_to_name = { "add": "ADD", "replace": "REPLACE", "test": "TEST", } - ), - schemas.StrSchema - ): @schemas.classproperty def ADD(cls): diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/json_patch_request_add_replace_test.pyi b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/json_patch_request_add_replace_test.pyi index d013295fd99..50e1a870bdc 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/json_patch_request_add_replace_test.pyi +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/json_patch_request_add_replace_test.pyi @@ -46,13 +46,7 @@ class JSONPatchRequestAddReplaceTest( class op( - schemas.SchemaEnumMakerClsFactory( - enum_value_to_name={ - "add": "ADD", - "replace": "REPLACE", - "test": "TEST", - } - ), + schemas.EnumBase, schemas.StrSchema ): diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/json_patch_request_move_copy.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/json_patch_request_move_copy.py index 7ff6a7bcfd9..0b84fba0970 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/json_patch_request_move_copy.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/json_patch_request_move_copy.py @@ -46,14 +46,16 @@ class JSONPatchRequestMoveCopy( class op( - schemas.SchemaEnumMakerClsFactory( - enum_value_to_name={ + schemas.EnumBase, + schemas.StrSchema + ): + + + class MetaOapg: + enum_value_to_name = { "move": "MOVE", "copy": "COPY", } - ), - schemas.StrSchema - ): @schemas.classproperty def MOVE(cls): diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/json_patch_request_move_copy.pyi b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/json_patch_request_move_copy.pyi index 7ff6a7bcfd9..0654ee60fb8 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/json_patch_request_move_copy.pyi +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/json_patch_request_move_copy.pyi @@ -46,12 +46,7 @@ class JSONPatchRequestMoveCopy( class op( - schemas.SchemaEnumMakerClsFactory( - enum_value_to_name={ - "move": "MOVE", - "copy": "COPY", - } - ), + schemas.EnumBase, schemas.StrSchema ): diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/json_patch_request_remove.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/json_patch_request_remove.py index ebe64d5ee09..4e15b41cefb 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/json_patch_request_remove.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/json_patch_request_remove.py @@ -44,13 +44,15 @@ class JSONPatchRequestRemove( class op( - schemas.SchemaEnumMakerClsFactory( - enum_value_to_name={ - "remove": "REMOVE", - } - ), + schemas.EnumBase, schemas.StrSchema ): + + + class MetaOapg: + enum_value_to_name = { + "remove": "REMOVE", + } @schemas.classproperty def REMOVE(cls): diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/json_patch_request_remove.pyi b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/json_patch_request_remove.pyi index ebe64d5ee09..325cbe8a98e 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/json_patch_request_remove.pyi +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/json_patch_request_remove.pyi @@ -44,11 +44,7 @@ class JSONPatchRequestRemove( class op( - schemas.SchemaEnumMakerClsFactory( - enum_value_to_name={ - "remove": "REMOVE", - } - ), + schemas.EnumBase, schemas.StrSchema ): diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/map_test.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/map_test.py index c5d70ab8075..031503142c6 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/map_test.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/map_test.py @@ -104,14 +104,16 @@ class MapTest( class additional_properties( - schemas.SchemaEnumMakerClsFactory( - enum_value_to_name={ + schemas.EnumBase, + schemas.StrSchema + ): + + + class MetaOapg: + enum_value_to_name = { "UPPER": "UPPER", "lower": "LOWER", } - ), - schemas.StrSchema - ): @schemas.classproperty def UPPER(cls): diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/map_test.pyi b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/map_test.pyi index c5d70ab8075..a89ebb2fc83 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/map_test.pyi +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/map_test.pyi @@ -104,12 +104,7 @@ class MapTest( class additional_properties( - schemas.SchemaEnumMakerClsFactory( - enum_value_to_name={ - "UPPER": "UPPER", - "lower": "LOWER", - } - ), + schemas.EnumBase, schemas.StrSchema ): diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/order.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/order.py index 817fb58ac79..6d653b0ab07 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/order.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/order.py @@ -43,15 +43,17 @@ class Order( class status( - schemas.SchemaEnumMakerClsFactory( - enum_value_to_name={ + schemas.EnumBase, + schemas.StrSchema + ): + + + class MetaOapg: + enum_value_to_name = { "placed": "PLACED", "approved": "APPROVED", "delivered": "DELIVERED", } - ), - schemas.StrSchema - ): @schemas.classproperty def PLACED(cls): diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/order.pyi b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/order.pyi index 817fb58ac79..ccbca89e082 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/order.pyi +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/order.pyi @@ -43,13 +43,7 @@ class Order( class status( - schemas.SchemaEnumMakerClsFactory( - enum_value_to_name={ - "placed": "PLACED", - "approved": "APPROVED", - "delivered": "DELIVERED", - } - ), + schemas.EnumBase, schemas.StrSchema ): diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/pet.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/pet.py index cc5bd6a5a7e..5b1b6b8275e 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/pet.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/pet.py @@ -100,15 +100,17 @@ class Pet( class status( - schemas.SchemaEnumMakerClsFactory( - enum_value_to_name={ + schemas.EnumBase, + schemas.StrSchema + ): + + + class MetaOapg: + enum_value_to_name = { "available": "AVAILABLE", "pending": "PENDING", "sold": "SOLD", } - ), - schemas.StrSchema - ): @schemas.classproperty def AVAILABLE(cls): diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/pet.pyi b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/pet.pyi index cc5bd6a5a7e..01529098ea0 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/pet.pyi +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/pet.pyi @@ -100,13 +100,7 @@ class Pet( class status( - schemas.SchemaEnumMakerClsFactory( - enum_value_to_name={ - "available": "AVAILABLE", - "pending": "PENDING", - "sold": "SOLD", - } - ), + schemas.EnumBase, schemas.StrSchema ): diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/quadrilateral_interface.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/quadrilateral_interface.py index a1cf375d2a0..90c85c2388f 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/quadrilateral_interface.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/quadrilateral_interface.py @@ -43,13 +43,15 @@ class QuadrilateralInterface( class shapeType( - schemas.SchemaEnumMakerClsFactory( - enum_value_to_name={ - "Quadrilateral": "QUADRILATERAL", - } - ), + schemas.EnumBase, schemas.StrSchema ): + + + class MetaOapg: + enum_value_to_name = { + "Quadrilateral": "QUADRILATERAL", + } @schemas.classproperty def QUADRILATERAL(cls): diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/quadrilateral_interface.pyi b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/quadrilateral_interface.pyi index a1cf375d2a0..92505429048 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/quadrilateral_interface.pyi +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/quadrilateral_interface.pyi @@ -43,11 +43,7 @@ class QuadrilateralInterface( class shapeType( - schemas.SchemaEnumMakerClsFactory( - enum_value_to_name={ - "Quadrilateral": "QUADRILATERAL", - } - ), + schemas.EnumBase, schemas.StrSchema ): diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/scalene_triangle.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/scalene_triangle.py index e08d1d098b9..46083ad5644 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/scalene_triangle.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/scalene_triangle.py @@ -47,13 +47,15 @@ class ScaleneTriangle( class triangleType( - schemas.SchemaEnumMakerClsFactory( - enum_value_to_name={ - "ScaleneTriangle": "SCALENE_TRIANGLE", - } - ), + schemas.EnumBase, schemas.StrSchema ): + + + class MetaOapg: + enum_value_to_name = { + "ScaleneTriangle": "SCALENE_TRIANGLE", + } @schemas.classproperty def SCALENE_TRIANGLE(cls): diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/scalene_triangle.pyi b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/scalene_triangle.pyi index e08d1d098b9..b602ba62d53 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/scalene_triangle.pyi +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/scalene_triangle.pyi @@ -47,11 +47,7 @@ class ScaleneTriangle( class triangleType( - schemas.SchemaEnumMakerClsFactory( - enum_value_to_name={ - "ScaleneTriangle": "SCALENE_TRIANGLE", - } - ), + schemas.EnumBase, schemas.StrSchema ): diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/simple_quadrilateral.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/simple_quadrilateral.py index 6490d3a5723..93d3c1f9325 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/simple_quadrilateral.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/simple_quadrilateral.py @@ -47,13 +47,15 @@ class SimpleQuadrilateral( class quadrilateralType( - schemas.SchemaEnumMakerClsFactory( - enum_value_to_name={ - "SimpleQuadrilateral": "SIMPLE_QUADRILATERAL", - } - ), + schemas.EnumBase, schemas.StrSchema ): + + + class MetaOapg: + enum_value_to_name = { + "SimpleQuadrilateral": "SIMPLE_QUADRILATERAL", + } @schemas.classproperty def SIMPLE_QUADRILATERAL(cls): diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/simple_quadrilateral.pyi b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/simple_quadrilateral.pyi index 6490d3a5723..59505edad85 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/simple_quadrilateral.pyi +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/simple_quadrilateral.pyi @@ -47,11 +47,7 @@ class SimpleQuadrilateral( class quadrilateralType( - schemas.SchemaEnumMakerClsFactory( - enum_value_to_name={ - "SimpleQuadrilateral": "SIMPLE_QUADRILATERAL", - } - ), + schemas.EnumBase, schemas.StrSchema ): diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/string_enum.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/string_enum.py index 94ee17b59af..abc1696bc14 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/string_enum.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/string_enum.py @@ -24,17 +24,7 @@ from petstore_api import schemas # noqa: F401 class StringEnum( - schemas.SchemaEnumMakerClsFactory( - enum_value_to_name={ - schemas.NoneClass.NONE: "NONE", - "placed": "PLACED", - "approved": "APPROVED", - "delivered": "DELIVERED", - "single quoted": "SINGLE_QUOTED", - "multiple\nlines": "MULTIPLE_LINES", - "double quote \n with newline": "DOUBLE_QUOTE_WITH_NEWLINE", - } - ), + schemas.EnumBase, schemas.StrBase, schemas.NoneBase, schemas.Schema, @@ -45,10 +35,18 @@ class StringEnum( Do not edit the class manually. """ - - @schemas.classproperty - def NONE(cls): - return cls(None) + + + class MetaOapg: + enum_value_to_name = { + "placed": "PLACED", + "approved": "APPROVED", + "delivered": "DELIVERED", + "single quoted": "SINGLE_QUOTED", + "multiple\nlines": "MULTIPLE_LINES", + "double quote \n with newline": "DOUBLE_QUOTE_WITH_NEWLINE", + schemas.NoneClass.NONE: "NONE", + } @schemas.classproperty def PLACED(cls): @@ -73,6 +71,10 @@ class StringEnum( @schemas.classproperty def DOUBLE_QUOTE_WITH_NEWLINE(cls): return cls("double quote \n with newline") + + @schemas.classproperty + def NONE(cls): + return cls(None) def __new__( diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/string_enum.pyi b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/string_enum.pyi index 94ee17b59af..abc1696bc14 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/string_enum.pyi +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/string_enum.pyi @@ -24,17 +24,7 @@ from petstore_api import schemas # noqa: F401 class StringEnum( - schemas.SchemaEnumMakerClsFactory( - enum_value_to_name={ - schemas.NoneClass.NONE: "NONE", - "placed": "PLACED", - "approved": "APPROVED", - "delivered": "DELIVERED", - "single quoted": "SINGLE_QUOTED", - "multiple\nlines": "MULTIPLE_LINES", - "double quote \n with newline": "DOUBLE_QUOTE_WITH_NEWLINE", - } - ), + schemas.EnumBase, schemas.StrBase, schemas.NoneBase, schemas.Schema, @@ -45,10 +35,18 @@ class StringEnum( Do not edit the class manually. """ - - @schemas.classproperty - def NONE(cls): - return cls(None) + + + class MetaOapg: + enum_value_to_name = { + "placed": "PLACED", + "approved": "APPROVED", + "delivered": "DELIVERED", + "single quoted": "SINGLE_QUOTED", + "multiple\nlines": "MULTIPLE_LINES", + "double quote \n with newline": "DOUBLE_QUOTE_WITH_NEWLINE", + schemas.NoneClass.NONE: "NONE", + } @schemas.classproperty def PLACED(cls): @@ -73,6 +71,10 @@ class StringEnum( @schemas.classproperty def DOUBLE_QUOTE_WITH_NEWLINE(cls): return cls("double quote \n with newline") + + @schemas.classproperty + def NONE(cls): + return cls(None) def __new__( diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/string_enum_with_default_value.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/string_enum_with_default_value.py index 33976873a61..85260096555 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/string_enum_with_default_value.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/string_enum_with_default_value.py @@ -24,13 +24,7 @@ from petstore_api import schemas # noqa: F401 class StringEnumWithDefaultValue( - schemas.SchemaEnumMakerClsFactory( - enum_value_to_name={ - "placed": "PLACED", - "approved": "APPROVED", - "delivered": "DELIVERED", - } - ), + schemas.EnumBase, schemas.StrSchema ): """NOTE: This class is auto generated by OpenAPI Generator. @@ -38,6 +32,14 @@ class StringEnumWithDefaultValue( Do not edit the class manually. """ + + + class MetaOapg: + enum_value_to_name = { + "placed": "PLACED", + "approved": "APPROVED", + "delivered": "DELIVERED", + } @schemas.classproperty def PLACED(cls): diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/string_enum_with_default_value.pyi b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/string_enum_with_default_value.pyi index 33976873a61..e51581c628f 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/string_enum_with_default_value.pyi +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/string_enum_with_default_value.pyi @@ -24,13 +24,7 @@ from petstore_api import schemas # noqa: F401 class StringEnumWithDefaultValue( - schemas.SchemaEnumMakerClsFactory( - enum_value_to_name={ - "placed": "PLACED", - "approved": "APPROVED", - "delivered": "DELIVERED", - } - ), + schemas.EnumBase, schemas.StrSchema ): """NOTE: This class is auto generated by OpenAPI Generator. diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/triangle_interface.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/triangle_interface.py index 6653983329a..7ac28c0031c 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/triangle_interface.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/triangle_interface.py @@ -43,13 +43,15 @@ class TriangleInterface( class shapeType( - schemas.SchemaEnumMakerClsFactory( - enum_value_to_name={ - "Triangle": "TRIANGLE", - } - ), + schemas.EnumBase, schemas.StrSchema ): + + + class MetaOapg: + enum_value_to_name = { + "Triangle": "TRIANGLE", + } @schemas.classproperty def TRIANGLE(cls): diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/triangle_interface.pyi b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/triangle_interface.pyi index 6653983329a..86b525d359a 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/triangle_interface.pyi +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/triangle_interface.pyi @@ -43,11 +43,7 @@ class TriangleInterface( class shapeType( - schemas.SchemaEnumMakerClsFactory( - enum_value_to_name={ - "Triangle": "TRIANGLE", - } - ), + schemas.EnumBase, schemas.StrSchema ): diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/uuid_string.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/uuid_string.py index 106a9f3cd59..92a3825e376 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/uuid_string.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/uuid_string.py @@ -34,4 +34,5 @@ class UUIDString( class MetaOapg: + format = 'uuid' min_length = 1 diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/whale.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/whale.py index d470f2901a8..b645789bd15 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/whale.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/whale.py @@ -42,13 +42,15 @@ class Whale( class className( - schemas.SchemaEnumMakerClsFactory( - enum_value_to_name={ - "whale": "WHALE", - } - ), + schemas.EnumBase, schemas.StrSchema ): + + + class MetaOapg: + enum_value_to_name = { + "whale": "WHALE", + } @schemas.classproperty def WHALE(cls): diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/whale.pyi b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/whale.pyi index d470f2901a8..48e2538cb8c 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/whale.pyi +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/whale.pyi @@ -42,11 +42,7 @@ class Whale( class className( - schemas.SchemaEnumMakerClsFactory( - enum_value_to_name={ - "whale": "WHALE", - } - ), + schemas.EnumBase, schemas.StrSchema ): diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/zebra.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/zebra.py index 1cf74de59e9..960a43f5921 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/zebra.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/zebra.py @@ -42,13 +42,15 @@ class Zebra( class className( - schemas.SchemaEnumMakerClsFactory( - enum_value_to_name={ - "zebra": "ZEBRA", - } - ), + schemas.EnumBase, schemas.StrSchema ): + + + class MetaOapg: + enum_value_to_name = { + "zebra": "ZEBRA", + } @schemas.classproperty def ZEBRA(cls): @@ -56,15 +58,17 @@ class Zebra( class type( - schemas.SchemaEnumMakerClsFactory( - enum_value_to_name={ + schemas.EnumBase, + schemas.StrSchema + ): + + + class MetaOapg: + enum_value_to_name = { "plains": "PLAINS", "mountain": "MOUNTAIN", "grevys": "GREVYS", } - ), - schemas.StrSchema - ): @schemas.classproperty def PLAINS(cls): diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/zebra.pyi b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/zebra.pyi index 1cf74de59e9..3666395b313 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/zebra.pyi +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/zebra.pyi @@ -42,11 +42,7 @@ class Zebra( class className( - schemas.SchemaEnumMakerClsFactory( - enum_value_to_name={ - "zebra": "ZEBRA", - } - ), + schemas.EnumBase, schemas.StrSchema ): @@ -56,13 +52,7 @@ class Zebra( class type( - schemas.SchemaEnumMakerClsFactory( - enum_value_to_name={ - "plains": "PLAINS", - "mountain": "MOUNTAIN", - "grevys": "GREVYS", - } - ), + schemas.EnumBase, schemas.StrSchema ): diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/paths/fake/get.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/paths/fake/get.py index 6c9c94cccfd..d69fbec4c6b 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/paths/fake/get.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/paths/fake/get.py @@ -39,14 +39,16 @@ class EnumQueryStringArraySchema( class items( - schemas.SchemaEnumMakerClsFactory( - enum_value_to_name={ + schemas.EnumBase, + schemas.StrSchema + ): + + + class MetaOapg: + enum_value_to_name = { ">": "GREATER_THAN", "$": "DOLLAR", } - ), - schemas.StrSchema - ): @schemas.classproperty def GREATER_THAN(cls): @@ -72,15 +74,17 @@ class EnumQueryStringArraySchema( class EnumQueryStringSchema( - schemas.SchemaEnumMakerClsFactory( - enum_value_to_name={ + schemas.EnumBase, + schemas.StrSchema +): + + + class MetaOapg: + enum_value_to_name = { "_abc": "_ABC", "-efg": "EFG", "(xyz)": "XYZ", } - ), - schemas.StrSchema -): @schemas.classproperty def _ABC(cls): @@ -96,14 +100,17 @@ class EnumQueryStringSchema( class EnumQueryIntegerSchema( - schemas.SchemaEnumMakerClsFactory( - enum_value_to_name={ + schemas.EnumBase, + schemas.Int32Schema +): + + + class MetaOapg: + format = 'int32' + enum_value_to_name = { 1: "POSITIVE_1", -2: "NEGATIVE_2", } - ), - schemas.Int32Schema -): @schemas.classproperty def POSITIVE_1(cls): @@ -115,14 +122,17 @@ class EnumQueryIntegerSchema( class EnumQueryDoubleSchema( - schemas.SchemaEnumMakerClsFactory( - enum_value_to_name={ + schemas.EnumBase, + schemas.Float64Schema +): + + + class MetaOapg: + format = 'double' + enum_value_to_name = { 1.1: "POSITIVE_1_PT_1", -1.2: "NEGATIVE_1_PT_2", } - ), - schemas.Float64Schema -): @schemas.classproperty def POSITIVE_1_PT_1(cls): @@ -188,14 +198,16 @@ class EnumHeaderStringArraySchema( class items( - schemas.SchemaEnumMakerClsFactory( - enum_value_to_name={ + schemas.EnumBase, + schemas.StrSchema + ): + + + class MetaOapg: + enum_value_to_name = { ">": "GREATER_THAN", "$": "DOLLAR", } - ), - schemas.StrSchema - ): @schemas.classproperty def GREATER_THAN(cls): @@ -221,15 +233,17 @@ class EnumHeaderStringArraySchema( class EnumHeaderStringSchema( - schemas.SchemaEnumMakerClsFactory( - enum_value_to_name={ + schemas.EnumBase, + schemas.StrSchema +): + + + class MetaOapg: + enum_value_to_name = { "_abc": "_ABC", "-efg": "EFG", "(xyz)": "XYZ", } - ), - schemas.StrSchema -): @schemas.classproperty def _ABC(cls): @@ -293,14 +307,16 @@ class SchemaForRequestBodyApplicationXWwwFormUrlencoded( class items( - schemas.SchemaEnumMakerClsFactory( - enum_value_to_name={ + schemas.EnumBase, + schemas.StrSchema + ): + + + class MetaOapg: + enum_value_to_name = { ">": "GREATER_THAN", "$": "DOLLAR", } - ), - schemas.StrSchema - ): @schemas.classproperty def GREATER_THAN(cls): @@ -326,15 +342,17 @@ class SchemaForRequestBodyApplicationXWwwFormUrlencoded( class enum_form_string( - schemas.SchemaEnumMakerClsFactory( - enum_value_to_name={ + schemas.EnumBase, + schemas.StrSchema + ): + + + class MetaOapg: + enum_value_to_name = { "_abc": "_ABC", "-efg": "EFG", "(xyz)": "XYZ", } - ), - schemas.StrSchema - ): @schemas.classproperty def _ABC(cls): diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/paths/fake/get.pyi b/samples/openapi3/client/petstore/python-experimental/petstore_api/paths/fake/get.pyi index b6ceae7b8ef..7db64856798 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/paths/fake/get.pyi +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/paths/fake/get.pyi @@ -37,12 +37,7 @@ class EnumQueryStringArraySchema( class items( - schemas.SchemaEnumMakerClsFactory( - enum_value_to_name={ - ">": "GREATER_THAN", - "$": "DOLLAR", - } - ), + schemas.EnumBase, schemas.StrSchema ): @@ -70,13 +65,7 @@ class EnumQueryStringArraySchema( class EnumQueryStringSchema( - schemas.SchemaEnumMakerClsFactory( - enum_value_to_name={ - "_abc": "_ABC", - "-efg": "EFG", - "(xyz)": "XYZ", - } - ), + schemas.EnumBase, schemas.StrSchema ): @@ -94,12 +83,7 @@ class EnumQueryStringSchema( class EnumQueryIntegerSchema( - schemas.SchemaEnumMakerClsFactory( - enum_value_to_name={ - 1: "POSITIVE_1", - -2: "NEGATIVE_2", - } - ), + schemas.EnumBase, schemas.Int32Schema ): @@ -113,12 +97,7 @@ class EnumQueryIntegerSchema( class EnumQueryDoubleSchema( - schemas.SchemaEnumMakerClsFactory( - enum_value_to_name={ - 1.1: "POSITIVE_1_PT_1", - -1.2: "NEGATIVE_1_PT_2", - } - ), + schemas.EnumBase, schemas.Float64Schema ): @@ -141,12 +120,7 @@ class EnumHeaderStringArraySchema( class items( - schemas.SchemaEnumMakerClsFactory( - enum_value_to_name={ - ">": "GREATER_THAN", - "$": "DOLLAR", - } - ), + schemas.EnumBase, schemas.StrSchema ): @@ -174,13 +148,7 @@ class EnumHeaderStringArraySchema( class EnumHeaderStringSchema( - schemas.SchemaEnumMakerClsFactory( - enum_value_to_name={ - "_abc": "_ABC", - "-efg": "EFG", - "(xyz)": "XYZ", - } - ), + schemas.EnumBase, schemas.StrSchema ): @@ -217,12 +185,7 @@ class SchemaForRequestBodyApplicationXWwwFormUrlencoded( class items( - schemas.SchemaEnumMakerClsFactory( - enum_value_to_name={ - ">": "GREATER_THAN", - "$": "DOLLAR", - } - ), + schemas.EnumBase, schemas.StrSchema ): @@ -250,13 +213,7 @@ class SchemaForRequestBodyApplicationXWwwFormUrlencoded( class enum_form_string( - schemas.SchemaEnumMakerClsFactory( - enum_value_to_name={ - "_abc": "_ABC", - "-efg": "EFG", - "(xyz)": "XYZ", - } - ), + schemas.EnumBase, schemas.StrSchema ): diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/paths/fake/post.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/paths/fake/post.py index 54172de750c..b732e5d6100 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/paths/fake/post.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/paths/fake/post.py @@ -62,6 +62,7 @@ class SchemaForRequestBodyApplicationXWwwFormUrlencoded( class MetaOapg: + format = 'int32' inclusive_maximum = 200 inclusive_minimum = 20 int64 = schemas.Int64Schema @@ -83,6 +84,7 @@ class SchemaForRequestBodyApplicationXWwwFormUrlencoded( class MetaOapg: + format = 'float' inclusive_maximum = 987.6 @@ -92,6 +94,7 @@ class SchemaForRequestBodyApplicationXWwwFormUrlencoded( class MetaOapg: + format = 'double' inclusive_maximum = 123.4 inclusive_minimum = 67.8 @@ -131,6 +134,7 @@ class SchemaForRequestBodyApplicationXWwwFormUrlencoded( class MetaOapg: + format = 'password' max_length = 64 min_length = 10 callback = schemas.StrSchema diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/paths/pet_find_by_status/get.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/paths/pet_find_by_status/get.py index 3f9a2430f0e..b8b945f54fa 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/paths/pet_find_by_status/get.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/paths/pet_find_by_status/get.py @@ -41,15 +41,17 @@ class StatusSchema( class items( - schemas.SchemaEnumMakerClsFactory( - enum_value_to_name={ + schemas.EnumBase, + schemas.StrSchema + ): + + + class MetaOapg: + enum_value_to_name = { "available": "AVAILABLE", "pending": "PENDING", "sold": "SOLD", } - ), - schemas.StrSchema - ): @schemas.classproperty def AVAILABLE(cls): diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/paths/pet_find_by_status/get.pyi b/samples/openapi3/client/petstore/python-experimental/petstore_api/paths/pet_find_by_status/get.pyi index 77db139f321..c626e911a77 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/paths/pet_find_by_status/get.pyi +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/paths/pet_find_by_status/get.pyi @@ -39,13 +39,7 @@ class StatusSchema( class items( - schemas.SchemaEnumMakerClsFactory( - enum_value_to_name={ - "available": "AVAILABLE", - "pending": "PENDING", - "sold": "SOLD", - } - ), + schemas.EnumBase, schemas.StrSchema ): diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/paths/store_order_order_id/get.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/paths/store_order_order_id/get.py index eed2c94e672..cae807ed63c 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/paths/store_order_order_id/get.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/paths/store_order_order_id/get.py @@ -38,6 +38,7 @@ class OrderIdSchema( class MetaOapg: + format = 'int64' inclusive_maximum = 5 inclusive_minimum = 1 RequestRequiredPathParams = typing_extensions.TypedDict( diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/schemas.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/schemas.py index 80ee17062a5..5628de732ac 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/schemas.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/schemas.py @@ -411,7 +411,7 @@ class Schema: """ cls._process_schema_classes_oapg(schema_classes) enum_schema = any( - hasattr(this_cls, '_enum_value_to_name') for this_cls in schema_classes) + issubclass(this_cls, EnumBase) for this_cls in schema_classes) inheritable_primitive_type = schema_classes.intersection(cls.__inheritable_primitive_types_set) chosen_schema_classes = schema_classes - inheritable_primitive_type suffix = tuple(inheritable_primitive_type) @@ -880,41 +880,22 @@ class ValidatorBase: ) -class EnumMakerBase: - pass - - -def SchemaEnumMakerClsFactory(enum_value_to_name: typing.Dict[typing.Union[str, decimal.Decimal, bool, none_type], str]) -> 'SchemaEnumMaker': - class SchemaEnumMaker(EnumMakerBase): - @classmethod - def _enum_value_to_name( - cls - ) -> typing.Dict[typing.Union[str, decimal.Decimal, bool, none_type], str]: - pass - try: - super_enum_value_to_name = super()._enum_value_to_name() - except AttributeError: - return enum_value_to_name - intersection = dict(enum_value_to_name.items() & super_enum_value_to_name.items()) - return intersection - - @classmethod - def _validate_oapg( - cls, - arg, - validation_metadata: ValidationMetadata, - ) -> typing.Dict[typing.Tuple[typing.Union[str, int], ...], typing.Set[typing.Union['Schema', str, decimal.Decimal, BoolClass, NoneClass, frozendict.frozendict, tuple]]]: - """ - SchemaEnumMaker _validate_oapg - Validates that arg is in the enum's allowed values - """ - try: - cls._enum_value_to_name()[arg] - except KeyError: - raise ApiValueError("Invalid value {} passed in to {}, {}".format(arg, cls, cls._enum_value_to_name())) - return super()._validate_oapg(arg, validation_metadata=validation_metadata) - - return SchemaEnumMaker +class EnumBase: + @classmethod + def _validate_oapg( + cls, + arg, + validation_metadata: ValidationMetadata, + ) -> typing.Dict[typing.Tuple[typing.Union[str, int], ...], typing.Set[typing.Union['Schema', str, decimal.Decimal, BoolClass, NoneClass, frozendict.frozendict, tuple]]]: + """ + EnumBase _validate_oapg + Validates that arg is in the enum's allowed values + """ + try: + cls.MetaOapg.enum_value_to_name[arg] + except KeyError: + raise ApiValueError("Invalid value {} passed in to {}, allowed_values={}".format(arg, cls, cls.MetaOapg.enum_value_to_name.keys())) + return super()._validate_oapg(arg, validation_metadata=validation_metadata) class BoolBase: diff --git a/samples/openapi3/client/petstore/python-experimental/tests_manual/test_combine_schemas.py b/samples/openapi3/client/petstore/python-experimental/tests_manual/test_combine_schemas.py index 13e4ba88f9a..f77f71ec46a 100644 --- a/samples/openapi3/client/petstore/python-experimental/tests_manual/test_combine_schemas.py +++ b/samples/openapi3/client/petstore/python-experimental/tests_manual/test_combine_schemas.py @@ -32,14 +32,10 @@ class TestCombineNonObjectSchemas(unittest.TestCase): class EnumPlusPrim(IntegerMax10, IntegerEnumOneValue): pass - assert EnumPlusPrim._enum_value_to_name() == {0: "POSITIVE_0"} - # order of base classes does not matter class EnumPlusPrim(IntegerEnumOneValue, IntegerMax10): pass - assert EnumPlusPrim._enum_value_to_name() == {0: "POSITIVE_0"} - enum_value = EnumPlusPrim.POSITIVE_0 assert isinstance(enum_value, EnumPlusPrim) assert isinstance(enum_value, Singleton) @@ -59,16 +55,12 @@ class TestCombineNonObjectSchemas(unittest.TestCase): assert isinstance(val, decimal.Decimal) def test_valid_enum_plus_enum(self): - class IntegerOneEnum(IntegerEnum, IntegerEnumOneValue): - pass - - assert IntegerOneEnum._enum_value_to_name() == {0: "POSITIVE_0"} - - # order of base classes does not matter class IntegerOneEnum(IntegerEnumOneValue, IntegerEnum): pass - assert IntegerOneEnum._enum_value_to_name() == {0: "POSITIVE_0"} + # order of base classes does not matter + class IntegerOneEnum(IntegerEnum, IntegerEnumOneValue): + pass enum_value = IntegerOneEnum.POSITIVE_0 assert isinstance(enum_value, IntegerOneEnum) @@ -77,12 +69,6 @@ class TestCombineNonObjectSchemas(unittest.TestCase): # we can access this enum from our class assert IntegerOneEnum.POSITIVE_0 == 0 - # accessing invalid enum throws an exception - invalid_enums = ['POSITIVE_1', 'POSITIVE_2'] - for invalid_enum in invalid_enums: - with self.assertRaises(petstore_api.ApiValueError): - getattr(IntegerOneEnum, invalid_enum) - if __name__ == '__main__': unittest.main()