Repository: openapi-generators/openapi-python-client (language: python)

Issue:
Broken _get_kwargs code generated with JSON body type string
**Describe the bug**
With a route definition that sets the content type to `application/json` but the schema type to a string, the code generated references an invalid variable.

**To Reproduce**
1. Add a route definition like so:
```json
        "/chat/web": {
            "parameters": [],
            "post": {
                "security": [
                    {
                        "basicAuth": []
                    }
                ],
                "description": "Send a message to the chat",
                "responses": {
                    "204": {
                        "description": "Message sent"
                    } 
                },
                "requestBody": {
                    "description": "The text to send",
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "string"
                            }
                        }
                    }
                }
            }
        }
```
2. Run `openapi-python-client update ...`
3. Open the python file at api/.../post_chat_web.py
4. See `_get_kwargs` code
```py
def _get_kwargs(
    *,
    client: AuthenticatedClient,
    json_body: str,
) -> Dict[str, Any]:
    url = "{}/chat/web".format(client.base_url)

    headers: Dict[str, Any] = client.get_headers()
    cookies: Dict[str, Any] = client.get_cookies()

    return {
        "url": url,
        "headers": headers,
        "cookies": cookies,
        "timeout": client.get_timeout(),
        "json": json_json_body,
    }
```

**Expected behavior**
The code in `post_chat_web.py` should reference `json_body` and not `json_json_body`.

**OpenAPI Spec File**
https://raw.githubusercontent.com/Nadybot/Nadybot/unstable/html/api.json

**Desktop (please complete the following information):**
 - OS: Fedora 34
 - Python Version: 3.9.6
 - openapi-python-client version 0.10.3



Discussion / hints:
Thanks for reporting this! Sorry for the delayed response, I'll add this into my list of bugs to reproduce & fix this weekend.

Fix patch:
diff --git a/openapi_python_client/templates/endpoint_macros.py.jinja b/openapi_python_client/templates/endpoint_macros.py.jinja
index 60baa4230..a0d1aa32f 100644
--- a/openapi_python_client/templates/endpoint_macros.py.jinja
+++ b/openapi_python_client/templates/endpoint_macros.py.jinja
@@ -67,6 +67,8 @@ params = {k: v for k, v in params.items() if v is not UNSET and v is not None}
     {% if property.template %}
         {% from "property_templates/" + property.template import transform %}
 {{ transform(property, property.python_name, destination) }}
+    {% else %}
+{{ destination }} = {{ property.python_name }}
     {% endif %}
 {% endif %}
 {% endmacro %}
diff --git a/openapi_python_client/templates/endpoint_module.py.jinja b/openapi_python_client/templates/endpoint_module.py.jinja
index c8bb190ae..5ddd2591b 100644
--- a/openapi_python_client/templates/endpoint_module.py.jinja
+++ b/openapi_python_client/templates/endpoint_module.py.jinja
@@ -63,7 +63,7 @@ def _parse_response(*, response: httpx.Response) -> Optional[{{ return_string }}
             {% from "property_templates/" + response.prop.template import construct %}
         {{ construct(response.prop, response.source) | indent(8) }}
         {% else %}
-        {{ response.prop.python_name }} = {{ response.source }}
+        {{ response.prop.python_name }} = cast({{ response.prop.get_type_string() }}, {{ response.source }})
         {% endif %}
         return {{ response.prop.python_name }}
     {% endfor %}


Test patch:
diff --git a/end_to_end_tests/custom-templates-golden-record/my_test_api_client/api/tests/__init__.py b/end_to_end_tests/custom-templates-golden-record/my_test_api_client/api/tests/__init__.py
index 5455c2c70..b0615a2d2 100644
--- a/end_to_end_tests/custom-templates-golden-record/my_test_api_client/api/tests/__init__.py
+++ b/end_to_end_tests/custom-templates-golden-record/my_test_api_client/api/tests/__init__.py
@@ -14,6 +14,7 @@
     no_response_tests_no_response_get,
     octet_stream_tests_octet_stream_get,
     post_form_data,
+    post_tests_json_body_string,
     test_inline_objects,
     token_with_cookie_auth_token_with_cookie_get,
     unsupported_content_tests_unsupported_content_get,
@@ -86,6 +87,13 @@ def json_body_tests_json_body_post(cls) -> types.ModuleType:
         """
         return json_body_tests_json_body_post
 
+    @classmethod
+    def post_tests_json_body_string(cls) -> types.ModuleType:
+        """
+        Json Body Which is String
+        """
+        return post_tests_json_body_string
+
     @classmethod
     def defaults_tests_defaults_post(cls) -> types.ModuleType:
         """
diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/post_tests_json_body_string.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/post_tests_json_body_string.py
new file mode 100644
index 000000000..8b076b59c
--- /dev/null
+++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/post_tests_json_body_string.py
@@ -0,0 +1,110 @@
+from typing import Any, Dict, Optional, Union, cast
+
+import httpx
+
+from ...client import Client
+from ...models.http_validation_error import HTTPValidationError
+from ...types import Response
+
+
+def _get_kwargs(
+    *,
+    client: Client,
+    json_body: str,
+) -> Dict[str, Any]:
+    url = "{}/tests/json_body/string".format(client.base_url)
+
+    headers: Dict[str, Any] = client.get_headers()
+    cookies: Dict[str, Any] = client.get_cookies()
+
+    json_json_body = json_body
+
+    return {
+        "url": url,
+        "headers": headers,
+        "cookies": cookies,
+        "timeout": client.get_timeout(),
+        "json": json_json_body,
+    }
+
+
+def _parse_response(*, response: httpx.Response) -> Optional[Union[HTTPValidationError, str]]:
+    if response.status_code == 200:
+        response_200 = cast(str, response.json())
+        return response_200
+    if response.status_code == 422:
+        response_422 = HTTPValidationError.from_dict(response.json())
+
+        return response_422
+    return None
+
+
+def _build_response(*, response: httpx.Response) -> Response[Union[HTTPValidationError, str]]:
+    return Response(
+        status_code=response.status_code,
+        content=response.content,
+        headers=response.headers,
+        parsed=_parse_response(response=response),
+    )
+
+
+def sync_detailed(
+    *,
+    client: Client,
+    json_body: str,
+) -> Response[Union[HTTPValidationError, str]]:
+    kwargs = _get_kwargs(
+        client=client,
+        json_body=json_body,
+    )
+
+    response = httpx.post(
+        verify=client.verify_ssl,
+        **kwargs,
+    )
+
+    return _build_response(response=response)
+
+
+def sync(
+    *,
+    client: Client,
+    json_body: str,
+) -> Optional[Union[HTTPValidationError, str]]:
+    """ """
+
+    return sync_detailed(
+        client=client,
+        json_body=json_body,
+    ).parsed
+
+
+async def asyncio_detailed(
+    *,
+    client: Client,
+    json_body: str,
+) -> Response[Union[HTTPValidationError, str]]:
+    kwargs = _get_kwargs(
+        client=client,
+        json_body=json_body,
+    )
+
+    async with httpx.AsyncClient(verify=client.verify_ssl) as _client:
+        response = await _client.post(**kwargs)
+
+    return _build_response(response=response)
+
+
+async def asyncio(
+    *,
+    client: Client,
+    json_body: str,
+) -> Optional[Union[HTTPValidationError, str]]:
+    """ """
+
+    return (
+        await asyncio_detailed(
+            client=client,
+            json_body=json_body,
+        )
+    ).parsed
diff --git a/end_to_end_tests/openapi.json b/end_to_end_tests/openapi.json
index e03b60d56..46db24487 100644
--- a/end_to_end_tests/openapi.json
+++ b/end_to_end_tests/openapi.json
@@ -388,6 +388,46 @@
         }
       }
     },
+    "/tests/json_body/string": {
+      "post": {
+        "tags": [
+          "tests"
+        ],
+        "summary": "Json Body Which is String",
+        "requestBody": {
+          "content": {
+            "application/json": {
+              "schema": {
+                "type": "string"
+              }
+            }
+          },
+          "required": true
+        },
+        "responses": {
+          "200": {
+            "description": "success",
+            "content": {
+              "application/json": {
+                "schema": {
+                  "type": "string"
+                }
+              }
+            }
+          },
+          "422": {
+            "description": "Validation Error",
+            "content": {
+              "application/json": {
+                "schema": {
+                  "$ref": "#/components/schemas/HTTPValidationError"
+                }
+              }
+            }
+          }
+        }
+      }
+    },
     "/tests/defaults": {
       "post": {
         "tags": [