Skip to content

Support non-file fields in Multipart requests #353

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

Closed
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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## 0.8.1 - Unreleased

### Additions

- Multipart requests now support non-file fields

## 0.8.0 - 2021-02-19

### Breaking Changes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,14 +130,24 @@ def _get_kwargs(
params.update(json_required_model_prop)
params = {k: v for k, v in params.items() if v is not UNSET and v is not None}

return {
data: Dict[str, Any] = {}
files: Dict[str, Any] = {}

kwargs = {
"url": url,
"headers": headers,
"cookies": cookies,
"timeout": client.get_timeout(),
"params": params,
}

if data:
kwargs["data"] = data
if files:
kwargs["files"] = files

return kwargs


def _parse_response(*, response: httpx.Response) -> Optional[Union[None, HTTPValidationError]]:
if response.status_code == 200:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,23 @@ def _get_kwargs(
headers: Dict[str, Any] = client.get_headers()
cookies: Dict[str, Any] = client.get_cookies()

return {
data: Dict[str, Any] = {}
files: Dict[str, Any] = {}

kwargs = {
"url": url,
"headers": headers,
"cookies": cookies,
"timeout": client.get_timeout(),
}

if data:
kwargs["data"] = data
if files:
kwargs["files"] = files

return kwargs


def _parse_response(*, response: httpx.Response) -> Optional[List[bool]]:
if response.status_code == 200:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,23 @@ def _get_kwargs(
headers: Dict[str, Any] = client.get_headers()
cookies: Dict[str, Any] = client.get_cookies()

return {
data: Dict[str, Any] = {}
files: Dict[str, Any] = {}

kwargs = {
"url": url,
"headers": headers,
"cookies": cookies,
"timeout": client.get_timeout(),
}

if data:
kwargs["data"] = data
if files:
kwargs["files"] = files

return kwargs


def _parse_response(*, response: httpx.Response) -> Optional[List[float]]:
if response.status_code == 200:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,23 @@ def _get_kwargs(
headers: Dict[str, Any] = client.get_headers()
cookies: Dict[str, Any] = client.get_cookies()

return {
data: Dict[str, Any] = {}
files: Dict[str, Any] = {}

kwargs = {
"url": url,
"headers": headers,
"cookies": cookies,
"timeout": client.get_timeout(),
}

if data:
kwargs["data"] = data
if files:
kwargs["files"] = files

return kwargs


def _parse_response(*, response: httpx.Response) -> Optional[List[int]]:
if response.status_code == 200:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,23 @@ def _get_kwargs(
headers: Dict[str, Any] = client.get_headers()
cookies: Dict[str, Any] = client.get_cookies()

return {
data: Dict[str, Any] = {}
files: Dict[str, Any] = {}

kwargs = {
"url": url,
"headers": headers,
"cookies": cookies,
"timeout": client.get_timeout(),
}

if data:
kwargs["data"] = data
if files:
kwargs["files"] = files

return kwargs


def _parse_response(*, response: httpx.Response) -> Optional[List[str]]:
if response.status_code == 200:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,24 @@ def _get_kwargs(
}
params = {k: v for k, v in params.items() if v is not UNSET and v is not None}

return {
data: Dict[str, Any] = {}
files: Dict[str, Any] = {}

kwargs = {
"url": url,
"headers": headers,
"cookies": cookies,
"timeout": client.get_timeout(),
"params": params,
}

if data:
kwargs["data"] = data
if files:
kwargs["files"] = files

return kwargs


def _parse_response(*, response: httpx.Response) -> Optional[Union[List[AModel], HTTPValidationError]]:
if response.status_code == 200:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,24 @@ def _get_kwargs(
}
params = {k: v for k, v in params.items() if v is not UNSET and v is not None}

return {
data: Dict[str, Any] = {}
files: Dict[str, Any] = {}

kwargs = {
"url": url,
"headers": headers,
"cookies": cookies,
"timeout": client.get_timeout(),
"params": params,
}

if data:
kwargs["data"] = data
if files:
kwargs["files"] = files

return kwargs


def _parse_response(*, response: httpx.Response) -> Optional[Union[None, HTTPValidationError]]:
if response.status_code == 200:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,24 @@ def _get_kwargs(

json_json_body = json_body.to_dict()

return {
data: Dict[str, Any] = {}
files: Dict[str, Any] = {}

kwargs = {
"url": url,
"headers": headers,
"cookies": cookies,
"timeout": client.get_timeout(),
"json": json_json_body,
}

if data:
kwargs["data"] = data
if files:
kwargs["files"] = files

return kwargs


def _parse_response(*, response: httpx.Response) -> Optional[Union[None, HTTPValidationError]]:
if response.status_code == 200:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,23 @@ def _get_kwargs(
headers: Dict[str, Any] = client.get_headers()
cookies: Dict[str, Any] = client.get_cookies()

return {
data: Dict[str, Any] = {}
files: Dict[str, Any] = {}

kwargs = {
"url": url,
"headers": headers,
"cookies": cookies,
"timeout": client.get_timeout(),
}

if data:
kwargs["data"] = data
if files:
kwargs["files"] = files

return kwargs


def _build_response(*, response: httpx.Response) -> Response[None]:
return Response(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,23 @@ def _get_kwargs(
headers: Dict[str, Any] = client.get_headers()
cookies: Dict[str, Any] = client.get_cookies()

return {
data: Dict[str, Any] = {}
files: Dict[str, Any] = {}

kwargs = {
"url": url,
"headers": headers,
"cookies": cookies,
"timeout": client.get_timeout(),
}

if data:
kwargs["data"] = data
if files:
kwargs["files"] = files

return kwargs


def _parse_response(*, response: httpx.Response) -> Optional[File]:
if response.status_code == 200:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,24 @@ def _get_kwargs(
}
params = {k: v for k, v in params.items() if v is not UNSET and v is not None}

return {
data: Dict[str, Any] = {}
files: Dict[str, Any] = {}

kwargs = {
"url": url,
"headers": headers,
"cookies": cookies,
"timeout": client.get_timeout(),
"params": params,
}

if data:
kwargs["data"] = data
if files:
kwargs["files"] = files

return kwargs


def _parse_response(*, response: httpx.Response) -> Optional[Union[None, HTTPValidationError]]:
if response.status_code == 200:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,24 @@ def _get_kwargs(

json_json_body = json_body.to_dict()

return {
data: Dict[str, Any] = {}
files: Dict[str, Any] = {}

kwargs = {
"url": url,
"headers": headers,
"cookies": cookies,
"timeout": client.get_timeout(),
"json": json_json_body,
}

if data:
kwargs["data"] = data
if files:
kwargs["files"] = files

return kwargs


def _parse_response(*, response: httpx.Response) -> Optional[TestInlineObjectsResponse_200]:
if response.status_code == 200:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,23 @@ def _get_kwargs(

cookies["MyToken"] = my_token

return {
data: Dict[str, Any] = {}
files: Dict[str, Any] = {}

kwargs = {
"url": url,
"headers": headers,
"cookies": cookies,
"timeout": client.get_timeout(),
}

if data:
kwargs["data"] = data
if files:
kwargs["files"] = files

return kwargs


def _parse_response(*, response: httpx.Response) -> Optional[Union[None, None]]:
if response.status_code == 200:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,23 @@ def _get_kwargs(
headers: Dict[str, Any] = client.get_headers()
cookies: Dict[str, Any] = client.get_cookies()

return {
data: Dict[str, Any] = {}
files: Dict[str, Any] = {}

kwargs = {
"url": url,
"headers": headers,
"cookies": cookies,
"timeout": client.get_timeout(),
}

if data:
kwargs["data"] = data
if files:
kwargs["files"] = files

return kwargs


def _build_response(*, response: httpx.Response) -> Response[None]:
return Response(
Expand Down
Loading