Skip to content
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

Correct serialziation alias #34

Merged
merged 1 commit into from
Oct 25, 2023
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
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