Skip to content
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

✨ Add support for declaring UploadFile parameters without explicit File() #4469

Merged
merged 8 commits into from Jan 23, 2022

Conversation

tiangolo
Copy link
Owner

✨ Add support for declaring UploadFile parameters without explicit File().

For example, this is now supported:

from fastapi import FastAPI, UploadFile

app = FastAPI()

@app.post("/uploadfile/")
async def create_upload_file(file: UploadFile):
    return {"filename": file.filename}

This also updates UploadFile to declare its own JSON Schema, and removes the equivalent and no longer necessary utility function that did a workaround for that.

This also includes docs and tests for the variations of UploadFile.

@github-actions
Copy link
Contributor

📝 Docs preview for commit 52efd58 at: https://61eda7ca0b769244610550d0--fastapi.netlify.app

@tiangolo tiangolo enabled auto-merge (squash) January 23, 2022 19:09
@codecov
Copy link

codecov bot commented Jan 23, 2022

Codecov Report

Merging #4469 (5f4f43f) into master (59b1f35) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##            master     #4469    +/-   ##
==========================================
  Coverage   100.00%   100.00%            
==========================================
  Files          511       521    +10     
  Lines        12845     13078   +233     
==========================================
+ Hits         12845     13078   +233     
Impacted Files Coverage Δ
docs_src/request_files/tutorial001.py 100.00% <100.00%> (ø)
docs_src/request_files/tutorial001_02.py 100.00% <100.00%> (ø)
docs_src/request_files/tutorial001_02_py310.py 100.00% <100.00%> (ø)
docs_src/request_files/tutorial001_03.py 100.00% <100.00%> (ø)
docs_src/request_files/tutorial002.py 100.00% <100.00%> (ø)
docs_src/request_files/tutorial002_py39.py 100.00% <100.00%> (ø)
docs_src/request_files/tutorial003.py 100.00% <100.00%> (ø)
docs_src/request_files/tutorial003_py39.py 100.00% <100.00%> (ø)
fastapi/datastructures.py 100.00% <100.00%> (ø)
fastapi/dependencies/utils.py 100.00% <100.00%> (ø)
... and 5 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 59b1f35...5f4f43f. Read the comment docs.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 23, 2022

@github-actions github-actions bot temporarily deployed to commit January 23, 2022 19:14 Inactive
@tiangolo tiangolo merged commit 1bf5520 into master Jan 23, 2022
@tiangolo tiangolo deleted the upload-file-alone branch January 23, 2022 19:14
huonw added a commit to huonw/fastapi that referenced this pull request May 2, 2022
JeanArhancet pushed a commit to JeanArhancet/fastapi that referenced this pull request Aug 20, 2022
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.

None yet

1 participant