diff --git a/CHANGELOG.md b/CHANGELOG.md index cff1500..e111003 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Change log +## 0.8.2 + +- Improved json support + ## 0.8.1 - Function parameters no longer format to snake_case to maintain consistency with the OpenAPI schema. diff --git a/clientele/generators/standard/templates/async_methods.jinja2 b/clientele/generators/standard/templates/async_methods.jinja2 index bbecff0..9923600 100644 --- a/clientele/generators/standard/templates/async_methods.jinja2 +++ b/clientele/generators/standard/templates/async_methods.jinja2 @@ -8,14 +8,14 @@ async def get(url: str, headers: typing.Optional[dict] = None) -> httpx.Response async def post(url: str, data: dict, headers: typing.Optional[dict] = None) -> httpx.Response: """Issue an HTTP POST request""" - json_data = json.dumps(data, default=json_serializer) + json_data = json.loads(json.dumps(data, default=json_serializer)) async with httpx.AsyncClient(headers=headers) as async_client: return await async_client.post(parse_url(url), json=json_data, headers=headers) async def put(url: str, data: dict, headers: typing.Optional[dict] = None) -> httpx.Response: """Issue an HTTP PUT request""" - json_data = json.dumps(data, default=json_serializer) + json_data = json.loads(json.dumps(data, default=json_serializer)) async with httpx.AsyncClient(headers=headers) as async_client: return await async_client.put(parse_url(url), json=json_data, headers=headers) diff --git a/clientele/generators/standard/templates/sync_methods.jinja2 b/clientele/generators/standard/templates/sync_methods.jinja2 index 064b298..13ac3ce 100644 --- a/clientele/generators/standard/templates/sync_methods.jinja2 +++ b/clientele/generators/standard/templates/sync_methods.jinja2 @@ -7,13 +7,13 @@ def get(url: str, headers: typing.Optional[dict] = None) -> httpx.Response: def post(url: str, data: dict, headers: typing.Optional[dict] = None) -> httpx.Response: """Issue an HTTP POST request""" - json_data = json.dumps(data, default=json_serializer) + json_data = json.loads(json.dumps(data, default=json_serializer)) return client.post(parse_url(url), json=json_data, headers=headers) def put(url: str, data: dict, headers: typing.Optional[dict] = None) -> httpx.Response: """Issue an HTTP PUT request""" - json_data = json.dumps(data, default=json_serializer) + json_data = json.loads(json.dumps(data, default=json_serializer)) return client.put(parse_url(url), json=json_data, headers=headers) diff --git a/clientele/settings.py b/clientele/settings.py index 7fff80d..bf1c91e 100644 --- a/clientele/settings.py +++ b/clientele/settings.py @@ -1,6 +1,6 @@ import platform -VERSION = "0.8.1" +VERSION = "0.8.2" def split_ver(): diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index cff1500..e111003 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -1,5 +1,9 @@ # Change log +## 0.8.2 + +- Improved json support + ## 0.8.1 - Function parameters no longer format to snake_case to maintain consistency with the OpenAPI schema. diff --git a/docs/install.md b/docs/install.md index 3b74f3f..24073b5 100644 --- a/docs/install.md +++ b/docs/install.md @@ -10,5 +10,5 @@ Once installed you can run `clientele version` to make sure you have the latest ```sh > clientele version -clientele 0.8.1 +clientele 0.8.2 ``` diff --git a/docs/usage.md b/docs/usage.md index 35a304a..b7791d2 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -102,5 +102,5 @@ Print the current version of Clientele: ```sh > clientele version -Clientele 0.8.1 +Clientele 0.8.2 ``` diff --git a/pyproject.toml b/pyproject.toml index 30dd5e6..7152a67 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "clientele" -version = "0.8.1" +version = "0.8.2" description = "Generate loveable Python HTTP API Clients" authors = ["Paul Hallett "] license = "MIT" diff --git a/tests/async_test_client/MANIFEST.md b/tests/async_test_client/MANIFEST.md index 8549735..ebd9e4d 100644 --- a/tests/async_test_client/MANIFEST.md +++ b/tests/async_test_client/MANIFEST.md @@ -9,7 +9,7 @@ pipx install clientele API VERSION: 0.1.0 OPENAPI VERSION: 3.0.2 -CLIENTELE VERSION: 0.8.1 +CLIENTELE VERSION: 0.8.2 Regnerate using this command: diff --git a/tests/async_test_client/http.py b/tests/async_test_client/http.py index a7bfd61..9767d8c 100644 --- a/tests/async_test_client/http.py +++ b/tests/async_test_client/http.py @@ -130,14 +130,14 @@ async def get(url: str, headers: typing.Optional[dict] = None) -> httpx.Response async def post(url: str, data: dict, headers: typing.Optional[dict] = None) -> httpx.Response: """Issue an HTTP POST request""" - json_data = json.dumps(data, default=json_serializer) + json_data = json.loads(json.dumps(data, default=json_serializer)) async with httpx.AsyncClient(headers=headers) as async_client: return await async_client.post(parse_url(url), json=json_data, headers=headers) async def put(url: str, data: dict, headers: typing.Optional[dict] = None) -> httpx.Response: """Issue an HTTP PUT request""" - json_data = json.dumps(data, default=json_serializer) + json_data = json.loads(json.dumps(data, default=json_serializer)) async with httpx.AsyncClient(headers=headers) as async_client: return await async_client.put(parse_url(url), json=json_data, headers=headers) diff --git a/tests/test_client/MANIFEST.md b/tests/test_client/MANIFEST.md index 8fc1a9b..02ddda2 100644 --- a/tests/test_client/MANIFEST.md +++ b/tests/test_client/MANIFEST.md @@ -9,7 +9,7 @@ pipx install clientele API VERSION: 0.1.0 OPENAPI VERSION: 3.0.2 -CLIENTELE VERSION: 0.8.1 +CLIENTELE VERSION: 0.8.2 Regnerate using this command: diff --git a/tests/test_client/http.py b/tests/test_client/http.py index 7aa1130..7a259a3 100644 --- a/tests/test_client/http.py +++ b/tests/test_client/http.py @@ -129,13 +129,13 @@ def get(url: str, headers: typing.Optional[dict] = None) -> httpx.Response: def post(url: str, data: dict, headers: typing.Optional[dict] = None) -> httpx.Response: """Issue an HTTP POST request""" - json_data = json.dumps(data, default=json_serializer) + json_data = json.loads(json.dumps(data, default=json_serializer)) return client.post(parse_url(url), json=json_data, headers=headers) def put(url: str, data: dict, headers: typing.Optional[dict] = None) -> httpx.Response: """Issue an HTTP PUT request""" - json_data = json.dumps(data, default=json_serializer) + json_data = json.loads(json.dumps(data, default=json_serializer)) return client.put(parse_url(url), json=json_data, headers=headers)