mirror of https://github.com/tiangolo/fastapi.git
fix type UrlStr -> HttpUrl (#832)
This commit is contained in:
parent
861ed37c97
commit
8d3dcbcd1b
|
|
@ -1,13 +1,13 @@
|
||||||
from typing import Set
|
from typing import Set
|
||||||
|
|
||||||
from fastapi import FastAPI
|
from fastapi import FastAPI
|
||||||
from pydantic import BaseModel, UrlStr
|
from pydantic import BaseModel, HttpUrl
|
||||||
|
|
||||||
app = FastAPI()
|
app = FastAPI()
|
||||||
|
|
||||||
|
|
||||||
class Image(BaseModel):
|
class Image(BaseModel):
|
||||||
url: UrlStr
|
url: HttpUrl
|
||||||
name: str
|
name: str
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
from typing import List, Set
|
from typing import List, Set
|
||||||
|
|
||||||
from fastapi import FastAPI
|
from fastapi import FastAPI
|
||||||
from pydantic import BaseModel, UrlStr
|
from pydantic import BaseModel, HttpUrl
|
||||||
|
|
||||||
app = FastAPI()
|
app = FastAPI()
|
||||||
|
|
||||||
|
|
||||||
class Image(BaseModel):
|
class Image(BaseModel):
|
||||||
url: UrlStr
|
url: HttpUrl
|
||||||
name: str
|
name: str
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
from typing import List, Set
|
from typing import List, Set
|
||||||
|
|
||||||
from fastapi import FastAPI
|
from fastapi import FastAPI
|
||||||
from pydantic import BaseModel, UrlStr
|
from pydantic import BaseModel, HttpUrl
|
||||||
|
|
||||||
app = FastAPI()
|
app = FastAPI()
|
||||||
|
|
||||||
|
|
||||||
class Image(BaseModel):
|
class Image(BaseModel):
|
||||||
url: UrlStr
|
url: HttpUrl
|
||||||
name: str
|
name: str
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
from fastapi import FastAPI
|
from fastapi import FastAPI
|
||||||
from pydantic import BaseModel, UrlStr
|
from pydantic import BaseModel, HttpUrl
|
||||||
|
|
||||||
app = FastAPI()
|
app = FastAPI()
|
||||||
|
|
||||||
|
|
||||||
class Image(BaseModel):
|
class Image(BaseModel):
|
||||||
url: UrlStr
|
url: HttpUrl
|
||||||
name: str
|
name: str
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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.
|
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"
|
```Python hl_lines="4 10"
|
||||||
{!./src/body_nested_models/tutorial005.py!}
|
{!./src/body_nested_models/tutorial005.py!}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue