Skip to content

Support binary request bodies for endpoints #899

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

Merged
merged 11 commits into from
Dec 7, 2023

Conversation

kgutwin
Copy link
Contributor

@kgutwin kgutwin commented Dec 6, 2023

Resolves #588.

Thanks for a great tool! I hope this is compatible with the active work going on in #897.

Copy link

codecov bot commented Dec 6, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (87b969c) 100.00% compared to head (ecd8395) 100.00%.

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #899   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           49        49           
  Lines         1932      1940    +8     
=========================================
+ Hits          1932      1940    +8     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@kgutwin
Copy link
Contributor Author

kgutwin commented Dec 6, 2023

I'm not sure what to do with the "1 missing line" from the Codecov report. The line is from a stub function in a Protocol used for type checking (see some of the examples here: https://docs.python.org/3/library/typing.html#annotating-callable-objects) and the Ellipsis used as the function body is idiomatic for this use. Since it's a Protocol, it's never supposed to actually be run. Is there a good way to exclude this line from Codecov's report, or do you have any other suggestions?

@dbanty
Copy link
Collaborator

dbanty commented Dec 6, 2023

I think a # pragma: no cover is appropriate there

@dbanty
Copy link
Collaborator

dbanty commented Dec 6, 2023

Thanks for putting this together! I like the idea of deduplicating the body logic a bit, but I wonder if there's a way we can do it without setattr just to keep some IDE hints (like, finding where it's set from). I'm going to noodle on this a little bit (and I can also deal with that upstream conflict)

# Conflicts:
#	openapi_python_client/parser/openapi.py
@dbanty
Copy link
Collaborator

dbanty commented Dec 7, 2023

Okay, I think I've decided that the way I want to fix this in the future will coincide with fixing support for multiple content-types—but that can wait until later since it will be a big change. I did open #900 as a draft of what that could look like, if you want to take a look 😁

@dbanty dbanty changed the title feat: Support binary request bodies for endpoints Support binary request bodies for endpoints Dec 7, 2023
dbanty
dbanty previously approved these changes Dec 7, 2023
dbanty
dbanty previously approved these changes Dec 7, 2023
@dbanty dbanty enabled auto-merge December 7, 2023 00:48
@dbanty dbanty added this pull request to the merge queue Dec 7, 2023
Merged via the queue into openapi-generators:main with commit 3e0f835 Dec 7, 2023
dbanty added a commit that referenced this pull request Dec 7, 2023
This PR was created by Knope. Merging it will create a new release

### Breaking Changes

#### Switch from Black to Ruff for formatting

`black` is no longer a runtime dependency, so if you have them set in
custom `post_hooks` in a config file, you'll need to make sure they're
being installed manually. [`ruff`](https://docs.astral.sh/ruff) is now
installed and used by default instead.

#### Use Ruff instead of isort + autoflake at runtime

`isort` and `autoflake` are no longer runtime dependencies, so if you
have them set in custom `post_hooks` in a config file, you'll need to
make sure they're being installed manually.
[`ruff`](https://docs.astral.sh/ruff) is now installed and used by
default instead.

### Features

#### Support all `text/*` content types in responses

Within an API response, any content type which starts with `text/` will
now be treated the same as `text/html` already was—they will return the
`response.text` attribute from the [httpx
Response](https://www.python-httpx.org/api/#response).

Thanks to @fdintino for the initial implementation, and thanks for the
discussions from @kairntech, @rubenfiszel, and @antoneladestito.

Closes #797 and #821.

#### Support `application/octet-stream` request bodies

Endpoints that accept `application/octet-stream` request bodies are now
supported using the same `File` type as octet-stream responses.

Thanks to @kgutwin for the implementation and @rtaycher for the
discussion!

PR #899 closes #588

### Fixes

#### Remove useless `pass` statements from generated code

Co-authored-by: GitHub <github-actions@github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants