Skip to content

Commit

Permalink
Merge pull request #34 from phalt/serialization-alias
Browse files Browse the repository at this point in the history
Correct serialziation alias
  • Loading branch information
phalt authored Oct 25, 2023
2 parents ad0dbf0 + 75ed52f commit 49eaafd
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- Improved support for Async clients which prevents a weird bug when running more than one event loop. Based on the suggestions from [this httpx issue](https://github.com/encode/httpcore/discussions/659).
- We now use [`ruff format`](https://astral.sh/blog/the-ruff-formatter) for coding formatting (not the client output).
- `Decimal` support now extends to Decimal input values.
- Input and Output schemas will now have properties that directly match those provided by the OpenAPI schema. This fixes a bug where previously, the snake-case formatting did not match up with what the API expected to send or receive.

## 0.7.1

Expand Down
2 changes: 1 addition & 1 deletion clientele/generators/standard/generators/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def generate_class_properties(self, properties: dict, required: Optional[list] =
arg_type = utils.get_type(arg_details)
is_optional = required and arg not in required
type_string = is_optional and f"typing.Optional[{arg_type}]" or arg_type
content = content + f""" {utils.snake_case_prop(arg)}: {type_string}\n"""
content = content + f""" {arg}: {type_string}\n"""
return content

def generate_input_class(self, schema: dict) -> None:
Expand Down
1 change: 1 addition & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- Improved support for Async clients which prevents a weird bug when running more than one event loop. Based on the suggestions from [this httpx issue](https://github.com/encode/httpcore/discussions/659).
- We now use [`ruff format`](https://astral.sh/blog/the-ruff-formatter) for coding formatting (not the client output).
- `Decimal` support now extends to Decimal input values.
- Input and Output schemas will now have properties that directly match those provided by the OpenAPI schema. This fixes a bug where previously, the snake-case formatting did not match up with what the API expected to send or receive.

## 0.7.1

Expand Down
2 changes: 1 addition & 1 deletion docs/examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ The `response` object will be attached to this exception class for your own debu

## Schemas

The `schemas.py` file has all the possible schemas, request and response, and even Enums, for the API. These are taken from OpenAPI's schemas objects and turned into Python classes. They are all subclassed from pydantic's `BaseModel`.
The `schemas.py` file has all the possible schemas, request and response, and even Enums, for the API. These are taken from OpenAPI's schemas objects and turned into Python classes. They are all subclassed from pydantic's `BaseModel`.

Here are a few examples:

Expand Down
5 changes: 4 additions & 1 deletion tests/test_generated_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,10 @@ def test_request_data_request_data_post(respx_mock: MockRouter):
mock_path = "/request-data"
respx_mock.post(mock_path).mock(return_value=Response(json=mocked_response, status_code=200))
# When
data = schemas.RequestDataRequest(my_input="test", my_decimal_input=Decimal(0.1))
data = schemas.RequestDataRequest(
my_input="test",
my_decimal_input=Decimal(0.1),
)
response = client.request_data_request_data_post(data=data)
# Then
assert isinstance(response, schemas.RequestDataResponse)
Expand Down

0 comments on commit 49eaafd

Please sign in to comment.