From 4838d7332028704d663d77d0410d8e99650581d9 Mon Sep 17 00:00:00 2001 From: Justin Black Date: Wed, 17 May 2023 09:00:26 -0700 Subject: [PATCH 1/3] Adds property method writing --- .../schemas/_helper_property_type_hints.hbs | 17 ++++++++++++----- .../src/main/resources/python/schemas.hbs | 16 ---------------- .../petstore/python/.openapi-generator/VERSION | 2 +- .../components/schema/abstract_step_message.py | 11 ++++++++--- .../petstore_api/components/schema/animal.py | 3 ++- .../src/petstore_api/components/schema/apple.py | 3 ++- .../petstore_api/components/schema/apple_req.py | 3 ++- .../petstore_api/components/schema/banana.py | 3 ++- .../components/schema/banana_req.py | 3 ++- .../components/schema/basque_pig.py | 3 ++- .../petstore_api/components/schema/category.py | 3 ++- .../components/schema/danish_pig.py | 3 ++- .../petstore_api/components/schema/enum_test.py | 3 ++- .../components/schema/format_test.py | 15 +++++++++++---- .../components/schema/grandparent_animal.py | 3 ++- .../json_patch_request_add_replace_test.py | 11 ++++++++--- .../schema/json_patch_request_move_copy.py | 7 +++++-- .../schema/json_patch_request_remove.py | 7 +++++-- .../src/petstore_api/components/schema/money.py | 7 +++++-- .../src/petstore_api/components/schema/name.py | 3 ++- .../schema/no_additional_properties.py | 3 ++- ...object_model_with_arg_and_args_properties.py | 7 +++++-- ...of_with_req_test_prop_from_unset_add_prop.py | 3 ++- .../object_with_difficultly_named_props.py | 1 - ...bject_with_invalid_named_refed_properties.py | 1 - .../src/petstore_api/components/schema/pet.py | 7 +++++-- .../schema/quadrilateral_interface.py | 7 +++++-- .../schema/req_props_from_explicit_add_props.py | 3 ++- .../schema/req_props_from_true_add_props.py | 3 ++- .../schema/req_props_from_unset_add_props.py | 3 ++- .../components/schema/triangle_interface.py | 7 +++++-- .../src/petstore_api/components/schema/whale.py | 3 ++- .../src/petstore_api/components/schema/zebra.py | 3 ++- .../application_x_www_form_urlencoded/schema.py | 15 +++++++++++---- .../application_x_www_form_urlencoded/schema.py | 7 +++++-- .../content/multipart_form_data/schema.py | 3 ++- .../content/multipart_form_data/schema.py | 3 ++- .../petstore/python/src/petstore_api/schemas.py | 16 ---------------- 38 files changed, 131 insertions(+), 90 deletions(-) diff --git a/modules/openapi-json-schema-generator/src/main/resources/python/components/schemas/_helper_property_type_hints.hbs b/modules/openapi-json-schema-generator/src/main/resources/python/components/schemas/_helper_property_type_hints.hbs index febb3dbc400..6245ebbaeb3 100644 --- a/modules/openapi-json-schema-generator/src/main/resources/python/components/schemas/_helper_property_type_hints.hbs +++ b/modules/openapi-json-schema-generator/src/main/resources/python/components/schemas/_helper_property_type_hints.hbs @@ -1,19 +1,26 @@ {{#if requiredProperties}} - {{#each requiredProperties}} {{#if @key.isValid}} {{#with this}} {{#if refInfo.refClass}} -{{@key.original}}: '{{> components/schemas/_helper_refclass_with_module }}' + +def {{@key.original}}(self) -> '{{> components/schemas/_helper_refclass_with_module }}': + return self.__getitem__("{{{@key.original}}}") {{else}} {{#if jsonPathPiece}} {{#if schemaIsFromAdditionalProperties}} -{{@key.original}}: Schema_.{{jsonPathPiece.camelCase}} + +def {{@key.original}}(self) -> Schema_.{{jsonPathPiece.camelCase}}: + return self.__getitem__("{{{@key.original}}}") {{else}} -{{@key.original}}: Schema_.Properties.{{jsonPathPiece.camelCase}} + +def {{@key.original}}(self) -> Schema_.Properties.{{jsonPathPiece.camelCase}}: + return self.__getitem__("{{{@key.original}}}") {{/if}} {{else}} -{{@key.original}}: schemas.AnyTypeSchema + +def {{@key.original}}(self) -> schemas.AnyTypeSchema: + return self.__getitem__("{{{@key.original}}}") {{/if}} {{/if}} {{/with}} diff --git a/modules/openapi-json-schema-generator/src/main/resources/python/schemas.hbs b/modules/openapi-json-schema-generator/src/main/resources/python/schemas.hbs index dd540bbf119..011394b8cf0 100644 --- a/modules/openapi-json-schema-generator/src/main/resources/python/schemas.hbs +++ b/modules/openapi-json-schema-generator/src/main/resources/python/schemas.hbs @@ -2004,22 +2004,6 @@ class DictBase: if not isinstance(self, FileIO): raise AttributeError('property setting not supported on immutable instances') - def __getattr__(self, name: str): - """ - for instance.name access - Properties are only type hinted for required properties - so that hasattr(instance, 'optionalProp') is False when that key is not present - """ - if not isinstance(self, frozendict.frozendict): - return super().__getattr__(name) - if name not in self.__class__.__annotations__: - raise AttributeError(f"{self} has no attribute '{name}'") - try: - value = self[name] - return value - except KeyError as ex: - raise AttributeError(str(ex)) - def get_item_(self, name: str) -> typing.Union['AnyTypeSchema', Unset]: # dict_instance[name] accessor if not isinstance(self, frozendict.frozendict): diff --git a/samples/openapi3/client/petstore/python/.openapi-generator/VERSION b/samples/openapi3/client/petstore/python/.openapi-generator/VERSION index 10bf840ed53..717311e32e3 100644 --- a/samples/openapi3/client/petstore/python/.openapi-generator/VERSION +++ b/samples/openapi3/client/petstore/python/.openapi-generator/VERSION @@ -1 +1 @@ -2.0.1 \ No newline at end of file +unset \ No newline at end of file diff --git a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/abstract_step_message.py b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/abstract_step_message.py index d62ceed78d4..37cf763b0ea 100644 --- a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/abstract_step_message.py +++ b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/abstract_step_message.py @@ -69,9 +69,14 @@ def _0() -> typing.Type['AbstractStepMessage']: ] - description: schemas.AnyTypeSchema - discriminator: Schema_.Properties.Discriminator - sequenceNumber: schemas.AnyTypeSchema + def description(self) -> schemas.AnyTypeSchema: + return self.__getitem__("description") + + def discriminator(self) -> Schema_.Properties.Discriminator: + return self.__getitem__("discriminator") + + def sequenceNumber(self) -> schemas.AnyTypeSchema: + return self.__getitem__("sequenceNumber") @typing.overload def __getitem__(self, name: typing_extensions.Literal["description"]) -> schemas.AnyTypeSchema: ... diff --git a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/animal.py b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/animal.py index f62f7e591b4..3edb6300519 100644 --- a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/animal.py +++ b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/animal.py @@ -67,7 +67,8 @@ class Schema_: "color": Color, } - className: Schema_.Properties.ClassName + def className(self) -> Schema_.Properties.ClassName: + return self.__getitem__("className") @typing.overload def __getitem__(self, name: typing_extensions.Literal["className"]) -> Schema_.Properties.ClassName: ... diff --git a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/apple.py b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/apple.py index 65b77502ca0..6d9a8fb829a 100644 --- a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/apple.py +++ b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/apple.py @@ -81,7 +81,8 @@ class Schema_: } - cultivar: Schema_.Properties.Cultivar + def cultivar(self) -> Schema_.Properties.Cultivar: + return self.__getitem__("cultivar") @typing.overload def __getitem__(self, name: typing_extensions.Literal["cultivar"]) -> Schema_.Properties.Cultivar: ... diff --git a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/apple_req.py b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/apple_req.py index 67889e32d97..7987b72637d 100644 --- a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/apple_req.py +++ b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/apple_req.py @@ -48,7 +48,8 @@ class Properties: } AdditionalProperties = schemas.NotAnyTypeSchema - cultivar: Schema_.Properties.Cultivar + def cultivar(self) -> Schema_.Properties.Cultivar: + return self.__getitem__("cultivar") @typing.overload def __getitem__(self, name: typing_extensions.Literal["cultivar"]) -> Schema_.Properties.Cultivar: ... diff --git a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/banana.py b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/banana.py index edefc0f0e7f..cca3d12c457 100644 --- a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/banana.py +++ b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/banana.py @@ -45,7 +45,8 @@ class Properties: "lengthCm": LengthCm, } - lengthCm: Schema_.Properties.LengthCm + def lengthCm(self) -> Schema_.Properties.LengthCm: + return self.__getitem__("lengthCm") @typing.overload def __getitem__(self, name: typing_extensions.Literal["lengthCm"]) -> Schema_.Properties.LengthCm: ... diff --git a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/banana_req.py b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/banana_req.py index 3acf179ce17..fb30814d9f3 100644 --- a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/banana_req.py +++ b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/banana_req.py @@ -48,7 +48,8 @@ class Properties: } AdditionalProperties = schemas.NotAnyTypeSchema - lengthCm: Schema_.Properties.LengthCm + def lengthCm(self) -> Schema_.Properties.LengthCm: + return self.__getitem__("lengthCm") @typing.overload def __getitem__(self, name: typing_extensions.Literal["lengthCm"]) -> Schema_.Properties.LengthCm: ... diff --git a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/basque_pig.py b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/basque_pig.py index d28d08d956e..af4775adac8 100644 --- a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/basque_pig.py +++ b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/basque_pig.py @@ -62,7 +62,8 @@ def BASQUE_PIG(cls): "className": ClassName, } - className: Schema_.Properties.ClassName + def className(self) -> Schema_.Properties.ClassName: + return self.__getitem__("className") @typing.overload def __getitem__(self, name: typing_extensions.Literal["className"]) -> Schema_.Properties.ClassName: ... diff --git a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/category.py b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/category.py index 0358df038d4..3bb0015f9b4 100644 --- a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/category.py +++ b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/category.py @@ -58,7 +58,8 @@ class Schema_: "name": Name, } - name: Schema_.Properties.Name + def name(self) -> Schema_.Properties.Name: + return self.__getitem__("name") @typing.overload def __getitem__(self, name: typing_extensions.Literal["name"]) -> Schema_.Properties.Name: ... diff --git a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/danish_pig.py b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/danish_pig.py index e051c9408f6..4563df37012 100644 --- a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/danish_pig.py +++ b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/danish_pig.py @@ -62,7 +62,8 @@ def DANISH_PIG(cls): "className": ClassName, } - className: Schema_.Properties.ClassName + def className(self) -> Schema_.Properties.ClassName: + return self.__getitem__("className") @typing.overload def __getitem__(self, name: typing_extensions.Literal["className"]) -> Schema_.Properties.ClassName: ... diff --git a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/enum_test.py b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/enum_test.py index 8de10e15989..f1f018620b2 100644 --- a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/enum_test.py +++ b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/enum_test.py @@ -176,7 +176,8 @@ def integer_enum_one_value() -> typing.Type['integer_enum_one_value.IntegerEnumO "IntegerEnumOneValue": integer_enum_one_value, } - enum_string_required: Schema_.Properties.EnumStringRequired + def enum_string_required(self) -> Schema_.Properties.EnumStringRequired: + return self.__getitem__("enum_string_required") @typing.overload def __getitem__(self, name: typing_extensions.Literal["enum_string_required"]) -> Schema_.Properties.EnumStringRequired: ... diff --git a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/format_test.py b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/format_test.py index e2db63bd85f..585cbde709d 100644 --- a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/format_test.py +++ b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/format_test.py @@ -239,10 +239,17 @@ class Schema_: "noneProp": NoneProp, } - byte: Schema_.Properties.Byte - date: Schema_.Properties.Date - number: Schema_.Properties.Number - password: Schema_.Properties.Password + def byte(self) -> Schema_.Properties.Byte: + return self.__getitem__("byte") + + def date(self) -> Schema_.Properties.Date: + return self.__getitem__("date") + + def number(self) -> Schema_.Properties.Number: + return self.__getitem__("number") + + def password(self) -> Schema_.Properties.Password: + return self.__getitem__("password") @typing.overload def __getitem__(self, name: typing_extensions.Literal["byte"]) -> Schema_.Properties.Byte: ... diff --git a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/grandparent_animal.py b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/grandparent_animal.py index 111c0dc88e6..673e5a4d224 100644 --- a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/grandparent_animal.py +++ b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/grandparent_animal.py @@ -54,7 +54,8 @@ class Properties: "pet_type": PetType, } - pet_type: Schema_.Properties.PetType + def pet_type(self) -> Schema_.Properties.PetType: + return self.__getitem__("pet_type") @typing.overload def __getitem__(self, name: typing_extensions.Literal["pet_type"]) -> Schema_.Properties.PetType: ... diff --git a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/json_patch_request_add_replace_test.py b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/json_patch_request_add_replace_test.py index dfa36d392d2..b4c7f7cb149 100644 --- a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/json_patch_request_add_replace_test.py +++ b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/json_patch_request_add_replace_test.py @@ -79,9 +79,14 @@ def TEST(cls): } AdditionalProperties = schemas.NotAnyTypeSchema - op: Schema_.Properties.Op - path: Schema_.Properties.Path - value: Schema_.Properties.Value + def op(self) -> Schema_.Properties.Op: + return self.__getitem__("op") + + def path(self) -> Schema_.Properties.Path: + return self.__getitem__("path") + + def value(self) -> Schema_.Properties.Value: + return self.__getitem__("value") @typing.overload def __getitem__(self, name: typing_extensions.Literal["op"]) -> Schema_.Properties.Op: ... diff --git a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/json_patch_request_move_copy.py b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/json_patch_request_move_copy.py index f1f3580bcab..dfc62a48f83 100644 --- a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/json_patch_request_move_copy.py +++ b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/json_patch_request_move_copy.py @@ -74,8 +74,11 @@ def COPY(cls): } AdditionalProperties = schemas.NotAnyTypeSchema - op: Schema_.Properties.Op - path: Schema_.Properties.Path + def op(self) -> Schema_.Properties.Op: + return self.__getitem__("op") + + def path(self) -> Schema_.Properties.Path: + return self.__getitem__("path") @typing.overload def __getitem__(self, name: typing_extensions.Literal["from"]) -> Schema_.Properties._From: ... diff --git a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/json_patch_request_remove.py b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/json_patch_request_remove.py index f8a96f42f17..ef38aca3211 100644 --- a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/json_patch_request_remove.py +++ b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/json_patch_request_remove.py @@ -66,8 +66,11 @@ def REMOVE(cls): } AdditionalProperties = schemas.NotAnyTypeSchema - op: Schema_.Properties.Op - path: Schema_.Properties.Path + def op(self) -> Schema_.Properties.Op: + return self.__getitem__("op") + + def path(self) -> Schema_.Properties.Path: + return self.__getitem__("path") @typing.overload def __getitem__(self, name: typing_extensions.Literal["op"]) -> Schema_.Properties.Op: ... diff --git a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/money.py b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/money.py index 4e71cd6de4f..f68c06f902d 100644 --- a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/money.py +++ b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/money.py @@ -51,8 +51,11 @@ def currency() -> typing.Type['currency.Currency']: "currency": currency, } - amount: Schema_.Properties.Amount - currency: 'currency.Currency' + def amount(self) -> Schema_.Properties.Amount: + return self.__getitem__("amount") + + def currency(self) -> 'currency.Currency': + return self.__getitem__("currency") @typing.overload def __getitem__(self, name: typing_extensions.Literal["amount"]) -> Schema_.Properties.Amount: ... diff --git a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/name.py b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/name.py index 44f707b9c73..12dcfd57d94 100644 --- a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/name.py +++ b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/name.py @@ -52,7 +52,8 @@ class Properties: } - name: Schema_.Properties.Name + def name(self) -> Schema_.Properties.Name: + return self.__getitem__("name") @typing.overload def __getitem__(self, name: typing_extensions.Literal["name"]) -> Schema_.Properties.Name: ... diff --git a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/no_additional_properties.py b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/no_additional_properties.py index b44cc0b5b59..d31835a6fdf 100644 --- a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/no_additional_properties.py +++ b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/no_additional_properties.py @@ -48,7 +48,8 @@ class Properties: } AdditionalProperties = schemas.NotAnyTypeSchema - id: Schema_.Properties.Id + def id(self) -> Schema_.Properties.Id: + return self.__getitem__("id") @typing.overload def __getitem__(self, name: typing_extensions.Literal["id"]) -> Schema_.Properties.Id: ... diff --git a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/object_model_with_arg_and_args_properties.py b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/object_model_with_arg_and_args_properties.py index 74815e96bd8..63f6187c29c 100644 --- a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/object_model_with_arg_and_args_properties.py +++ b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/object_model_with_arg_and_args_properties.py @@ -48,8 +48,11 @@ class Properties: "args": Args, } - arg: Schema_.Properties.Arg - args: Schema_.Properties.Args + def arg(self) -> Schema_.Properties.Arg: + return self.__getitem__("arg") + + def args(self) -> Schema_.Properties.Args: + return self.__getitem__("args") @typing.overload def __getitem__(self, name: typing_extensions.Literal["arg"]) -> Schema_.Properties.Arg: ... diff --git a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/object_with_all_of_with_req_test_prop_from_unset_add_prop.py b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/object_with_all_of_with_req_test_prop_from_unset_add_prop.py index 4c2b570ac13..9643cb48efb 100644 --- a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/object_with_all_of_with_req_test_prop_from_unset_add_prop.py +++ b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/object_with_all_of_with_req_test_prop_from_unset_add_prop.py @@ -60,7 +60,8 @@ class Properties: "name": Name, } - test: schemas.AnyTypeSchema + def test(self) -> schemas.AnyTypeSchema: + return self.__getitem__("test") @typing.overload def __getitem__(self, name: typing_extensions.Literal["test"]) -> schemas.AnyTypeSchema: ... diff --git a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/object_with_difficultly_named_props.py b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/object_with_difficultly_named_props.py index 0ecb707420d..129df813af6 100644 --- a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/object_with_difficultly_named_props.py +++ b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/object_with_difficultly_named_props.py @@ -51,7 +51,6 @@ class Properties: "123Number": _123Number, } - @typing.overload def __getitem__(self, name: typing_extensions.Literal["123-list"]) -> Schema_.Properties._123List: ... diff --git a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/object_with_invalid_named_refed_properties.py b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/object_with_invalid_named_refed_properties.py index 33943ea818b..13bf876db59 100644 --- a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/object_with_invalid_named_refed_properties.py +++ b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/object_with_invalid_named_refed_properties.py @@ -54,7 +54,6 @@ def reference() -> typing.Type['array_with_validations_in_items.ArrayWithValidat "!reference": reference, } - @typing.overload def __getitem__(self, name: typing_extensions.Literal["!reference"]) -> 'array_with_validations_in_items.ArrayWithValidationsInItems': ... diff --git a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/pet.py b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/pet.py index 9e22892e1e5..a30f713f85f 100644 --- a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/pet.py +++ b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/pet.py @@ -151,8 +151,11 @@ def SOLD(cls): "status": Status, } - name: Schema_.Properties.Name - photoUrls: Schema_.Properties.PhotoUrls + def name(self) -> Schema_.Properties.Name: + return self.__getitem__("name") + + def photoUrls(self) -> Schema_.Properties.PhotoUrls: + return self.__getitem__("photoUrls") @typing.overload def __getitem__(self, name: typing_extensions.Literal["name"]) -> Schema_.Properties.Name: ... diff --git a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/quadrilateral_interface.py b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/quadrilateral_interface.py index a872eebb736..1a9d0d1cb3b 100644 --- a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/quadrilateral_interface.py +++ b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/quadrilateral_interface.py @@ -66,8 +66,11 @@ def QUADRILATERAL(cls): } - quadrilateralType: Schema_.Properties.QuadrilateralType - shapeType: Schema_.Properties.ShapeType + def quadrilateralType(self) -> Schema_.Properties.QuadrilateralType: + return self.__getitem__("quadrilateralType") + + def shapeType(self) -> Schema_.Properties.ShapeType: + return self.__getitem__("shapeType") @typing.overload def __getitem__(self, name: typing_extensions.Literal["quadrilateralType"]) -> Schema_.Properties.QuadrilateralType: ... diff --git a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/req_props_from_explicit_add_props.py b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/req_props_from_explicit_add_props.py index 9fd1260cfaf..acf1fe24848 100644 --- a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/req_props_from_explicit_add_props.py +++ b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/req_props_from_explicit_add_props.py @@ -41,7 +41,8 @@ class Schema_: } AdditionalProperties = schemas.StrSchema - validName: Schema_.AdditionalProperties + def validName(self) -> Schema_.AdditionalProperties: + return self.__getitem__("validName") @typing.overload def __getitem__(self, name: typing_extensions.Literal["invalid-name"]) -> Schema_.AdditionalProperties: ... diff --git a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/req_props_from_true_add_props.py b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/req_props_from_true_add_props.py index d1ecdd111b7..d94da888d80 100644 --- a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/req_props_from_true_add_props.py +++ b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/req_props_from_true_add_props.py @@ -41,7 +41,8 @@ class Schema_: } AdditionalProperties = schemas.AnyTypeSchema - validName: Schema_.AdditionalProperties + def validName(self) -> Schema_.AdditionalProperties: + return self.__getitem__("validName") @typing.overload def __getitem__(self, name: typing_extensions.Literal["invalid-name"]) -> Schema_.AdditionalProperties: ... diff --git a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/req_props_from_unset_add_props.py b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/req_props_from_unset_add_props.py index 4276aa83954..5a134b07d52 100644 --- a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/req_props_from_unset_add_props.py +++ b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/req_props_from_unset_add_props.py @@ -40,7 +40,8 @@ class Schema_: "validName", } - validName: schemas.AnyTypeSchema + def validName(self) -> schemas.AnyTypeSchema: + return self.__getitem__("validName") @typing.overload def __getitem__(self, name: typing_extensions.Literal["invalid-name"]) -> schemas.AnyTypeSchema: ... diff --git a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/triangle_interface.py b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/triangle_interface.py index f929d952737..dc757a61d45 100644 --- a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/triangle_interface.py +++ b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/triangle_interface.py @@ -66,8 +66,11 @@ def TRIANGLE(cls): } - shapeType: Schema_.Properties.ShapeType - triangleType: Schema_.Properties.TriangleType + def shapeType(self) -> Schema_.Properties.ShapeType: + return self.__getitem__("shapeType") + + def triangleType(self) -> Schema_.Properties.TriangleType: + return self.__getitem__("triangleType") @typing.overload def __getitem__(self, name: typing_extensions.Literal["shapeType"]) -> Schema_.Properties.ShapeType: ... diff --git a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/whale.py b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/whale.py index 0a6d0651875..dadd08bd909 100644 --- a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/whale.py +++ b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/whale.py @@ -66,7 +66,8 @@ def WHALE(cls): "className": ClassName, } - className: Schema_.Properties.ClassName + def className(self) -> Schema_.Properties.ClassName: + return self.__getitem__("className") @typing.overload def __getitem__(self, name: typing_extensions.Literal["className"]) -> Schema_.Properties.ClassName: ... diff --git a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/zebra.py b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/zebra.py index 5ac9070e0d7..72f5c7fb89b 100644 --- a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/zebra.py +++ b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/zebra.py @@ -92,7 +92,8 @@ def ZEBRA(cls): } AdditionalProperties = schemas.AnyTypeSchema - className: Schema_.Properties.ClassName + def className(self) -> Schema_.Properties.ClassName: + return self.__getitem__("className") @typing.overload def __getitem__(self, name: typing_extensions.Literal["className"]) -> Schema_.Properties.ClassName: ... diff --git a/samples/openapi3/client/petstore/python/src/petstore_api/paths/fake/post/request_body/content/application_x_www_form_urlencoded/schema.py b/samples/openapi3/client/petstore/python/src/petstore_api/paths/fake/post/request_body/content/application_x_www_form_urlencoded/schema.py index 2089b12bd14..31545d6e9dc 100644 --- a/samples/openapi3/client/petstore/python/src/petstore_api/paths/fake/post/request_body/content/application_x_www_form_urlencoded/schema.py +++ b/samples/openapi3/client/petstore/python/src/petstore_api/paths/fake/post/request_body/content/application_x_www_form_urlencoded/schema.py @@ -183,10 +183,17 @@ class Schema_: "callback": Callback, } - byte: Schema_.Properties.Byte - double: Schema_.Properties.Double - number: Schema_.Properties.Number - pattern_without_delimiter: Schema_.Properties.PatternWithoutDelimiter + def byte(self) -> Schema_.Properties.Byte: + return self.__getitem__("byte") + + def double(self) -> Schema_.Properties.Double: + return self.__getitem__("double") + + def number(self) -> Schema_.Properties.Number: + return self.__getitem__("number") + + def pattern_without_delimiter(self) -> Schema_.Properties.PatternWithoutDelimiter: + return self.__getitem__("pattern_without_delimiter") @typing.overload def __getitem__(self, name: typing_extensions.Literal["byte"]) -> Schema_.Properties.Byte: ... diff --git a/samples/openapi3/client/petstore/python/src/petstore_api/paths/fake_json_form_data/get/request_body/content/application_x_www_form_urlencoded/schema.py b/samples/openapi3/client/petstore/python/src/petstore_api/paths/fake_json_form_data/get/request_body/content/application_x_www_form_urlencoded/schema.py index ecbd7df9184..4d6234fa200 100644 --- a/samples/openapi3/client/petstore/python/src/petstore_api/paths/fake_json_form_data/get/request_body/content/application_x_www_form_urlencoded/schema.py +++ b/samples/openapi3/client/petstore/python/src/petstore_api/paths/fake_json_form_data/get/request_body/content/application_x_www_form_urlencoded/schema.py @@ -43,8 +43,11 @@ class Properties: "param2": Param2, } - param: Schema_.Properties.Param - param2: Schema_.Properties.Param2 + def param(self) -> Schema_.Properties.Param: + return self.__getitem__("param") + + def param2(self) -> Schema_.Properties.Param2: + return self.__getitem__("param2") @typing.overload def __getitem__(self, name: typing_extensions.Literal["param"]) -> Schema_.Properties.Param: ... diff --git a/samples/openapi3/client/petstore/python/src/petstore_api/paths/fake_pet_id_upload_image_with_required_file/post/request_body/content/multipart_form_data/schema.py b/samples/openapi3/client/petstore/python/src/petstore_api/paths/fake_pet_id_upload_image_with_required_file/post/request_body/content/multipart_form_data/schema.py index 15e7030b269..b6fcf6dbef5 100644 --- a/samples/openapi3/client/petstore/python/src/petstore_api/paths/fake_pet_id_upload_image_with_required_file/post/request_body/content/multipart_form_data/schema.py +++ b/samples/openapi3/client/petstore/python/src/petstore_api/paths/fake_pet_id_upload_image_with_required_file/post/request_body/content/multipart_form_data/schema.py @@ -42,7 +42,8 @@ class Properties: "requiredFile": RequiredFile, } - requiredFile: Schema_.Properties.RequiredFile + def requiredFile(self) -> Schema_.Properties.RequiredFile: + return self.__getitem__("requiredFile") @typing.overload def __getitem__(self, name: typing_extensions.Literal["requiredFile"]) -> Schema_.Properties.RequiredFile: ... diff --git a/samples/openapi3/client/petstore/python/src/petstore_api/paths/fake_upload_file/post/request_body/content/multipart_form_data/schema.py b/samples/openapi3/client/petstore/python/src/petstore_api/paths/fake_upload_file/post/request_body/content/multipart_form_data/schema.py index 1f2d7770571..dc0dc30e889 100644 --- a/samples/openapi3/client/petstore/python/src/petstore_api/paths/fake_upload_file/post/request_body/content/multipart_form_data/schema.py +++ b/samples/openapi3/client/petstore/python/src/petstore_api/paths/fake_upload_file/post/request_body/content/multipart_form_data/schema.py @@ -42,7 +42,8 @@ class Properties: "file": File, } - file: Schema_.Properties.File + def file(self) -> Schema_.Properties.File: + return self.__getitem__("file") @typing.overload def __getitem__(self, name: typing_extensions.Literal["file"]) -> Schema_.Properties.File: ... diff --git a/samples/openapi3/client/petstore/python/src/petstore_api/schemas.py b/samples/openapi3/client/petstore/python/src/petstore_api/schemas.py index f9ff1cc85e5..99ce8017b03 100644 --- a/samples/openapi3/client/petstore/python/src/petstore_api/schemas.py +++ b/samples/openapi3/client/petstore/python/src/petstore_api/schemas.py @@ -1896,22 +1896,6 @@ def __setattr__(self, name: str, value: typing.Any): if not isinstance(self, FileIO): raise AttributeError('property setting not supported on immutable instances') - def __getattr__(self, name: str): - """ - for instance.name access - Properties are only type hinted for required properties - so that hasattr(instance, 'optionalProp') is False when that key is not present - """ - if not isinstance(self, frozendict.frozendict): - return super().__getattr__(name) - if name not in self.__class__.__annotations__: - raise AttributeError(f"{self} has no attribute '{name}'") - try: - value = self[name] - return value - except KeyError as ex: - raise AttributeError(str(ex)) - def get_item_(self, name: str) -> typing.Union['AnyTypeSchema', Unset]: # dict_instance[name] accessor if not isinstance(self, frozendict.frozendict): From 0e4c669c307a98865a894c2834ed86267330588d Mon Sep 17 00:00:00 2001 From: Justin Black Date: Wed, 17 May 2023 09:54:20 -0700 Subject: [PATCH 2/3] Adds property acessor and test --- .../schemas/_helper_property_type_hints.hbs | 4 + .../3_0/python/petstore_customized.yaml | 18 ++- .../petstore/python/.openapi-generator/FILES | 6 + .../openapi3/client/petstore/python/README.md | 2 + .../schema/obj_with_required_props.md | 21 ++++ .../schema/obj_with_required_props_base.md | 15 +++ .../schema/abstract_step_message.py | 3 + .../petstore_api/components/schema/animal.py | 1 + .../petstore_api/components/schema/apple.py | 1 + .../components/schema/apple_req.py | 1 + .../petstore_api/components/schema/banana.py | 1 + .../components/schema/banana_req.py | 1 + .../components/schema/basque_pig.py | 1 + .../components/schema/category.py | 1 + .../components/schema/danish_pig.py | 1 + .../components/schema/enum_test.py | 1 + .../components/schema/format_test.py | 4 + .../components/schema/grandparent_animal.py | 1 + .../json_patch_request_add_replace_test.py | 3 + .../schema/json_patch_request_move_copy.py | 2 + .../schema/json_patch_request_remove.py | 2 + .../petstore_api/components/schema/money.py | 2 + .../petstore_api/components/schema/name.py | 1 + .../schema/no_additional_properties.py | 1 + .../schema/obj_with_required_props.py | 110 ++++++++++++++++++ .../schema/obj_with_required_props_base.py | 96 +++++++++++++++ ...ject_model_with_arg_and_args_properties.py | 2 + ..._with_req_test_prop_from_unset_add_prop.py | 1 + .../src/petstore_api/components/schema/pet.py | 2 + .../schema/quadrilateral_interface.py | 2 + .../req_props_from_explicit_add_props.py | 1 + .../schema/req_props_from_true_add_props.py | 1 + .../schema/req_props_from_unset_add_props.py | 1 + .../components/schema/triangle_interface.py | 2 + .../petstore_api/components/schema/whale.py | 1 + .../petstore_api/components/schema/zebra.py | 1 + .../components/schemas/__init__.py | 2 + .../schema.py | 4 + .../schema.py | 2 + .../content/multipart_form_data/schema.py | 1 + .../content/multipart_form_data/schema.py | 1 + .../schema/test_obj_with_required_props.py | 25 ++++ .../test_obj_with_required_props_base.py | 25 ++++ .../test_obj_with_required_props.py | 31 +++++ 44 files changed, 404 insertions(+), 1 deletion(-) create mode 100644 samples/openapi3/client/petstore/python/docs/components/schema/obj_with_required_props.md create mode 100644 samples/openapi3/client/petstore/python/docs/components/schema/obj_with_required_props_base.md create mode 100644 samples/openapi3/client/petstore/python/src/petstore_api/components/schema/obj_with_required_props.py create mode 100644 samples/openapi3/client/petstore/python/src/petstore_api/components/schema/obj_with_required_props_base.py create mode 100644 samples/openapi3/client/petstore/python/test/components/schema/test_obj_with_required_props.py create mode 100644 samples/openapi3/client/petstore/python/test/components/schema/test_obj_with_required_props_base.py create mode 100644 samples/openapi3/client/petstore/python/tests_manual/test_obj_with_required_props.py diff --git a/modules/openapi-json-schema-generator/src/main/resources/python/components/schemas/_helper_property_type_hints.hbs b/modules/openapi-json-schema-generator/src/main/resources/python/components/schemas/_helper_property_type_hints.hbs index 6245ebbaeb3..e39a69d228b 100644 --- a/modules/openapi-json-schema-generator/src/main/resources/python/components/schemas/_helper_property_type_hints.hbs +++ b/modules/openapi-json-schema-generator/src/main/resources/python/components/schemas/_helper_property_type_hints.hbs @@ -4,21 +4,25 @@ {{#with this}} {{#if refInfo.refClass}} +@property def {{@key.original}}(self) -> '{{> components/schemas/_helper_refclass_with_module }}': return self.__getitem__("{{{@key.original}}}") {{else}} {{#if jsonPathPiece}} {{#if schemaIsFromAdditionalProperties}} +@property def {{@key.original}}(self) -> Schema_.{{jsonPathPiece.camelCase}}: return self.__getitem__("{{{@key.original}}}") {{else}} +@property def {{@key.original}}(self) -> Schema_.Properties.{{jsonPathPiece.camelCase}}: return self.__getitem__("{{{@key.original}}}") {{/if}} {{else}} +@property def {{@key.original}}(self) -> schemas.AnyTypeSchema: return self.__getitem__("{{{@key.original}}}") {{/if}} diff --git a/modules/openapi-json-schema-generator/src/test/resources/3_0/python/petstore_customized.yaml b/modules/openapi-json-schema-generator/src/test/resources/3_0/python/petstore_customized.yaml index a2c7cba83db..217cc05905b 100644 --- a/modules/openapi-json-schema-generator/src/test/resources/3_0/python/petstore_customized.yaml +++ b/modules/openapi-json-schema-generator/src/test/resources/3_0/python/petstore_customized.yaml @@ -3273,4 +3273,20 @@ components: SelfReferencingArrayModel: type: array items: - $ref: '#/components/schemas/SelfReferencingArrayModel' \ No newline at end of file + $ref: '#/components/schemas/SelfReferencingArrayModel' + ObjWithRequiredPropsBase: + type: object + properties: + b: + type: string + required: + - b + ObjWithRequiredProps: + type: object + properties: + a: + type: string + required: + - a + allOf: + - $ref: '#/components/schemas/ObjWithRequiredPropsBase' \ No newline at end of file diff --git a/samples/openapi3/client/petstore/python/.openapi-generator/FILES b/samples/openapi3/client/petstore/python/.openapi-generator/FILES index e7e81816037..1bee4a7659c 100644 --- a/samples/openapi3/client/petstore/python/.openapi-generator/FILES +++ b/samples/openapi3/client/petstore/python/.openapi-generator/FILES @@ -117,6 +117,8 @@ docs/components/schema/nullable_string.md docs/components/schema/number.md docs/components/schema/number_only.md docs/components/schema/number_with_validations.md +docs/components/schema/obj_with_required_props.md +docs/components/schema/obj_with_required_props_base.md docs/components/schema/object_interface.md docs/components/schema/object_model_with_arg_and_args_properties.md docs/components/schema/object_model_with_ref_props.md @@ -462,6 +464,8 @@ src/petstore_api/components/schema/nullable_string.py src/petstore_api/components/schema/number.py src/petstore_api/components/schema/number_only.py src/petstore_api/components/schema/number_with_validations.py +src/petstore_api/components/schema/obj_with_required_props.py +src/petstore_api/components/schema/obj_with_required_props_base.py src/petstore_api/components/schema/object_interface.py src/petstore_api/components/schema/object_model_with_arg_and_args_properties.py src/petstore_api/components/schema/object_model_with_ref_props.py @@ -1313,6 +1317,8 @@ test-requirements.txt test/__init__.py test/components/__init__.py test/components/schema/__init__.py +test/components/schema/test_obj_with_required_props.py +test/components/schema/test_obj_with_required_props_base.py test/test_paths/__init__.py test/test_paths/__init__.py test/test_paths/__init__.py diff --git a/samples/openapi3/client/petstore/python/README.md b/samples/openapi3/client/petstore/python/README.md index 712acb1e865..0d9ef2e75cd 100644 --- a/samples/openapi3/client/petstore/python/README.md +++ b/samples/openapi3/client/petstore/python/README.md @@ -353,6 +353,8 @@ Class | Description [Number](docs/components/schema/number.md) | [NumberOnly](docs/components/schema/number_only.md) | [NumberWithValidations](docs/components/schema/number_with_validations.md) | +[ObjWithRequiredProps](docs/components/schema/obj_with_required_props.md) | +[ObjWithRequiredPropsBase](docs/components/schema/obj_with_required_props_base.md) | [ObjectInterface](docs/components/schema/object_interface.md) | [ObjectModelWithArgAndArgsProperties](docs/components/schema/object_model_with_arg_and_args_properties.md) | [ObjectModelWithRefProps](docs/components/schema/object_model_with_ref_props.md) | a model that includes properties which should stay primitive (String + Boolean) and one which is defined as a class, NumberWithValidations diff --git a/samples/openapi3/client/petstore/python/docs/components/schema/obj_with_required_props.md b/samples/openapi3/client/petstore/python/docs/components/schema/obj_with_required_props.md new file mode 100644 index 00000000000..7f9373fd856 --- /dev/null +++ b/samples/openapi3/client/petstore/python/docs/components/schema/obj_with_required_props.md @@ -0,0 +1,21 @@ +petstore_api.components.schema.obj_with_required_props +# Schema ObjWithRequiredProps + +## Type Info +Input Type | Accessed Type | Description | Notes +------------ | ------------- | ------------- | ------------- +dict, frozendict.frozendict | frozendict.frozendict | | + +## Dictionary Keys +Key | Input Type | Accessed Type | Description | Notes +------------ | ------------- | ------------- | ------------- | ------------- +**a** | str | str | | +**any_string_name** | dict, frozendict.frozendict, list, tuple, decimal.Decimal, float, int, str, datetime.date, datetime.datetime, uuid.UUID, bool, None, bytes, io.FileIO, io.BufferedReader, schemas.Schema | frozendict.frozendict, tuple, decimal.Decimal, str, bytes, BoolClass, NoneClass, FileIO | any string name can be used but the value must be the correct type | [optional] + +## Composed Schemas (allOf/anyOf/oneOf/not) +## allOf +Class Name | Input Type | Accessed Type | Description | Notes +------------- | ------------- | ------------- | ------------- | ------------- +[**ObjWithRequiredPropsBase**](obj_with_required_props_base.md) | [**ObjWithRequiredPropsBase**](obj_with_required_props_base.md) | [**ObjWithRequiredPropsBase**](obj_with_required_props_base.md) | | + +[[Back to top]](#top) [[Back to Component Schemas]](../../../README.md#Component-Schemas) [[Back to README]](../../../README.md) diff --git a/samples/openapi3/client/petstore/python/docs/components/schema/obj_with_required_props_base.md b/samples/openapi3/client/petstore/python/docs/components/schema/obj_with_required_props_base.md new file mode 100644 index 00000000000..9cd4cc39683 --- /dev/null +++ b/samples/openapi3/client/petstore/python/docs/components/schema/obj_with_required_props_base.md @@ -0,0 +1,15 @@ +petstore_api.components.schema.obj_with_required_props_base +# Schema ObjWithRequiredPropsBase + +## Type Info +Input Type | Accessed Type | Description | Notes +------------ | ------------- | ------------- | ------------- +dict, frozendict.frozendict | frozendict.frozendict | | + +## Dictionary Keys +Key | Input Type | Accessed Type | Description | Notes +------------ | ------------- | ------------- | ------------- | ------------- +**b** | str | str | | +**any_string_name** | dict, frozendict.frozendict, list, tuple, decimal.Decimal, float, int, str, datetime.date, datetime.datetime, uuid.UUID, bool, None, bytes, io.FileIO, io.BufferedReader, schemas.Schema | frozendict.frozendict, tuple, decimal.Decimal, str, bytes, BoolClass, NoneClass, FileIO | any string name can be used but the value must be the correct type | [optional] + +[[Back to top]](#top) [[Back to Component Schemas]](../../../README.md#Component-Schemas) [[Back to README]](../../../README.md) diff --git a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/abstract_step_message.py b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/abstract_step_message.py index 37cf763b0ea..c6416a3789f 100644 --- a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/abstract_step_message.py +++ b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/abstract_step_message.py @@ -69,12 +69,15 @@ def _0() -> typing.Type['AbstractStepMessage']: ] + @property def description(self) -> schemas.AnyTypeSchema: return self.__getitem__("description") + @property def discriminator(self) -> Schema_.Properties.Discriminator: return self.__getitem__("discriminator") + @property def sequenceNumber(self) -> schemas.AnyTypeSchema: return self.__getitem__("sequenceNumber") diff --git a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/animal.py b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/animal.py index 3edb6300519..0cc38c5113e 100644 --- a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/animal.py +++ b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/animal.py @@ -67,6 +67,7 @@ class Schema_: "color": Color, } + @property def className(self) -> Schema_.Properties.ClassName: return self.__getitem__("className") diff --git a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/apple.py b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/apple.py index 6d9a8fb829a..701956fc89d 100644 --- a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/apple.py +++ b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/apple.py @@ -81,6 +81,7 @@ class Schema_: } + @property def cultivar(self) -> Schema_.Properties.Cultivar: return self.__getitem__("cultivar") diff --git a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/apple_req.py b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/apple_req.py index 7987b72637d..095c33ef2cd 100644 --- a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/apple_req.py +++ b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/apple_req.py @@ -48,6 +48,7 @@ class Properties: } AdditionalProperties = schemas.NotAnyTypeSchema + @property def cultivar(self) -> Schema_.Properties.Cultivar: return self.__getitem__("cultivar") diff --git a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/banana.py b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/banana.py index cca3d12c457..8ddf52740b1 100644 --- a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/banana.py +++ b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/banana.py @@ -45,6 +45,7 @@ class Properties: "lengthCm": LengthCm, } + @property def lengthCm(self) -> Schema_.Properties.LengthCm: return self.__getitem__("lengthCm") diff --git a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/banana_req.py b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/banana_req.py index fb30814d9f3..b9a8db83c42 100644 --- a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/banana_req.py +++ b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/banana_req.py @@ -48,6 +48,7 @@ class Properties: } AdditionalProperties = schemas.NotAnyTypeSchema + @property def lengthCm(self) -> Schema_.Properties.LengthCm: return self.__getitem__("lengthCm") diff --git a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/basque_pig.py b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/basque_pig.py index af4775adac8..5e3c3f188b5 100644 --- a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/basque_pig.py +++ b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/basque_pig.py @@ -62,6 +62,7 @@ def BASQUE_PIG(cls): "className": ClassName, } + @property def className(self) -> Schema_.Properties.ClassName: return self.__getitem__("className") diff --git a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/category.py b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/category.py index 3bb0015f9b4..140746addd1 100644 --- a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/category.py +++ b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/category.py @@ -58,6 +58,7 @@ class Schema_: "name": Name, } + @property def name(self) -> Schema_.Properties.Name: return self.__getitem__("name") diff --git a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/danish_pig.py b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/danish_pig.py index 4563df37012..c4ad936737b 100644 --- a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/danish_pig.py +++ b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/danish_pig.py @@ -62,6 +62,7 @@ def DANISH_PIG(cls): "className": ClassName, } + @property def className(self) -> Schema_.Properties.ClassName: return self.__getitem__("className") diff --git a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/enum_test.py b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/enum_test.py index f1f018620b2..e88551da3a5 100644 --- a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/enum_test.py +++ b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/enum_test.py @@ -176,6 +176,7 @@ def integer_enum_one_value() -> typing.Type['integer_enum_one_value.IntegerEnumO "IntegerEnumOneValue": integer_enum_one_value, } + @property def enum_string_required(self) -> Schema_.Properties.EnumStringRequired: return self.__getitem__("enum_string_required") diff --git a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/format_test.py b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/format_test.py index 585cbde709d..d89c0b7bd8c 100644 --- a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/format_test.py +++ b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/format_test.py @@ -239,15 +239,19 @@ class Schema_: "noneProp": NoneProp, } + @property def byte(self) -> Schema_.Properties.Byte: return self.__getitem__("byte") + @property def date(self) -> Schema_.Properties.Date: return self.__getitem__("date") + @property def number(self) -> Schema_.Properties.Number: return self.__getitem__("number") + @property def password(self) -> Schema_.Properties.Password: return self.__getitem__("password") diff --git a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/grandparent_animal.py b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/grandparent_animal.py index 673e5a4d224..45deb9d9f95 100644 --- a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/grandparent_animal.py +++ b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/grandparent_animal.py @@ -54,6 +54,7 @@ class Properties: "pet_type": PetType, } + @property def pet_type(self) -> Schema_.Properties.PetType: return self.__getitem__("pet_type") diff --git a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/json_patch_request_add_replace_test.py b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/json_patch_request_add_replace_test.py index b4c7f7cb149..938109f28de 100644 --- a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/json_patch_request_add_replace_test.py +++ b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/json_patch_request_add_replace_test.py @@ -79,12 +79,15 @@ def TEST(cls): } AdditionalProperties = schemas.NotAnyTypeSchema + @property def op(self) -> Schema_.Properties.Op: return self.__getitem__("op") + @property def path(self) -> Schema_.Properties.Path: return self.__getitem__("path") + @property def value(self) -> Schema_.Properties.Value: return self.__getitem__("value") diff --git a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/json_patch_request_move_copy.py b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/json_patch_request_move_copy.py index dfc62a48f83..9bdb85ec755 100644 --- a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/json_patch_request_move_copy.py +++ b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/json_patch_request_move_copy.py @@ -74,9 +74,11 @@ def COPY(cls): } AdditionalProperties = schemas.NotAnyTypeSchema + @property def op(self) -> Schema_.Properties.Op: return self.__getitem__("op") + @property def path(self) -> Schema_.Properties.Path: return self.__getitem__("path") diff --git a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/json_patch_request_remove.py b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/json_patch_request_remove.py index ef38aca3211..1505a34635f 100644 --- a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/json_patch_request_remove.py +++ b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/json_patch_request_remove.py @@ -66,9 +66,11 @@ def REMOVE(cls): } AdditionalProperties = schemas.NotAnyTypeSchema + @property def op(self) -> Schema_.Properties.Op: return self.__getitem__("op") + @property def path(self) -> Schema_.Properties.Path: return self.__getitem__("path") diff --git a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/money.py b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/money.py index f68c06f902d..c95191bfd04 100644 --- a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/money.py +++ b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/money.py @@ -51,9 +51,11 @@ def currency() -> typing.Type['currency.Currency']: "currency": currency, } + @property def amount(self) -> Schema_.Properties.Amount: return self.__getitem__("amount") + @property def currency(self) -> 'currency.Currency': return self.__getitem__("currency") diff --git a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/name.py b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/name.py index 12dcfd57d94..de5e9526956 100644 --- a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/name.py +++ b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/name.py @@ -52,6 +52,7 @@ class Properties: } + @property def name(self) -> Schema_.Properties.Name: return self.__getitem__("name") diff --git a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/no_additional_properties.py b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/no_additional_properties.py index d31835a6fdf..ce2bec4449b 100644 --- a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/no_additional_properties.py +++ b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/no_additional_properties.py @@ -48,6 +48,7 @@ class Properties: } AdditionalProperties = schemas.NotAnyTypeSchema + @property def id(self) -> Schema_.Properties.Id: return self.__getitem__("id") diff --git a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/obj_with_required_props.py b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/obj_with_required_props.py new file mode 100644 index 00000000000..4dcb8d2784f --- /dev/null +++ b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/obj_with_required_props.py @@ -0,0 +1,110 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://github.com/openapi-json-schema-tools/openapi-json-schema-generator +""" + +import datetime # noqa: F401 +import decimal # noqa: F401 +import functools # noqa: F401 +import io # noqa: F401 +import re # noqa: F401 +import typing # noqa: F401 +import typing_extensions # noqa: F401 +import uuid # noqa: F401 + +import frozendict # noqa: F401 + +from petstore_api import schemas # noqa: F401 + + +class ObjWithRequiredProps( + schemas.DictSchema +): + """NOTE: This class is auto generated by OpenAPI JSON Schema Generator. + Ref: https://github.com/openapi-json-schema-tools/openapi-json-schema-generator + + Do not edit the class manually. + """ + + + class Schema_: + types = { + frozendict.frozendict, + } + required = { + "a", + } + + class Properties: + A = schemas.StrSchema + __annotations__ = { + "a": A, + } + + class AllOf: + + @staticmethod + def _0() -> typing.Type['obj_with_required_props_base.ObjWithRequiredPropsBase']: + return obj_with_required_props_base.ObjWithRequiredPropsBase + classes = [ + _0, + ] + + + @property + def a(self) -> Schema_.Properties.A: + return self.__getitem__("a") + + @typing.overload + def __getitem__(self, name: typing_extensions.Literal["a"]) -> Schema_.Properties.A: ... + + @typing.overload + def __getitem__(self, name: str) -> schemas.UnsetAnyTypeSchema: ... + + def __getitem__( + self, + name: typing.Union[ + typing_extensions.Literal["a"], + str + ] + ): + # dict_instance[name] accessor + return super().__getitem__(name) + + @typing.overload + def get_item_(self, name: typing_extensions.Literal["a"]) -> Schema_.Properties.A: ... + + @typing.overload + def get_item_(self, name: str) -> typing.Union[schemas.UnsetAnyTypeSchema, schemas.Unset]: ... + + def get_item_( + self, + name: typing.Union[ + typing_extensions.Literal["a"], + str + ] + ): + return super().get_item_(name) + + def __new__( + cls, + *args_: typing.Union[dict, frozendict.frozendict], + a: typing.Union[Schema_.Properties.A, str], + configuration_: typing.Optional[schemas.schema_configuration.SchemaConfiguration] = None, + **kwargs: typing.Union[dict, frozendict.frozendict, list, tuple, decimal.Decimal, float, int, str, datetime.date, datetime.datetime, uuid.UUID, bool, None, bytes, io.FileIO, io.BufferedReader, schemas.Schema], + ) -> 'ObjWithRequiredProps': + return super().__new__( + cls, + *args_, + a=a, + configuration_=configuration_, + **kwargs, + ) + +from petstore_api.components.schema import obj_with_required_props_base diff --git a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/obj_with_required_props_base.py b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/obj_with_required_props_base.py new file mode 100644 index 00000000000..c85b0b407be --- /dev/null +++ b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/obj_with_required_props_base.py @@ -0,0 +1,96 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://github.com/openapi-json-schema-tools/openapi-json-schema-generator +""" + +import datetime # noqa: F401 +import decimal # noqa: F401 +import functools # noqa: F401 +import io # noqa: F401 +import re # noqa: F401 +import typing # noqa: F401 +import typing_extensions # noqa: F401 +import uuid # noqa: F401 + +import frozendict # noqa: F401 + +from petstore_api import schemas # noqa: F401 + + +class ObjWithRequiredPropsBase( + schemas.DictSchema +): + """NOTE: This class is auto generated by OpenAPI JSON Schema Generator. + Ref: https://github.com/openapi-json-schema-tools/openapi-json-schema-generator + + Do not edit the class manually. + """ + + + class Schema_: + types = {frozendict.frozendict} + required = { + "b", + } + + class Properties: + B = schemas.StrSchema + __annotations__ = { + "b": B, + } + + @property + def b(self) -> Schema_.Properties.B: + return self.__getitem__("b") + + @typing.overload + def __getitem__(self, name: typing_extensions.Literal["b"]) -> Schema_.Properties.B: ... + + @typing.overload + def __getitem__(self, name: str) -> schemas.UnsetAnyTypeSchema: ... + + def __getitem__( + self, + name: typing.Union[ + typing_extensions.Literal["b"], + str + ] + ): + # dict_instance[name] accessor + return super().__getitem__(name) + + @typing.overload + def get_item_(self, name: typing_extensions.Literal["b"]) -> Schema_.Properties.B: ... + + @typing.overload + def get_item_(self, name: str) -> typing.Union[schemas.UnsetAnyTypeSchema, schemas.Unset]: ... + + def get_item_( + self, + name: typing.Union[ + typing_extensions.Literal["b"], + str + ] + ): + return super().get_item_(name) + + def __new__( + cls, + *args_: typing.Union[dict, frozendict.frozendict], + b: typing.Union[Schema_.Properties.B, str], + configuration_: typing.Optional[schemas.schema_configuration.SchemaConfiguration] = None, + **kwargs: typing.Union[dict, frozendict.frozendict, list, tuple, decimal.Decimal, float, int, str, datetime.date, datetime.datetime, uuid.UUID, bool, None, bytes, io.FileIO, io.BufferedReader, schemas.Schema], + ) -> 'ObjWithRequiredPropsBase': + return super().__new__( + cls, + *args_, + b=b, + configuration_=configuration_, + **kwargs, + ) diff --git a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/object_model_with_arg_and_args_properties.py b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/object_model_with_arg_and_args_properties.py index 63f6187c29c..b0c60d74934 100644 --- a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/object_model_with_arg_and_args_properties.py +++ b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/object_model_with_arg_and_args_properties.py @@ -48,9 +48,11 @@ class Properties: "args": Args, } + @property def arg(self) -> Schema_.Properties.Arg: return self.__getitem__("arg") + @property def args(self) -> Schema_.Properties.Args: return self.__getitem__("args") diff --git a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/object_with_all_of_with_req_test_prop_from_unset_add_prop.py b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/object_with_all_of_with_req_test_prop_from_unset_add_prop.py index 9643cb48efb..91d59373fe0 100644 --- a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/object_with_all_of_with_req_test_prop_from_unset_add_prop.py +++ b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/object_with_all_of_with_req_test_prop_from_unset_add_prop.py @@ -60,6 +60,7 @@ class Properties: "name": Name, } + @property def test(self) -> schemas.AnyTypeSchema: return self.__getitem__("test") diff --git a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/pet.py b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/pet.py index a30f713f85f..316f1f6be99 100644 --- a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/pet.py +++ b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/pet.py @@ -151,9 +151,11 @@ def SOLD(cls): "status": Status, } + @property def name(self) -> Schema_.Properties.Name: return self.__getitem__("name") + @property def photoUrls(self) -> Schema_.Properties.PhotoUrls: return self.__getitem__("photoUrls") diff --git a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/quadrilateral_interface.py b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/quadrilateral_interface.py index 1a9d0d1cb3b..e70ae484cce 100644 --- a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/quadrilateral_interface.py +++ b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/quadrilateral_interface.py @@ -66,9 +66,11 @@ def QUADRILATERAL(cls): } + @property def quadrilateralType(self) -> Schema_.Properties.QuadrilateralType: return self.__getitem__("quadrilateralType") + @property def shapeType(self) -> Schema_.Properties.ShapeType: return self.__getitem__("shapeType") diff --git a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/req_props_from_explicit_add_props.py b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/req_props_from_explicit_add_props.py index acf1fe24848..bb7f1e3f28a 100644 --- a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/req_props_from_explicit_add_props.py +++ b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/req_props_from_explicit_add_props.py @@ -41,6 +41,7 @@ class Schema_: } AdditionalProperties = schemas.StrSchema + @property def validName(self) -> Schema_.AdditionalProperties: return self.__getitem__("validName") diff --git a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/req_props_from_true_add_props.py b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/req_props_from_true_add_props.py index d94da888d80..193ddbf5502 100644 --- a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/req_props_from_true_add_props.py +++ b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/req_props_from_true_add_props.py @@ -41,6 +41,7 @@ class Schema_: } AdditionalProperties = schemas.AnyTypeSchema + @property def validName(self) -> Schema_.AdditionalProperties: return self.__getitem__("validName") diff --git a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/req_props_from_unset_add_props.py b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/req_props_from_unset_add_props.py index 5a134b07d52..9fc03928c3a 100644 --- a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/req_props_from_unset_add_props.py +++ b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/req_props_from_unset_add_props.py @@ -40,6 +40,7 @@ class Schema_: "validName", } + @property def validName(self) -> schemas.AnyTypeSchema: return self.__getitem__("validName") diff --git a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/triangle_interface.py b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/triangle_interface.py index dc757a61d45..15ccdad867c 100644 --- a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/triangle_interface.py +++ b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/triangle_interface.py @@ -66,9 +66,11 @@ def TRIANGLE(cls): } + @property def shapeType(self) -> Schema_.Properties.ShapeType: return self.__getitem__("shapeType") + @property def triangleType(self) -> Schema_.Properties.TriangleType: return self.__getitem__("triangleType") diff --git a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/whale.py b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/whale.py index dadd08bd909..a5f2c6458c9 100644 --- a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/whale.py +++ b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/whale.py @@ -66,6 +66,7 @@ def WHALE(cls): "className": ClassName, } + @property def className(self) -> Schema_.Properties.ClassName: return self.__getitem__("className") diff --git a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/zebra.py b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/zebra.py index 72f5c7fb89b..65c736f8602 100644 --- a/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/zebra.py +++ b/samples/openapi3/client/petstore/python/src/petstore_api/components/schema/zebra.py @@ -92,6 +92,7 @@ def ZEBRA(cls): } AdditionalProperties = schemas.AnyTypeSchema + @property def className(self) -> Schema_.Properties.ClassName: return self.__getitem__("className") diff --git a/samples/openapi3/client/petstore/python/src/petstore_api/components/schemas/__init__.py b/samples/openapi3/client/petstore/python/src/petstore_api/components/schemas/__init__.py index b9d89f5d808..5544b26a5ba 100644 --- a/samples/openapi3/client/petstore/python/src/petstore_api/components/schemas/__init__.py +++ b/samples/openapi3/client/petstore/python/src/petstore_api/components/schemas/__init__.py @@ -89,6 +89,8 @@ from petstore_api.components.schema.number import Number from petstore_api.components.schema.number_only import NumberOnly from petstore_api.components.schema.number_with_validations import NumberWithValidations +from petstore_api.components.schema.obj_with_required_props import ObjWithRequiredProps +from petstore_api.components.schema.obj_with_required_props_base import ObjWithRequiredPropsBase from petstore_api.components.schema.object_interface import ObjectInterface from petstore_api.components.schema.object_model_with_arg_and_args_properties import ObjectModelWithArgAndArgsProperties from petstore_api.components.schema.object_model_with_ref_props import ObjectModelWithRefProps diff --git a/samples/openapi3/client/petstore/python/src/petstore_api/paths/fake/post/request_body/content/application_x_www_form_urlencoded/schema.py b/samples/openapi3/client/petstore/python/src/petstore_api/paths/fake/post/request_body/content/application_x_www_form_urlencoded/schema.py index 31545d6e9dc..73c51d6c942 100644 --- a/samples/openapi3/client/petstore/python/src/petstore_api/paths/fake/post/request_body/content/application_x_www_form_urlencoded/schema.py +++ b/samples/openapi3/client/petstore/python/src/petstore_api/paths/fake/post/request_body/content/application_x_www_form_urlencoded/schema.py @@ -183,15 +183,19 @@ class Schema_: "callback": Callback, } + @property def byte(self) -> Schema_.Properties.Byte: return self.__getitem__("byte") + @property def double(self) -> Schema_.Properties.Double: return self.__getitem__("double") + @property def number(self) -> Schema_.Properties.Number: return self.__getitem__("number") + @property def pattern_without_delimiter(self) -> Schema_.Properties.PatternWithoutDelimiter: return self.__getitem__("pattern_without_delimiter") diff --git a/samples/openapi3/client/petstore/python/src/petstore_api/paths/fake_json_form_data/get/request_body/content/application_x_www_form_urlencoded/schema.py b/samples/openapi3/client/petstore/python/src/petstore_api/paths/fake_json_form_data/get/request_body/content/application_x_www_form_urlencoded/schema.py index 4d6234fa200..9f5707c3d53 100644 --- a/samples/openapi3/client/petstore/python/src/petstore_api/paths/fake_json_form_data/get/request_body/content/application_x_www_form_urlencoded/schema.py +++ b/samples/openapi3/client/petstore/python/src/petstore_api/paths/fake_json_form_data/get/request_body/content/application_x_www_form_urlencoded/schema.py @@ -43,9 +43,11 @@ class Properties: "param2": Param2, } + @property def param(self) -> Schema_.Properties.Param: return self.__getitem__("param") + @property def param2(self) -> Schema_.Properties.Param2: return self.__getitem__("param2") diff --git a/samples/openapi3/client/petstore/python/src/petstore_api/paths/fake_pet_id_upload_image_with_required_file/post/request_body/content/multipart_form_data/schema.py b/samples/openapi3/client/petstore/python/src/petstore_api/paths/fake_pet_id_upload_image_with_required_file/post/request_body/content/multipart_form_data/schema.py index b6fcf6dbef5..cf738d932ca 100644 --- a/samples/openapi3/client/petstore/python/src/petstore_api/paths/fake_pet_id_upload_image_with_required_file/post/request_body/content/multipart_form_data/schema.py +++ b/samples/openapi3/client/petstore/python/src/petstore_api/paths/fake_pet_id_upload_image_with_required_file/post/request_body/content/multipart_form_data/schema.py @@ -42,6 +42,7 @@ class Properties: "requiredFile": RequiredFile, } + @property def requiredFile(self) -> Schema_.Properties.RequiredFile: return self.__getitem__("requiredFile") diff --git a/samples/openapi3/client/petstore/python/src/petstore_api/paths/fake_upload_file/post/request_body/content/multipart_form_data/schema.py b/samples/openapi3/client/petstore/python/src/petstore_api/paths/fake_upload_file/post/request_body/content/multipart_form_data/schema.py index dc0dc30e889..61da8336e57 100644 --- a/samples/openapi3/client/petstore/python/src/petstore_api/paths/fake_upload_file/post/request_body/content/multipart_form_data/schema.py +++ b/samples/openapi3/client/petstore/python/src/petstore_api/paths/fake_upload_file/post/request_body/content/multipart_form_data/schema.py @@ -42,6 +42,7 @@ class Properties: "file": File, } + @property def file(self) -> Schema_.Properties.File: return self.__getitem__("file") diff --git a/samples/openapi3/client/petstore/python/test/components/schema/test_obj_with_required_props.py b/samples/openapi3/client/petstore/python/test/components/schema/test_obj_with_required_props.py new file mode 100644 index 00000000000..9d0e03d057a --- /dev/null +++ b/samples/openapi3/client/petstore/python/test/components/schema/test_obj_with_required_props.py @@ -0,0 +1,25 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://github.com/openapi-json-schema-tools/openapi-json-schema-generator +""" + +import unittest + +import petstore_api +from petstore_api.components.schema.obj_with_required_props import ObjWithRequiredProps +from petstore_api.configurations import schema_configuration + + +class TestObjWithRequiredProps(unittest.TestCase): + """ObjWithRequiredProps unit test stubs""" + configuration_ = schema_configuration.SchemaConfiguration() + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python/test/components/schema/test_obj_with_required_props_base.py b/samples/openapi3/client/petstore/python/test/components/schema/test_obj_with_required_props_base.py new file mode 100644 index 00000000000..9e56259633c --- /dev/null +++ b/samples/openapi3/client/petstore/python/test/components/schema/test_obj_with_required_props_base.py @@ -0,0 +1,25 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://github.com/openapi-json-schema-tools/openapi-json-schema-generator +""" + +import unittest + +import petstore_api +from petstore_api.components.schema.obj_with_required_props_base import ObjWithRequiredPropsBase +from petstore_api.configurations import schema_configuration + + +class TestObjWithRequiredPropsBase(unittest.TestCase): + """ObjWithRequiredPropsBase unit test stubs""" + configuration_ = schema_configuration.SchemaConfiguration() + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python/tests_manual/test_obj_with_required_props.py b/samples/openapi3/client/petstore/python/tests_manual/test_obj_with_required_props.py new file mode 100644 index 00000000000..cf6c9de9a39 --- /dev/null +++ b/samples/openapi3/client/petstore/python/tests_manual/test_obj_with_required_props.py @@ -0,0 +1,31 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://github.com/openapi-json-schema-tools/openapi-json-schema-generator +""" + +import unittest + +from petstore_api.components.schema.obj_with_required_props import ObjWithRequiredProps +from petstore_api.components.schema.obj_with_required_props_base import ObjWithRequiredPropsBase +from petstore_api.configurations import schema_configuration + + +class TestObjWithRequiredProps(unittest.TestCase): + """ObjWithRequiredProps unit test stubs""" + configuration_ = schema_configuration.SchemaConfiguration() + obj = ObjWithRequiredProps(a='a', b='b') + assert isinstance(obj, ObjWithRequiredProps) and isinstance(obj, ObjWithRequiredPropsBase) + a = obj.a + assert isinstance(a, ObjWithRequiredProps.Schema_.Properties.A) + b = obj.b + assert isinstance(a, ObjWithRequiredPropsBase.Schema_.Properties.B) + + +if __name__ == '__main__': + unittest.main() From 8488783f31139bcfef71126f24dd70cac528be63 Mon Sep 17 00:00:00 2001 From: Justin Black Date: Wed, 17 May 2023 10:00:40 -0700 Subject: [PATCH 3/3] Samples regenerated --- .../unit_test_api/components/schema/allof.py | 8 ++++++-- .../schema/allof_with_base_schema.py | 12 +++++++++--- .../components/schema/anyof_complex_types.py | 8 ++++++-- .../components/schema/enums_in_properties.py | 4 +++- .../components/schema/oneof_complex_types.py | 8 ++++++-- .../components/schema/oneof_with_required.py | 18 ++++++++++++++---- .../components/schema/required_validation.py | 4 +++- .../schema/required_with_escaped_characters.py | 1 - .../python/src/unit_test_api/schemas.py | 16 ---------------- .../components/schema/addition_operator.py | 14 +++++++++++--- .../components/schema/subtraction_operator.py | 14 +++++++++++--- .../python/src/this_package/schemas.py | 16 ---------------- .../python/src/this_package/schemas.py | 16 ---------------- .../petstore/python/.openapi-generator/FILES | 2 -- .../petstore/python/.openapi-generator/VERSION | 2 +- 15 files changed, 70 insertions(+), 73 deletions(-) diff --git a/samples/openapi3/client/3_0_3_unit_test/python/src/unit_test_api/components/schema/allof.py b/samples/openapi3/client/3_0_3_unit_test/python/src/unit_test_api/components/schema/allof.py index d59cba1f34a..ab2fe5fcd01 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python/src/unit_test_api/components/schema/allof.py +++ b/samples/openapi3/client/3_0_3_unit_test/python/src/unit_test_api/components/schema/allof.py @@ -57,7 +57,9 @@ class Properties: } - bar: Schema_.Properties.Bar + @property + def bar(self) -> Schema_.Properties.Bar: + return self.__getitem__("bar") @typing.overload def __getitem__(self, name: typing_extensions.Literal["bar"]) -> Schema_.Properties.Bar: ... @@ -122,7 +124,9 @@ class Properties: } - foo: Schema_.Properties.Foo + @property + def foo(self) -> Schema_.Properties.Foo: + return self.__getitem__("foo") @typing.overload def __getitem__(self, name: typing_extensions.Literal["foo"]) -> Schema_.Properties.Foo: ... diff --git a/samples/openapi3/client/3_0_3_unit_test/python/src/unit_test_api/components/schema/allof_with_base_schema.py b/samples/openapi3/client/3_0_3_unit_test/python/src/unit_test_api/components/schema/allof_with_base_schema.py index e2bdc0f5532..990468cf488 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python/src/unit_test_api/components/schema/allof_with_base_schema.py +++ b/samples/openapi3/client/3_0_3_unit_test/python/src/unit_test_api/components/schema/allof_with_base_schema.py @@ -66,7 +66,9 @@ class Properties: } - foo: Schema_.Properties.Foo + @property + def foo(self) -> Schema_.Properties.Foo: + return self.__getitem__("foo") @typing.overload def __getitem__(self, name: typing_extensions.Literal["foo"]) -> Schema_.Properties.Foo: ... @@ -131,7 +133,9 @@ class Properties: } - baz: Schema_.Properties.Baz + @property + def baz(self) -> Schema_.Properties.Baz: + return self.__getitem__("baz") @typing.overload def __getitem__(self, name: typing_extensions.Literal["baz"]) -> Schema_.Properties.Baz: ... @@ -182,7 +186,9 @@ def __new__( ] - bar: Schema_.Properties.Bar + @property + def bar(self) -> Schema_.Properties.Bar: + return self.__getitem__("bar") @typing.overload def __getitem__(self, name: typing_extensions.Literal["bar"]) -> Schema_.Properties.Bar: ... diff --git a/samples/openapi3/client/3_0_3_unit_test/python/src/unit_test_api/components/schema/anyof_complex_types.py b/samples/openapi3/client/3_0_3_unit_test/python/src/unit_test_api/components/schema/anyof_complex_types.py index 369d05dac81..cfa50744a33 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python/src/unit_test_api/components/schema/anyof_complex_types.py +++ b/samples/openapi3/client/3_0_3_unit_test/python/src/unit_test_api/components/schema/anyof_complex_types.py @@ -57,7 +57,9 @@ class Properties: } - bar: Schema_.Properties.Bar + @property + def bar(self) -> Schema_.Properties.Bar: + return self.__getitem__("bar") @typing.overload def __getitem__(self, name: typing_extensions.Literal["bar"]) -> Schema_.Properties.Bar: ... @@ -122,7 +124,9 @@ class Properties: } - foo: Schema_.Properties.Foo + @property + def foo(self) -> Schema_.Properties.Foo: + return self.__getitem__("foo") @typing.overload def __getitem__(self, name: typing_extensions.Literal["foo"]) -> Schema_.Properties.Foo: ... diff --git a/samples/openapi3/client/3_0_3_unit_test/python/src/unit_test_api/components/schema/enums_in_properties.py b/samples/openapi3/client/3_0_3_unit_test/python/src/unit_test_api/components/schema/enums_in_properties.py index f95a658bc80..cb25387f131 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python/src/unit_test_api/components/schema/enums_in_properties.py +++ b/samples/openapi3/client/3_0_3_unit_test/python/src/unit_test_api/components/schema/enums_in_properties.py @@ -81,7 +81,9 @@ def BAR(cls): "bar": Bar, } - bar: Schema_.Properties.Bar + @property + def bar(self) -> Schema_.Properties.Bar: + return self.__getitem__("bar") @typing.overload def __getitem__(self, name: typing_extensions.Literal["bar"]) -> Schema_.Properties.Bar: ... diff --git a/samples/openapi3/client/3_0_3_unit_test/python/src/unit_test_api/components/schema/oneof_complex_types.py b/samples/openapi3/client/3_0_3_unit_test/python/src/unit_test_api/components/schema/oneof_complex_types.py index 78d7807fc35..36817f9742d 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python/src/unit_test_api/components/schema/oneof_complex_types.py +++ b/samples/openapi3/client/3_0_3_unit_test/python/src/unit_test_api/components/schema/oneof_complex_types.py @@ -57,7 +57,9 @@ class Properties: } - bar: Schema_.Properties.Bar + @property + def bar(self) -> Schema_.Properties.Bar: + return self.__getitem__("bar") @typing.overload def __getitem__(self, name: typing_extensions.Literal["bar"]) -> Schema_.Properties.Bar: ... @@ -122,7 +124,9 @@ class Properties: } - foo: Schema_.Properties.Foo + @property + def foo(self) -> Schema_.Properties.Foo: + return self.__getitem__("foo") @typing.overload def __getitem__(self, name: typing_extensions.Literal["foo"]) -> Schema_.Properties.Foo: ... diff --git a/samples/openapi3/client/3_0_3_unit_test/python/src/unit_test_api/components/schema/oneof_with_required.py b/samples/openapi3/client/3_0_3_unit_test/python/src/unit_test_api/components/schema/oneof_with_required.py index 497b4b7601c..ea9063bd197 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python/src/unit_test_api/components/schema/oneof_with_required.py +++ b/samples/openapi3/client/3_0_3_unit_test/python/src/unit_test_api/components/schema/oneof_with_required.py @@ -54,8 +54,13 @@ class Schema_: } - bar: schemas.AnyTypeSchema - foo: schemas.AnyTypeSchema + @property + def bar(self) -> schemas.AnyTypeSchema: + return self.__getitem__("bar") + + @property + def foo(self) -> schemas.AnyTypeSchema: + return self.__getitem__("foo") @typing.overload def __getitem__(self, name: typing_extensions.Literal["bar"]) -> schemas.AnyTypeSchema: ... @@ -123,8 +128,13 @@ class Schema_: } - baz: schemas.AnyTypeSchema - foo: schemas.AnyTypeSchema + @property + def baz(self) -> schemas.AnyTypeSchema: + return self.__getitem__("baz") + + @property + def foo(self) -> schemas.AnyTypeSchema: + return self.__getitem__("foo") @typing.overload def __getitem__(self, name: typing_extensions.Literal["baz"]) -> schemas.AnyTypeSchema: ... diff --git a/samples/openapi3/client/3_0_3_unit_test/python/src/unit_test_api/components/schema/required_validation.py b/samples/openapi3/client/3_0_3_unit_test/python/src/unit_test_api/components/schema/required_validation.py index f064a323d5d..0723117703a 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python/src/unit_test_api/components/schema/required_validation.py +++ b/samples/openapi3/client/3_0_3_unit_test/python/src/unit_test_api/components/schema/required_validation.py @@ -48,7 +48,9 @@ class Properties: } - foo: Schema_.Properties.Foo + @property + def foo(self) -> Schema_.Properties.Foo: + return self.__getitem__("foo") @typing.overload def __getitem__(self, name: typing_extensions.Literal["foo"]) -> Schema_.Properties.Foo: ... diff --git a/samples/openapi3/client/3_0_3_unit_test/python/src/unit_test_api/components/schema/required_with_escaped_characters.py b/samples/openapi3/client/3_0_3_unit_test/python/src/unit_test_api/components/schema/required_with_escaped_characters.py index 45ec5182624..672efa30e72 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python/src/unit_test_api/components/schema/required_with_escaped_characters.py +++ b/samples/openapi3/client/3_0_3_unit_test/python/src/unit_test_api/components/schema/required_with_escaped_characters.py @@ -45,7 +45,6 @@ class Schema_: } - @typing.overload def __getitem__(self, name: typing_extensions.Literal["foo\tbar"]) -> schemas.AnyTypeSchema: ... diff --git a/samples/openapi3/client/3_0_3_unit_test/python/src/unit_test_api/schemas.py b/samples/openapi3/client/3_0_3_unit_test/python/src/unit_test_api/schemas.py index 54ebc6c8307..48b94413bc1 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python/src/unit_test_api/schemas.py +++ b/samples/openapi3/client/3_0_3_unit_test/python/src/unit_test_api/schemas.py @@ -1896,22 +1896,6 @@ def __setattr__(self, name: str, value: typing.Any): if not isinstance(self, FileIO): raise AttributeError('property setting not supported on immutable instances') - def __getattr__(self, name: str): - """ - for instance.name access - Properties are only type hinted for required properties - so that hasattr(instance, 'optionalProp') is False when that key is not present - """ - if not isinstance(self, frozendict.frozendict): - return super().__getattr__(name) - if name not in self.__class__.__annotations__: - raise AttributeError(f"{self} has no attribute '{name}'") - try: - value = self[name] - return value - except KeyError as ex: - raise AttributeError(str(ex)) - def get_item_(self, name: str) -> typing.Union['AnyTypeSchema', Unset]: # dict_instance[name] accessor if not isinstance(self, frozendict.frozendict): diff --git a/samples/openapi3/client/features/nonCompliantUseDiscriminatorIfCompositionFails/python/src/this_package/components/schema/addition_operator.py b/samples/openapi3/client/features/nonCompliantUseDiscriminatorIfCompositionFails/python/src/this_package/components/schema/addition_operator.py index 5ba982a130d..f2a96e8de4b 100644 --- a/samples/openapi3/client/features/nonCompliantUseDiscriminatorIfCompositionFails/python/src/this_package/components/schema/addition_operator.py +++ b/samples/openapi3/client/features/nonCompliantUseDiscriminatorIfCompositionFails/python/src/this_package/components/schema/addition_operator.py @@ -63,9 +63,17 @@ class Schema_: } AdditionalProperties = schemas.NotAnyTypeSchema - a: Schema_.Properties.A - b: Schema_.Properties.B - operator_id: Schema_.Properties.OperatorId + @property + def a(self) -> Schema_.Properties.A: + return self.__getitem__("a") + + @property + def b(self) -> Schema_.Properties.B: + return self.__getitem__("b") + + @property + def operator_id(self) -> Schema_.Properties.OperatorId: + return self.__getitem__("operator_id") @typing.overload def __getitem__(self, name: typing_extensions.Literal["a"]) -> Schema_.Properties.A: ... diff --git a/samples/openapi3/client/features/nonCompliantUseDiscriminatorIfCompositionFails/python/src/this_package/components/schema/subtraction_operator.py b/samples/openapi3/client/features/nonCompliantUseDiscriminatorIfCompositionFails/python/src/this_package/components/schema/subtraction_operator.py index 01e7aca318e..1a9d3c322b7 100644 --- a/samples/openapi3/client/features/nonCompliantUseDiscriminatorIfCompositionFails/python/src/this_package/components/schema/subtraction_operator.py +++ b/samples/openapi3/client/features/nonCompliantUseDiscriminatorIfCompositionFails/python/src/this_package/components/schema/subtraction_operator.py @@ -63,9 +63,17 @@ class Schema_: } AdditionalProperties = schemas.NotAnyTypeSchema - a: Schema_.Properties.A - b: Schema_.Properties.B - operator_id: Schema_.Properties.OperatorId + @property + def a(self) -> Schema_.Properties.A: + return self.__getitem__("a") + + @property + def b(self) -> Schema_.Properties.B: + return self.__getitem__("b") + + @property + def operator_id(self) -> Schema_.Properties.OperatorId: + return self.__getitem__("operator_id") @typing.overload def __getitem__(self, name: typing_extensions.Literal["a"]) -> Schema_.Properties.A: ... diff --git a/samples/openapi3/client/features/nonCompliantUseDiscriminatorIfCompositionFails/python/src/this_package/schemas.py b/samples/openapi3/client/features/nonCompliantUseDiscriminatorIfCompositionFails/python/src/this_package/schemas.py index 0e76ad8bb9e..af7d4d6b5b4 100644 --- a/samples/openapi3/client/features/nonCompliantUseDiscriminatorIfCompositionFails/python/src/this_package/schemas.py +++ b/samples/openapi3/client/features/nonCompliantUseDiscriminatorIfCompositionFails/python/src/this_package/schemas.py @@ -1972,22 +1972,6 @@ def __setattr__(self, name: str, value: typing.Any): if not isinstance(self, FileIO): raise AttributeError('property setting not supported on immutable instances') - def __getattr__(self, name: str): - """ - for instance.name access - Properties are only type hinted for required properties - so that hasattr(instance, 'optionalProp') is False when that key is not present - """ - if not isinstance(self, frozendict.frozendict): - return super().__getattr__(name) - if name not in self.__class__.__annotations__: - raise AttributeError(f"{self} has no attribute '{name}'") - try: - value = self[name] - return value - except KeyError as ex: - raise AttributeError(str(ex)) - def get_item_(self, name: str) -> typing.Union['AnyTypeSchema', Unset]: # dict_instance[name] accessor if not isinstance(self, frozendict.frozendict): diff --git a/samples/openapi3/client/features/security/python/src/this_package/schemas.py b/samples/openapi3/client/features/security/python/src/this_package/schemas.py index 0a3b1cd5978..32be714cf34 100644 --- a/samples/openapi3/client/features/security/python/src/this_package/schemas.py +++ b/samples/openapi3/client/features/security/python/src/this_package/schemas.py @@ -1896,22 +1896,6 @@ def __setattr__(self, name: str, value: typing.Any): if not isinstance(self, FileIO): raise AttributeError('property setting not supported on immutable instances') - def __getattr__(self, name: str): - """ - for instance.name access - Properties are only type hinted for required properties - so that hasattr(instance, 'optionalProp') is False when that key is not present - """ - if not isinstance(self, frozendict.frozendict): - return super().__getattr__(name) - if name not in self.__class__.__annotations__: - raise AttributeError(f"{self} has no attribute '{name}'") - try: - value = self[name] - return value - except KeyError as ex: - raise AttributeError(str(ex)) - def get_item_(self, name: str) -> typing.Union['AnyTypeSchema', Unset]: # dict_instance[name] accessor if not isinstance(self, frozendict.frozendict): diff --git a/samples/openapi3/client/petstore/python/.openapi-generator/FILES b/samples/openapi3/client/petstore/python/.openapi-generator/FILES index 1bee4a7659c..4526279966c 100644 --- a/samples/openapi3/client/petstore/python/.openapi-generator/FILES +++ b/samples/openapi3/client/petstore/python/.openapi-generator/FILES @@ -1317,8 +1317,6 @@ test-requirements.txt test/__init__.py test/components/__init__.py test/components/schema/__init__.py -test/components/schema/test_obj_with_required_props.py -test/components/schema/test_obj_with_required_props_base.py test/test_paths/__init__.py test/test_paths/__init__.py test/test_paths/__init__.py diff --git a/samples/openapi3/client/petstore/python/.openapi-generator/VERSION b/samples/openapi3/client/petstore/python/.openapi-generator/VERSION index 717311e32e3..10bf840ed53 100644 --- a/samples/openapi3/client/petstore/python/.openapi-generator/VERSION +++ b/samples/openapi3/client/petstore/python/.openapi-generator/VERSION @@ -1 +1 @@ -unset \ No newline at end of file +2.0.1 \ No newline at end of file