fix type UrlStr -> HttpUrl (#832)

This commit is contained in:
Dustyposa 2020-01-08 16:08:43 +08:00 committed by David Montague
parent 861ed37c97
commit 8d3dcbcd1b
5 changed files with 9 additions and 9 deletions

View File

@ -1,13 +1,13 @@
from typing import Set
from fastapi import FastAPI
from pydantic import BaseModel, UrlStr
from pydantic import BaseModel, HttpUrl
app = FastAPI()
class Image(BaseModel):
url: UrlStr
url: HttpUrl
name: str

View File

@ -1,13 +1,13 @@
from typing import List, Set
from fastapi import FastAPI
from pydantic import BaseModel, UrlStr
from pydantic import BaseModel, HttpUrl
app = FastAPI()
class Image(BaseModel):
url: UrlStr
url: HttpUrl
name: str

View File

@ -1,13 +1,13 @@
from typing import List, Set
from fastapi import FastAPI
from pydantic import BaseModel, UrlStr
from pydantic import BaseModel, HttpUrl
app = FastAPI()
class Image(BaseModel):
url: UrlStr
url: HttpUrl
name: str

View File

@ -1,13 +1,13 @@
from typing import List
from fastapi import FastAPI
from pydantic import BaseModel, UrlStr
from pydantic import BaseModel, HttpUrl
app = FastAPI()
class Image(BaseModel):
url: UrlStr
url: HttpUrl
name: str

View File

@ -118,7 +118,7 @@ Apart from normal singular types like `str`, `int`, `float`, etc. You can use mo
To see all the options you have, checkout the docs for <a href="https://pydantic-docs.helpmanual.io/#exotic-types" target="_blank">Pydantic's exotic types</a>. You will see some examples in the next chapter.
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`:
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 `HttpUrl`:
```Python hl_lines="4 10"
{!./src/body_nested_models/tutorial005.py!}