From 02bda73f40513a82b3bedcbe49b42e091d4c2f19 Mon Sep 17 00:00:00 2001 From: Paul Hallett Date: Thu, 26 Oct 2023 11:29:03 +1300 Subject: [PATCH] standard casing from openapi --- clientele/generators/standard/generators/clients.py | 2 +- example_openapi_specs/best.json | 4 ++-- tests/async_test_client/client.py | 8 ++++---- tests/test_async_generated_client.py | 6 +++--- tests/test_client/client.py | 8 ++++---- tests/test_generated_client.py | 6 +++--- 6 files changed, 17 insertions(+), 17 deletions(-) diff --git a/clientele/generators/standard/generators/clients.py b/clientele/generators/standard/generators/clients.py index 55dc1f5..deb130c 100644 --- a/clientele/generators/standard/generators/clients.py +++ b/clientele/generators/standard/generators/clients.py @@ -76,7 +76,7 @@ def generate_parameters(self, parameters: list[dict], additional_parameters: lis if param.get("$ref"): # Get the actual parameter it is referencing param = utils.get_param_from_ref(spec=self.spec, param=param) - clean_key = utils.snake_case_prop(param["name"]) + clean_key = param["name"] if clean_key in param_keys: continue in_ = param.get("in") diff --git a/example_openapi_specs/best.json b/example_openapi_specs/best.json index 06447ef..46887f5 100644 --- a/example_openapi_specs/best.json +++ b/example_openapi_specs/best.json @@ -565,7 +565,7 @@ "parameters": [ { "in": "query", - "name": "your_input", + "name": "yourInput", "required": true, "schema": { "title": "Your Input", @@ -605,7 +605,7 @@ "parameters": [ { "in": "query", - "name": "your_input", + "name": "yourInput", "required": false, "schema": { "title": "Your Input", diff --git a/tests/async_test_client/client.py b/tests/async_test_client/client.py index 787b7eb..757b9ba 100644 --- a/tests/async_test_client/client.py +++ b/tests/async_test_client/client.py @@ -70,20 +70,20 @@ async def security_required_request_security_required_get() -> schemas.SecurityR async def query_request_simple_query_get( - your_input: str, + yourInput: str, ) -> schemas.HTTPValidationError | schemas.SimpleQueryParametersResponse: """Query Request""" - response = await http.get(url=f"/simple-query?your_input={your_input}") + response = await http.get(url=f"/simple-query?yourInput={yourInput}") return http.handle_response(query_request_simple_query_get, response) async def query_request_optional_query_get( - your_input: typing.Optional[str], + yourInput: typing.Optional[str], ) -> schemas.HTTPValidationError | schemas.OptionalQueryParametersResponse: """Optional Query Request""" - response = await http.get(url=f"/optional-query?your_input={your_input}") + response = await http.get(url=f"/optional-query?yourInput={yourInput}") return http.handle_response(query_request_optional_query_get, response) diff --git a/tests/test_async_generated_client.py b/tests/test_async_generated_client.py index b3dc37b..191c91a 100644 --- a/tests/test_async_generated_client.py +++ b/tests/test_async_generated_client.py @@ -91,10 +91,10 @@ async def test_query_request_simple_query_get(respx_mock: MockRouter): # Given your_input = "hello world" mocked_response = {"your_query": your_input} - mock_path = "/simple-query?your_input=hello+world" + mock_path = "/simple-query?yourInput=hello+world" respx_mock.get(mock_path).mock(return_value=Response(json=mocked_response, status_code=200)) # When - response = await client.query_request_simple_query_get(your_input=your_input) + response = await client.query_request_simple_query_get(yourInput=your_input) # Then assert isinstance(response, schemas.SimpleQueryParametersResponse) assert len(respx_mock.calls) == 1 @@ -112,7 +112,7 @@ async def test_query_request_optional_query_get(respx_mock: MockRouter): mock_path = "/optional-query" respx_mock.get(mock_path).mock(return_value=Response(json=mocked_response, status_code=200)) # When - response = await client.query_request_optional_query_get(your_input=your_input) + response = await client.query_request_optional_query_get(yourInput=your_input) # Then assert isinstance(response, schemas.OptionalQueryParametersResponse) assert len(respx_mock.calls) == 1 diff --git a/tests/test_client/client.py b/tests/test_client/client.py index 2352405..0f47085 100644 --- a/tests/test_client/client.py +++ b/tests/test_client/client.py @@ -70,20 +70,20 @@ def security_required_request_security_required_get() -> schemas.SecurityRequire def query_request_simple_query_get( - your_input: str, + yourInput: str, ) -> schemas.HTTPValidationError | schemas.SimpleQueryParametersResponse: """Query Request""" - response = http.get(url=f"/simple-query?your_input={your_input}") + response = http.get(url=f"/simple-query?yourInput={yourInput}") return http.handle_response(query_request_simple_query_get, response) def query_request_optional_query_get( - your_input: typing.Optional[str], + yourInput: typing.Optional[str], ) -> schemas.HTTPValidationError | schemas.OptionalQueryParametersResponse: """Optional Query Request""" - response = http.get(url=f"/optional-query?your_input={your_input}") + response = http.get(url=f"/optional-query?yourInput={yourInput}") return http.handle_response(query_request_optional_query_get, response) diff --git a/tests/test_generated_client.py b/tests/test_generated_client.py index 2999dd2..5d19d88 100644 --- a/tests/test_generated_client.py +++ b/tests/test_generated_client.py @@ -78,10 +78,10 @@ def test_query_request_simple_query_get(respx_mock: MockRouter): # Given your_input = "hello world" mocked_response = {"your_query": your_input} - mock_path = "/simple-query?your_input=hello+world" + mock_path = "/simple-query?yourInput=hello+world" respx_mock.get(mock_path).mock(return_value=Response(json=mocked_response, status_code=200)) # When - response = client.query_request_simple_query_get(your_input=your_input) + response = client.query_request_simple_query_get(yourInput=your_input) # Then assert isinstance(response, schemas.SimpleQueryParametersResponse) assert len(respx_mock.calls) == 1 @@ -98,7 +98,7 @@ def test_query_request_optional_query_get(respx_mock: MockRouter): mock_path = "/optional-query" respx_mock.get(mock_path).mock(return_value=Response(json=mocked_response, status_code=200)) # When - response = client.query_request_optional_query_get(your_input=your_input) + response = client.query_request_optional_query_get(yourInput=your_input) # Then assert isinstance(response, schemas.OptionalQueryParametersResponse) assert len(respx_mock.calls) == 1