mirror of
https://github.com/fastapi/fastapi.git
synced 2026-05-03 21:23:53 -04:00
📝 Update docs highlighting after re-sort imports
coming back to flit, after pipenv
This commit is contained in:
@@ -4,7 +4,7 @@ With **FastAPI**, you can define, validate, document, and use arbitrarily deeply
|
||||
|
||||
You can define an attribute to be a subtype. For example, a Python `list`:
|
||||
|
||||
```Python hl_lines="13"
|
||||
```Python hl_lines="12"
|
||||
{!./tutorial/src/body_nested_models/tutorial001.py!}
|
||||
```
|
||||
|
||||
@@ -41,7 +41,7 @@ Use that same standard syntax for model attributes with subtypes.
|
||||
|
||||
So, in our example, we can make `tags` be specifically a "list of strings":
|
||||
|
||||
```Python hl_lines="15"
|
||||
```Python hl_lines="14"
|
||||
{!./tutorial/src/body_nested_models/tutorial002.py!}
|
||||
```
|
||||
|
||||
@@ -53,7 +53,7 @@ And Python has a special data type for sets of unique items, the `set`.
|
||||
|
||||
Then we can import `Set` and declare `tags` as a `set` of `str`:
|
||||
|
||||
```Python hl_lines="1 15"
|
||||
```Python hl_lines="1 14"
|
||||
{!./tutorial/src/body_nested_models/tutorial003.py!}
|
||||
```
|
||||
|
||||
@@ -77,7 +77,7 @@ All that, arbitrarily nested.
|
||||
|
||||
For example, we can define an `Image` model:
|
||||
|
||||
```Python hl_lines="10 11 12"
|
||||
```Python hl_lines="9 10 11"
|
||||
{!./tutorial/src/body_nested_models/tutorial004.py!}
|
||||
```
|
||||
|
||||
@@ -85,7 +85,7 @@ For example, we can define an `Image` model:
|
||||
|
||||
And then we can use it as the type of an attribute:
|
||||
|
||||
```Python hl_lines="21"
|
||||
```Python hl_lines="20"
|
||||
{!./tutorial/src/body_nested_models/tutorial004.py!}
|
||||
```
|
||||
|
||||
@@ -120,7 +120,7 @@ To see all the options you have, checkout the docs for <a href="https://pydantic
|
||||
|
||||
For example, as in the `Image` model we have a `url` field, we can declare it to be instead of a `str`, a Pydantic's `UrlStr`:
|
||||
|
||||
```Python hl_lines="4 12"
|
||||
```Python hl_lines="5 11"
|
||||
{!./tutorial/src/body_nested_models/tutorial005.py!}
|
||||
```
|
||||
|
||||
@@ -130,7 +130,7 @@ The string will be checked to be a valid URL, and documented in JSON Schema / Op
|
||||
|
||||
You can also use Pydantic models as subtypes of `list`, `set`, etc:
|
||||
|
||||
```Python hl_lines="22"
|
||||
```Python hl_lines="21"
|
||||
{!./tutorial/src/body_nested_models/tutorial006.py!}
|
||||
```
|
||||
|
||||
@@ -167,7 +167,7 @@ This will expect (convert, validate, document, etc) a JSON body like:
|
||||
|
||||
You can define arbitrarily deeply nested models:
|
||||
|
||||
```Python hl_lines="11 16 22 25 29"
|
||||
```Python hl_lines="10 15 21 24 28"
|
||||
{!./tutorial/src/body_nested_models/tutorial007.py!}
|
||||
```
|
||||
|
||||
@@ -184,7 +184,7 @@ images: List[Image]
|
||||
|
||||
as in:
|
||||
|
||||
```Python hl_lines="17"
|
||||
```Python hl_lines="16"
|
||||
{!./tutorial/src/body_nested_models/tutorial008.py!}
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user