Skip to content

Commit

Permalink
standard casing from openapi
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Hallett committed Oct 25, 2023
1 parent 90dfb36 commit 02bda73
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion clientele/generators/standard/generators/clients.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
4 changes: 2 additions & 2 deletions example_openapi_specs/best.json
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@
"parameters": [
{
"in": "query",
"name": "your_input",
"name": "yourInput",
"required": true,
"schema": {
"title": "Your Input",
Expand Down Expand Up @@ -605,7 +605,7 @@
"parameters": [
{
"in": "query",
"name": "your_input",
"name": "yourInput",
"required": false,
"schema": {
"title": "Your Input",
Expand Down
8 changes: 4 additions & 4 deletions tests/async_test_client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down
6 changes: 3 additions & 3 deletions tests/test_async_generated_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions tests/test_client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down
6 changes: 3 additions & 3 deletions tests/test_generated_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 02bda73

Please sign in to comment.