Skip to content

Don't depend on stringcase (closes #369) #375

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Apr 28, 2021
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 @@ -4,7 +4,7 @@

from ...client import Client
from ...models.test_inline_objects_json_body import TestInlineObjectsJsonBody
from ...models.test_inline_objects_response_200 import TestInlineObjectsResponse_200
from ...models.test_inline_objects_response_200 import TestInlineObjectsResponse200
from ...types import Response


Expand All @@ -29,15 +29,15 @@ def _get_kwargs(
}


def _parse_response(*, response: httpx.Response) -> Optional[TestInlineObjectsResponse_200]:
def _parse_response(*, response: httpx.Response) -> Optional[TestInlineObjectsResponse200]:
if response.status_code == 200:
response_200 = TestInlineObjectsResponse_200.from_dict(response.json())
response_200 = TestInlineObjectsResponse200.from_dict(response.json())

return response_200
return None


def _build_response(*, response: httpx.Response) -> Response[TestInlineObjectsResponse_200]:
def _build_response(*, response: httpx.Response) -> Response[TestInlineObjectsResponse200]:
return Response(
status_code=response.status_code,
content=response.content,
Expand All @@ -50,7 +50,7 @@ def sync_detailed(
*,
client: Client,
json_body: TestInlineObjectsJsonBody,
) -> Response[TestInlineObjectsResponse_200]:
) -> Response[TestInlineObjectsResponse200]:
kwargs = _get_kwargs(
client=client,
json_body=json_body,
Expand All @@ -67,7 +67,7 @@ def sync(
*,
client: Client,
json_body: TestInlineObjectsJsonBody,
) -> Optional[TestInlineObjectsResponse_200]:
) -> Optional[TestInlineObjectsResponse200]:
""" """

return sync_detailed(
Expand All @@ -80,7 +80,7 @@ async def asyncio_detailed(
*,
client: Client,
json_body: TestInlineObjectsJsonBody,
) -> Response[TestInlineObjectsResponse_200]:
) -> Response[TestInlineObjectsResponse200]:
kwargs = _get_kwargs(
client=client,
json_body=json_body,
Expand All @@ -96,7 +96,7 @@ async def asyncio(
*,
client: Client,
json_body: TestInlineObjectsJsonBody,
) -> Optional[TestInlineObjectsResponse_200]:
) -> Optional[TestInlineObjectsResponse200]:
""" """

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@
)
from .model_with_additional_properties_refed import ModelWithAdditionalPropertiesRefed
from .model_with_any_json_properties import ModelWithAnyJsonProperties
from .model_with_any_json_properties_additional_property_type0 import ModelWithAnyJsonPropertiesAdditionalPropertyType0
from .model_with_any_json_properties_additional_property_type_0 import ModelWithAnyJsonPropertiesAdditionalPropertyType0
from .model_with_primitive_additional_properties import ModelWithPrimitiveAdditionalProperties
from .model_with_primitive_additional_properties_a_date_holder import ModelWithPrimitiveAdditionalPropertiesADateHolder
from .model_with_property_ref import ModelWithPropertyRef
from .model_with_union_property import ModelWithUnionProperty
from .model_with_union_property_inlined import ModelWithUnionPropertyInlined
from .model_with_union_property_inlined_fruit_type0 import ModelWithUnionPropertyInlinedFruitType0
from .model_with_union_property_inlined_fruit_type1 import ModelWithUnionPropertyInlinedFruitType1
from .model_with_union_property_inlined_fruit_type_0 import ModelWithUnionPropertyInlinedFruitType0
from .model_with_union_property_inlined_fruit_type_1 import ModelWithUnionPropertyInlinedFruitType1
from .test_inline_objects_json_body import TestInlineObjectsJsonBody
from .test_inline_objects_response_200 import TestInlineObjectsResponse_200
from .test_inline_objects_response_200 import TestInlineObjectsResponse200
from .validation_error import ValidationError
88 changes: 44 additions & 44 deletions end_to_end_tests/golden-record/my_test_api_client/models/a_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,20 +186,20 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T:

def _parse_a_camel_date_time(data: object) -> Union[datetime.date, datetime.datetime]:
try:
a_camel_date_time_type0: datetime.datetime
a_camel_date_time_type_0: datetime.datetime
if not isinstance(data, str):
raise TypeError()
a_camel_date_time_type0 = isoparse(data)
a_camel_date_time_type_0 = isoparse(data)

return a_camel_date_time_type0
return a_camel_date_time_type_0
except: # noqa: E722
pass
if not isinstance(data, str):
raise TypeError()
a_camel_date_time_type1: datetime.date
a_camel_date_time_type1 = isoparse(data).date()
a_camel_date_time_type_1: datetime.date
a_camel_date_time_type_1 = isoparse(data).date()

return a_camel_date_time_type1
return a_camel_date_time_type_1

a_camel_date_time = _parse_a_camel_date_time(d.pop("aCamelDateTime"))

Expand All @@ -209,20 +209,20 @@ def _parse_a_camel_date_time(data: object) -> Union[datetime.date, datetime.date

def _parse_one_of_models(data: object) -> Union[FreeFormModel, ModelWithUnionProperty]:
try:
one_of_models_type0: FreeFormModel
one_of_models_type_0: FreeFormModel
if not isinstance(data, dict):
raise TypeError()
one_of_models_type0 = FreeFormModel.from_dict(data)
one_of_models_type_0 = FreeFormModel.from_dict(data)

return one_of_models_type0
return one_of_models_type_0
except: # noqa: E722
pass
if not isinstance(data, dict):
raise TypeError()
one_of_models_type1: ModelWithUnionProperty
one_of_models_type1 = ModelWithUnionProperty.from_dict(data)
one_of_models_type_1: ModelWithUnionProperty
one_of_models_type_1 = ModelWithUnionProperty.from_dict(data)

return one_of_models_type1
return one_of_models_type_1

one_of_models = _parse_one_of_models(d.pop("one_of_models"))

Expand Down Expand Up @@ -267,47 +267,47 @@ def _parse_nullable_one_of_models(data: object) -> Union[FreeFormModel, ModelWit
if data is None:
return data
try:
nullable_one_of_models_type0: FreeFormModel
nullable_one_of_models_type_0: FreeFormModel
if not isinstance(data, dict):
raise TypeError()
nullable_one_of_models_type0 = FreeFormModel.from_dict(data)
nullable_one_of_models_type_0 = FreeFormModel.from_dict(data)

return nullable_one_of_models_type0
return nullable_one_of_models_type_0
except: # noqa: E722
pass
if not isinstance(data, dict):
raise TypeError()
nullable_one_of_models_type1: ModelWithUnionProperty
nullable_one_of_models_type1 = ModelWithUnionProperty.from_dict(data)
nullable_one_of_models_type_1: ModelWithUnionProperty
nullable_one_of_models_type_1 = ModelWithUnionProperty.from_dict(data)

return nullable_one_of_models_type1
return nullable_one_of_models_type_1

nullable_one_of_models = _parse_nullable_one_of_models(d.pop("nullable_one_of_models"))

def _parse_not_required_one_of_models(data: object) -> Union[FreeFormModel, ModelWithUnionProperty, Unset]:
if isinstance(data, Unset):
return data
try:
not_required_one_of_models_type0: Union[Unset, FreeFormModel]
not_required_one_of_models_type_0: Union[Unset, FreeFormModel]
if not isinstance(data, dict):
raise TypeError()
not_required_one_of_models_type0 = UNSET
_not_required_one_of_models_type0 = data
if not isinstance(_not_required_one_of_models_type0, Unset):
not_required_one_of_models_type0 = FreeFormModel.from_dict(_not_required_one_of_models_type0)
not_required_one_of_models_type_0 = UNSET
_not_required_one_of_models_type_0 = data
if not isinstance(_not_required_one_of_models_type_0, Unset):
not_required_one_of_models_type_0 = FreeFormModel.from_dict(_not_required_one_of_models_type_0)

return not_required_one_of_models_type0
return not_required_one_of_models_type_0
except: # noqa: E722
pass
if not isinstance(data, dict):
raise TypeError()
not_required_one_of_models_type1: Union[Unset, ModelWithUnionProperty]
not_required_one_of_models_type1 = UNSET
_not_required_one_of_models_type1 = data
if not isinstance(_not_required_one_of_models_type1, Unset):
not_required_one_of_models_type1 = ModelWithUnionProperty.from_dict(_not_required_one_of_models_type1)
not_required_one_of_models_type_1: Union[Unset, ModelWithUnionProperty]
not_required_one_of_models_type_1 = UNSET
_not_required_one_of_models_type_1 = data
if not isinstance(_not_required_one_of_models_type_1, Unset):
not_required_one_of_models_type_1 = ModelWithUnionProperty.from_dict(_not_required_one_of_models_type_1)

return not_required_one_of_models_type1
return not_required_one_of_models_type_1

not_required_one_of_models = _parse_not_required_one_of_models(d.pop("not_required_one_of_models", UNSET))

Expand All @@ -319,31 +319,31 @@ def _parse_not_required_nullable_one_of_models(
if isinstance(data, Unset):
return data
try:
not_required_nullable_one_of_models_type0: Union[Unset, FreeFormModel]
not_required_nullable_one_of_models_type_0: Union[Unset, FreeFormModel]
if not isinstance(data, dict):
raise TypeError()
not_required_nullable_one_of_models_type0 = UNSET
_not_required_nullable_one_of_models_type0 = data
if not isinstance(_not_required_nullable_one_of_models_type0, Unset):
not_required_nullable_one_of_models_type0 = FreeFormModel.from_dict(
_not_required_nullable_one_of_models_type0
not_required_nullable_one_of_models_type_0 = UNSET
_not_required_nullable_one_of_models_type_0 = data
if not isinstance(_not_required_nullable_one_of_models_type_0, Unset):
not_required_nullable_one_of_models_type_0 = FreeFormModel.from_dict(
_not_required_nullable_one_of_models_type_0
)

return not_required_nullable_one_of_models_type0
return not_required_nullable_one_of_models_type_0
except: # noqa: E722
pass
try:
not_required_nullable_one_of_models_type1: Union[Unset, ModelWithUnionProperty]
not_required_nullable_one_of_models_type_1: Union[Unset, ModelWithUnionProperty]
if not isinstance(data, dict):
raise TypeError()
not_required_nullable_one_of_models_type1 = UNSET
_not_required_nullable_one_of_models_type1 = data
if not isinstance(_not_required_nullable_one_of_models_type1, Unset):
not_required_nullable_one_of_models_type1 = ModelWithUnionProperty.from_dict(
_not_required_nullable_one_of_models_type1
not_required_nullable_one_of_models_type_1 = UNSET
_not_required_nullable_one_of_models_type_1 = data
if not isinstance(_not_required_nullable_one_of_models_type_1, Unset):
not_required_nullable_one_of_models_type_1 = ModelWithUnionProperty.from_dict(
_not_required_nullable_one_of_models_type_1
)

return not_required_nullable_one_of_models_type1
return not_required_nullable_one_of_models_type_1
except: # noqa: E722
pass
return cast(Union[FreeFormModel, ModelWithUnionProperty, None, Unset, str], data)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import attr

from ..models.model_with_any_json_properties_additional_property_type0 import (
from ..models.model_with_any_json_properties_additional_property_type_0 import (
ModelWithAnyJsonPropertiesAdditionalPropertyType0,
)

Expand Down Expand Up @@ -46,21 +46,21 @@ def _parse_additional_property(
data: object,
) -> Union[List[str], ModelWithAnyJsonPropertiesAdditionalPropertyType0, bool, float, int, str]:
try:
additional_property_type0: ModelWithAnyJsonPropertiesAdditionalPropertyType0
additional_property_type_0: ModelWithAnyJsonPropertiesAdditionalPropertyType0
if not isinstance(data, dict):
raise TypeError()
additional_property_type0 = ModelWithAnyJsonPropertiesAdditionalPropertyType0.from_dict(data)
additional_property_type_0 = ModelWithAnyJsonPropertiesAdditionalPropertyType0.from_dict(data)

return additional_property_type0
return additional_property_type_0
except: # noqa: E722
pass
try:
additional_property_type1: List[str]
additional_property_type_1: List[str]
if not isinstance(data, list):
raise TypeError()
additional_property_type1 = cast(List[str], data)
additional_property_type_1 = cast(List[str], data)

return additional_property_type1
return additional_property_type_1
except: # noqa: E722
pass
return cast(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ def to_dict(self) -> Dict[str, Any]:
@classmethod
def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T:
d = src_dict.copy()
model_with_any_json_properties_additional_property_type0 = cls()
model_with_any_json_properties_additional_property_type_0 = cls()

model_with_any_json_properties_additional_property_type0.additional_properties = d
return model_with_any_json_properties_additional_property_type0
model_with_any_json_properties_additional_property_type_0.additional_properties = d
return model_with_any_json_properties_additional_property_type_0

@property
def additional_keys(self) -> List[str]:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,26 +44,26 @@ def _parse_a_property(data: object) -> Union[AnEnum, AnIntEnum, Unset]:
if isinstance(data, Unset):
return data
try:
a_property_type0: Union[Unset, AnEnum]
a_property_type_0: Union[Unset, AnEnum]
if not isinstance(data, str):
raise TypeError()
a_property_type0 = UNSET
_a_property_type0 = data
if not isinstance(_a_property_type0, Unset):
a_property_type0 = AnEnum(_a_property_type0)
a_property_type_0 = UNSET
_a_property_type_0 = data
if not isinstance(_a_property_type_0, Unset):
a_property_type_0 = AnEnum(_a_property_type_0)

return a_property_type0
return a_property_type_0
except: # noqa: E722
pass
if not isinstance(data, int):
raise TypeError()
a_property_type1: Union[Unset, AnIntEnum]
a_property_type1 = UNSET
_a_property_type1 = data
if not isinstance(_a_property_type1, Unset):
a_property_type1 = AnIntEnum(_a_property_type1)
a_property_type_1: Union[Unset, AnIntEnum]
a_property_type_1 = UNSET
_a_property_type_1 = data
if not isinstance(_a_property_type_1, Unset):
a_property_type_1 = AnIntEnum(_a_property_type_1)

return a_property_type1
return a_property_type_1

a_property = _parse_a_property(d.pop("a_property", UNSET))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import attr

from ..models.model_with_union_property_inlined_fruit_type0 import ModelWithUnionPropertyInlinedFruitType0
from ..models.model_with_union_property_inlined_fruit_type1 import ModelWithUnionPropertyInlinedFruitType1
from ..models.model_with_union_property_inlined_fruit_type_0 import ModelWithUnionPropertyInlinedFruitType0
from ..models.model_with_union_property_inlined_fruit_type_1 import ModelWithUnionPropertyInlinedFruitType1
from ..types import UNSET, Unset

T = TypeVar("T", bound="ModelWithUnionPropertyInlined")
Expand Down Expand Up @@ -46,26 +46,26 @@ def _parse_fruit(
if isinstance(data, Unset):
return data
try:
fruit_type0: Union[Unset, ModelWithUnionPropertyInlinedFruitType0]
fruit_type_0: Union[Unset, ModelWithUnionPropertyInlinedFruitType0]
if not isinstance(data, dict):
raise TypeError()
fruit_type0 = UNSET
_fruit_type0 = data
if not isinstance(_fruit_type0, Unset):
fruit_type0 = ModelWithUnionPropertyInlinedFruitType0.from_dict(_fruit_type0)
fruit_type_0 = UNSET
_fruit_type_0 = data
if not isinstance(_fruit_type_0, Unset):
fruit_type_0 = ModelWithUnionPropertyInlinedFruitType0.from_dict(_fruit_type_0)

return fruit_type0
return fruit_type_0
except: # noqa: E722
pass
if not isinstance(data, dict):
raise TypeError()
fruit_type1: Union[Unset, ModelWithUnionPropertyInlinedFruitType1]
fruit_type1 = UNSET
_fruit_type1 = data
if not isinstance(_fruit_type1, Unset):
fruit_type1 = ModelWithUnionPropertyInlinedFruitType1.from_dict(_fruit_type1)
fruit_type_1: Union[Unset, ModelWithUnionPropertyInlinedFruitType1]
fruit_type_1 = UNSET
_fruit_type_1 = data
if not isinstance(_fruit_type_1, Unset):
fruit_type_1 = ModelWithUnionPropertyInlinedFruitType1.from_dict(_fruit_type_1)

return fruit_type1
return fruit_type_1

fruit = _parse_fruit(d.pop("fruit", UNSET))

Expand Down
Loading