Skip to content
This repository was archived by the owner on Dec 25, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ This means that one can use normal dict methods on instances of these classes.
- optional properties which were not set will not exist in the instance
- None is only allowed in as a value if type: "null" was included or nullable: true was set
- type hints are written for accessing values by key literals like instance["hi-there"]
- and there is a method instance.get_item_["hi-there"] which returns an schemas.Unset value if the key was not set
- required properties with valid python names are accessible with instance.SomeRequiredProp
which uses the exact key from the openapi document
- preserving the original key names is required to properly validate a payload to multiple json schemas
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,59 +53,4 @@ def __getitem__(self, name: str) -> {{#if refInfo.refClass}}'{{> components/sche
return super().__getitem__(name)
{{/unless}}
{{/with}}
{{/or}}
{{#if requiredProperties}}
{{#each requiredProperties}}
{{#with this}}

@typing.overload
{{#if refInfo.refClass}}
def get_item_(self, name: typing_extensions.Literal["{{{@key.original}}}"]) -> '{{> components/schemas/_helper_refclass_with_module }}': ...
{{else}}
{{#if jsonPathPiece}}
{{#if schemaIsFromAdditionalProperties}}
def get_item_(self, name: typing_extensions.Literal["{{{@key.original}}}"]) -> Schema_.{{jsonPathPiece.camelCase}}: ...
{{else}}
def get_item_(self, name: typing_extensions.Literal["{{{@key.original}}}"]) -> Schema_.Properties.{{jsonPathPiece.camelCase}}: ...
{{/if}}
{{else}}
def get_item_(self, name: typing_extensions.Literal["{{{@key.original}}}"]) -> schemas.AnyTypeSchema: ...
{{/if}}
{{/if}}
{{/with}}
{{/each}}
{{/if}}
{{#if optionalProperties}}
{{#each optionalProperties}}

@typing.overload
{{#if refInfo.refClass}}
def get_item_(self, name: typing_extensions.Literal["{{{@key.original}}}"]) -> typing.Union['{{> components/schemas/_helper_refclass_with_module }}', schemas.Unset]: ...
{{else}}
def get_item_(self, name: typing_extensions.Literal["{{{@key.original}}}"]) -> typing.Union[Schema_.Properties.{{jsonPathPiece.camelCase}}, schemas.Unset]: ...
{{/if}}
{{/each}}
{{/if}}
{{#or properties requiredProperties}}
{{#with additionalProperties}}
{{#unless isBooleanSchemaFalse}}

@typing.overload
def get_item_(self, name: str) -> typing.Union[{{#if refInfo.refClass}}'{{> components/schemas/_helper_refclass_with_module }}'{{else}}Schema_.{{jsonPathPiece.camelCase}}{{/if}}, schemas.Unset]: ...
{{/unless}}
{{else}}

@typing.overload
def get_item_(self, name: str) -> typing.Union[schemas.UnsetAnyTypeSchema, schemas.Unset]: ...
{{/with}}

{{> components/schemas/_helper_getitem methodName="get_item_" }}
{{else}}
{{#with additionalProperties}}
{{#unless isBooleanSchemaFalse}}

def get_item_(self, name: str) -> {{#if refInfo.refClass}}'{{> components/schemas/_helper_refclass_with_module }}'{{else}}Schema_.{{jsonPathPiece.camelCase}}{{/if}}:
return super().get_item_(name)
{{/unless}}
{{/with}}
{{/or}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Migration v2.0.0 to v3.0.0

- get_item_ methods have been removed to reduce amount of generated code
- instead use instance.get('someProp', schemas.unset)
- urllib3 has been downgraded from 2.0.a3 -> urllib3>=1.21.1,<1.27 required by requests == 2.28.2
- this change was required because oauth2 support was added and it uses the requests library
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,8 @@ When switching from other python client generators you will need to make some ch
- Only required keys with valid python names are properties like .someProp and have type hints
- All optional keys may not exist, so properties are not defined for them
- One can access optional values with dict_instance['optionalProp'] and KeyError will be raised if it does not exist
- Use get_item_ if you need a way to always get a value whether or not the key exists
- If the key does not exist, schemas.unset is returned from calling dict_instance.get_item_('optionalProp')
- All required and optional keys have type hints for this method, and @typing.overload is used
- A type hint is also generated for additionalProperties accessed using this method
- if you need a way to always get a value whether or not the key exists use:
- dict_instance.get('optionalProp', schemas.unset)
- So you will need to update you code to use some_instance['optionalProp'] to access optional property
and additionalProperty values
8. The location of the api classes has changed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2020,15 +2020,6 @@ class DictBase:
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):
raise NotImplementedError()
try:
return super().__getitem__(name)
except KeyError:
return unset


def cast_to_allowed_types(
arg: typing.Union[
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.0.0
3.0.0
1 change: 0 additions & 1 deletion samples/openapi3/client/3_0_3_unit_test/python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ This means that one can use normal dict methods on instances of these classes.
- optional properties which were not set will not exist in the instance
- None is only allowed in as a value if type: "null" was included or nullable: true was set
- type hints are written for accessing values by key literals like instance["hi-there"]
- and there is a method instance.get_item_["hi-there"] which returns an schemas.Unset value if the key was not set
- required properties with valid python names are accessible with instance.SomeRequiredProp
which uses the exact key from the openapi document
- preserving the original key names is required to properly validate a payload to multiple json schemas
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,8 @@ When switching from other python client generators you will need to make some ch
- Only required keys with valid python names are properties like .someProp and have type hints
- All optional keys may not exist, so properties are not defined for them
- One can access optional values with dict_instance['optionalProp'] and KeyError will be raised if it does not exist
- Use get_item_ if you need a way to always get a value whether or not the key exists
- If the key does not exist, schemas.unset is returned from calling dict_instance.get_item_('optionalProp')
- All required and optional keys have type hints for this method, and @typing.overload is used
- A type hint is also generated for additionalProperties accessed using this method
- if you need a way to always get a value whether or not the key exists use:
- dict_instance.get('optionalProp', schemas.unset)
- So you will need to update you code to use some_instance['optionalProp'] to access optional property
and additionalProperty values
8. The location of the api classes has changed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,25 +64,6 @@ def __getitem__(
):
# dict_instance[name] accessor
return super().__getitem__(name)

@typing.overload
def get_item_(self, name: typing_extensions.Literal["foo"]) -> typing.Union[Schema_.Properties.Foo, schemas.Unset]: ...

@typing.overload
def get_item_(self, name: typing_extensions.Literal["bar"]) -> typing.Union[Schema_.Properties.Bar, schemas.Unset]: ...

@typing.overload
def get_item_(self, name: str) -> typing.Union[Schema_.AdditionalProperties, schemas.Unset]: ...

def get_item_(
self,
name: typing.Union[
typing_extensions.Literal["foo"],
typing_extensions.Literal["bar"],
str
]
):
return super().get_item_(name)

def __new__(
cls,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,25 +64,6 @@ def __getitem__(
):
# dict_instance[name] accessor
return super().__getitem__(name)

@typing.overload
def get_item_(self, name: typing_extensions.Literal["foo"]) -> typing.Union[Schema_.Properties.Foo, schemas.Unset]: ...

@typing.overload
def get_item_(self, name: typing_extensions.Literal["bar"]) -> typing.Union[Schema_.Properties.Bar, schemas.Unset]: ...

@typing.overload
def get_item_(self, name: str) -> typing.Union[schemas.UnsetAnyTypeSchema, schemas.Unset]: ...

def get_item_(
self,
name: typing.Union[
typing_extensions.Literal["foo"],
typing_extensions.Literal["bar"],
str
]
):
return super().get_item_(name)

def __new__(
cls,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@ class Schema_:
def __getitem__(self, name: str) -> Schema_.AdditionalProperties:
# dict_instance[name] accessor
return super().__getitem__(name)

def get_item_(self, name: str) -> Schema_.AdditionalProperties:
return super().get_item_(name)

def __new__(
cls,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,21 +70,6 @@ def __getitem__(
):
# dict_instance[name] accessor
return super().__getitem__(name)

@typing.overload
def get_item_(self, name: typing_extensions.Literal["foo"]) -> typing.Union[Schema_.Properties.Foo, schemas.Unset]: ...

@typing.overload
def get_item_(self, name: str) -> typing.Union[schemas.UnsetAnyTypeSchema, schemas.Unset]: ...

def get_item_(
self,
name: typing.Union[
typing_extensions.Literal["foo"],
str
]
):
return super().get_item_(name)

def __new__(
cls,
Expand All @@ -108,9 +93,6 @@ def __new__(
def __getitem__(self, name: str) -> Schema_.AdditionalProperties:
# dict_instance[name] accessor
return super().__getitem__(name)

def get_item_(self, name: str) -> Schema_.AdditionalProperties:
return super().get_item_(name)

def __new__(
cls,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,21 +74,6 @@ def __getitem__(
):
# dict_instance[name] accessor
return super().__getitem__(name)

@typing.overload
def get_item_(self, name: typing_extensions.Literal["bar"]) -> Schema_.Properties.Bar: ...

@typing.overload
def get_item_(self, name: str) -> typing.Union[schemas.UnsetAnyTypeSchema, schemas.Unset]: ...

def get_item_(
self,
name: typing.Union[
typing_extensions.Literal["bar"],
str
]
):
return super().get_item_(name)

def __new__(
cls,
Expand Down Expand Up @@ -139,21 +124,6 @@ def __getitem__(
):
# dict_instance[name] accessor
return super().__getitem__(name)

@typing.overload
def get_item_(self, name: typing_extensions.Literal["foo"]) -> Schema_.Properties.Foo: ...

@typing.overload
def get_item_(self, name: str) -> typing.Union[schemas.UnsetAnyTypeSchema, schemas.Unset]: ...

def get_item_(
self,
name: typing.Union[
typing_extensions.Literal["foo"],
str
]
):
return super().get_item_(name)

def __new__(
cls,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,21 +83,6 @@ def __getitem__(
):
# dict_instance[name] accessor
return super().__getitem__(name)

@typing.overload
def get_item_(self, name: typing_extensions.Literal["foo"]) -> Schema_.Properties.Foo: ...

@typing.overload
def get_item_(self, name: str) -> typing.Union[schemas.UnsetAnyTypeSchema, schemas.Unset]: ...

def get_item_(
self,
name: typing.Union[
typing_extensions.Literal["foo"],
str
]
):
return super().get_item_(name)

def __new__(
cls,
Expand Down Expand Up @@ -148,21 +133,6 @@ def __getitem__(
):
# dict_instance[name] accessor
return super().__getitem__(name)

@typing.overload
def get_item_(self, name: typing_extensions.Literal["baz"]) -> Schema_.Properties.Baz: ...

@typing.overload
def get_item_(self, name: str) -> typing.Union[schemas.UnsetAnyTypeSchema, schemas.Unset]: ...

def get_item_(
self,
name: typing.Union[
typing_extensions.Literal["baz"],
str
]
):
return super().get_item_(name)

def __new__(
cls,
Expand Down Expand Up @@ -199,21 +169,6 @@ def __getitem__(
):
# dict_instance[name] accessor
return super().__getitem__(name)

@typing.overload
def get_item_(self, name: typing_extensions.Literal["bar"]) -> Schema_.Properties.Bar: ...

@typing.overload
def get_item_(self, name: str) -> typing.Union[schemas.UnsetAnyTypeSchema, schemas.Unset]: ...

def get_item_(
self,
name: typing.Union[
typing_extensions.Literal["bar"],
str
]
):
return super().get_item_(name)

def __new__(
cls,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,21 +74,6 @@ def __getitem__(
):
# dict_instance[name] accessor
return super().__getitem__(name)

@typing.overload
def get_item_(self, name: typing_extensions.Literal["bar"]) -> Schema_.Properties.Bar: ...

@typing.overload
def get_item_(self, name: str) -> typing.Union[schemas.UnsetAnyTypeSchema, schemas.Unset]: ...

def get_item_(
self,
name: typing.Union[
typing_extensions.Literal["bar"],
str
]
):
return super().get_item_(name)

def __new__(
cls,
Expand Down Expand Up @@ -139,21 +124,6 @@ def __getitem__(
):
# dict_instance[name] accessor
return super().__getitem__(name)

@typing.overload
def get_item_(self, name: typing_extensions.Literal["foo"]) -> Schema_.Properties.Foo: ...

@typing.overload
def get_item_(self, name: str) -> typing.Union[schemas.UnsetAnyTypeSchema, schemas.Unset]: ...

def get_item_(
self,
name: typing.Union[
typing_extensions.Literal["foo"],
str
]
):
return super().get_item_(name)

def __new__(
cls,
Expand Down
Loading