]> git.ipfire.org Git - thirdparty/fastapi/fastapi.git/commitdiff
✏ Fix typos in docs for dependencies (#1675)
authorNils Lindemann <nilslindemann@tutanota.com>
Mon, 3 Aug 2020 07:12:07 +0000 (09:12 +0200)
committerGitHub <noreply@github.com>
Mon, 3 Aug 2020 07:12:07 +0000 (09:12 +0200)
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
docs/en/docs/tutorial/dependencies/classes-as-dependencies.md
docs/en/docs/tutorial/dependencies/dependencies-in-path-operation-decorators.md
docs/en/docs/tutorial/dependencies/index.md
docs/en/docs/tutorial/dependencies/sub-dependencies.md

index 3ae184d9557b9b6ddfe2c4c995360d668813bbb7..976db38c7c6fa363b6a381d6d15fd4e9c6973aa0 100644 (file)
@@ -69,7 +69,7 @@ If you pass a "callable" as a dependency in **FastAPI**, it will analyze the par
 
 That also applies to callables with no parameters at all. The same as it would be for *path operation functions* with no parameters.
 
-Then, we can change the dependency "dependable" `common_parameters` from above to the class `CommonQueryParameters`:
+Then, we can change the dependency "dependable" `common_parameters` from above to the class `CommonQueryParams`:
 
 ```Python hl_lines="11 12 13 14 15"
 {!../../../docs_src/dependencies/tutorial002.py!}
@@ -101,15 +101,15 @@ In both cases the data will be converted, validated, documented on the OpenAPI s
 
 Now you can declare your dependency using this class.
 
-And as when **FastAPI** calls that class the value that will be passed as `commons` to your function will be an "instance" of the class, you can declare that parameter `commons` to be of type of the class, `CommonQueryParams`.
-
 ```Python hl_lines="19"
 {!../../../docs_src/dependencies/tutorial002.py!}
 ```
 
+**FastAPI** calls the `CommonQueryParams` class. This creates an "instance" of that class and the instance will be passed as the parameter `commons` to your function.
+
 ## Type annotation vs `Depends`
 
-In the code above, you are declaring `commons` as:
+Notice how we write `CommonQueryParams` twice in the above code:
 
 ```Python
 commons: CommonQueryParams = Depends(CommonQueryParams)
@@ -175,9 +175,9 @@ commons: CommonQueryParams = Depends(CommonQueryParams)
 commons: CommonQueryParams = Depends()
 ```
 
-So, you can declare the dependency as the type of the variable, and use `Depends()` as the "default" value (the value after the `=`) for that function's parameter, without any parameter, instead of having to write the full class *again* inside of `Depends(CommonQueryParams)`.
+You declare the dependency as the type of the parameter, and you use `Depends()` as its "default" value (that after the `=`) for that function's parameter, without any parameter in `Depends()`, instead of having to write the full class *again* inside of `Depends(CommonQueryParams)`.
 
-So, the same example would look like:
+The same example would then look like:
 
 ```Python hl_lines="19"
 {!../../../docs_src/dependencies/tutorial004.py!}
@@ -186,6 +186,6 @@ So, the same example would look like:
 ...and **FastAPI** will know what to do.
 
 !!! tip
-    If all that seems more confusing than helpful, disregard it, you don't *need* it.
-    
+    If that seems more confusing than helpful, disregard it, you don't *need* it.
+
     It is just a shortcut. Because **FastAPI** cares about helping you minimize code repetition.
index 64e03139c96adf03aac3721fe8c80c84adaf65ec..3498ab3d8a2f521b84936905e8817ca256a7154b 100644 (file)
@@ -25,7 +25,7 @@ These dependencies will be executed/solved the same way normal dependencies. But
 
     Using these `dependencies` in the *path operation decorator* you can make sure they are executed while avoiding editor/tooling errors.
 
-    It might also help avoiding confusion for new developers that see an un-used parameter in your code and could think it's unnecessary.
+    It might also help avoid confusion for new developers that see an unused parameter in your code and could think it's unnecessary.
 
 ## Dependencies errors and return values
 
index 1b86e16791846c847f59efaeaad3b2c0b5ec8efe..7adbd037291a919d5c236122db9c9c681b93797c 100644 (file)
@@ -39,7 +39,7 @@ That's it.
 
 **2 lines**.
 
-And it has the same shape and structure that all your *path operation functions*.
+And it has the same shape and structure that all your *path operation functions* have.
 
 You can think of it as a *path operation function* without the "decorator" (without the `@app.get("/some-path")`).
 
@@ -123,10 +123,9 @@ So, the interactive docs will have all the information from these dependencies t
 
 <img src="/img/tutorial/dependencies/image01.png">
 
-
 ## Simple usage
 
-If you look at it, *path operation functions* are declared to be used whenever a *path* and *operation* matches, and then **FastAPI** takes care of calling the function with the correct parameters and use the response.
+If you look at it, *path operation functions* are declared to be used whenever a *path* and *operation* matches, and then **FastAPI** takes care of calling the function with the correct parameters, extracting the data from the request.
 
 Actually, all (or most) of the web frameworks work in this same way.
 
index 3ecccebaf71ae117345bdb4fd683cd5db0667bd7..c86c91fd55aaf1952e3b718e24c33f21f219bdc2 100644 (file)
@@ -31,7 +31,7 @@ Let's focus on the parameters declared:
 * Even though this function is a dependency ("dependable") itself, it also declares another dependency (it "depends" on something else).
     * It depends on the `query_extractor`, and assigns the value returned by it to the parameter `q`.
 * It also declares an optional `last_query` cookie, as a `str`.
-    * Let's imagine that if the user didn't provide any query `q`, we just use the last query used, that we had saved to a cookie before.
+    * If the user didn't provide any query `q`, we use the last query used, which we saved to a cookie before.
 
 ### Use the dependency