Search Options

Results per page
Sort
Preferred Languages
Advance

Results 151 - 160 of 533 for union_ (0.04 sec)

  1. docs_src/schema_extra_example/tutorial003_an_py39.py

    from typing import Annotated, Union
    
    from fastapi import Body, FastAPI
    from pydantic import BaseModel
    
    app = FastAPI()
    
    
    class Item(BaseModel):
        name: str
        description: Union[str, None] = None
        price: float
        tax: Union[float, None] = None
    
    
    @app.put("/items/{item_id}")
    async def update_item(
        item_id: int,
        item: Annotated[
            Item,
            Body(
                examples=[
                    {
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Fri Jun 30 18:25:16 UTC 2023
    - 692 bytes
    - Viewed (0)
  2. tests/test_union_inherited_body.py

    from typing import Optional, Union
    
    from dirty_equals import IsDict
    from fastapi import FastAPI
    from fastapi.testclient import TestClient
    from pydantic import BaseModel
    
    app = FastAPI()
    
    
    class Item(BaseModel):
        name: Optional[str] = None
    
    
    class ExtendedItem(Item):
        age: int
    
    
    @app.post("/items/")
    def save_union_different_body(item: Union[ExtendedItem, Item]):
        return {"item": item}
    
    
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Fri Jul 07 17:12:13 UTC 2023
    - 5.2K bytes
    - Viewed (0)
  3. docs_src/query_params_str_validations/tutorial014_an_py39.py

    from typing import Annotated, Union
    
    from fastapi import FastAPI, Query
    
    app = FastAPI()
    
    
    @app.get("/items/")
    async def read_items(
        hidden_query: Annotated[Union[str, None], Query(include_in_schema=False)] = None,
    ):
        if hidden_query:
            return {"hidden_query": hidden_query}
        else:
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Tue Mar 26 16:56:53 UTC 2024
    - 344 bytes
    - Viewed (0)
  4. docs_src/response_model/tutorial001_py39.py

    from typing import Any, Union
    
    from fastapi import FastAPI
    from pydantic import BaseModel
    
    app = FastAPI()
    
    
    class Item(BaseModel):
        name: str
        description: Union[str, None] = None
        price: float
        tax: Union[float, None] = None
        tags: list[str] = []
    
    
    @app.post("/items/", response_model=Item)
    async def create_item(item: Item) -> Any:
        return item
    
    
    @app.get("/items/", response_model=list[Item])
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sat Jan 07 13:45:48 UTC 2023
    - 556 bytes
    - Viewed (0)
  5. docs_src/schema_extra_example/tutorial003_an.py

    from typing import Union
    
    from fastapi import Body, FastAPI
    from pydantic import BaseModel
    from typing_extensions import Annotated
    
    app = FastAPI()
    
    
    class Item(BaseModel):
        name: str
        description: Union[str, None] = None
        price: float
        tax: Union[float, None] = None
    
    
    @app.put("/items/{item_id}")
    async def update_item(
        item_id: int,
        item: Annotated[
            Item,
            Body(
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Fri Jun 30 18:25:16 UTC 2023
    - 721 bytes
    - Viewed (0)
  6. docs_src/query_params_str_validations/tutorial007_an.py

    from typing import Union
    
    from fastapi import FastAPI, Query
    from typing_extensions import Annotated
    
    app = FastAPI()
    
    
    @app.get("/items/")
    async def read_items(
        q: Annotated[Union[str, None], Query(title="Query string", min_length=3)] = None,
    ):
        results = {"items": [{"item_id": "Foo"}, {"item_id": "Bar"}]}
        if q:
            results.update({"q": q})
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Tue Mar 26 16:56:53 UTC 2024
    - 379 bytes
    - Viewed (0)
  7. docs_src/response_model/tutorial003_04.py

    from typing import Union
    
    from fastapi import FastAPI, Response
    from fastapi.responses import RedirectResponse
    
    app = FastAPI()
    
    
    @app.get("/portal")
    async def get_portal(teleport: bool = False) -> Union[Response, dict]:
        if teleport:
            return RedirectResponse(url="https://www.youtube.com/watch?v=dQw4w9WgXcQ")
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Tue Jan 10 16:22:47 UTC 2023
    - 384 bytes
    - Viewed (0)
  8. docs/em/docs/python-types.md

    ```
    
    ////
    
    #### ⚙ī¸ `Union` ⚖ī¸ `Optional`
    
    đŸšĨ 👆 ⚙ī¸ 🐍 âŦ 🔛 3ī¸âƒŖ.1ī¸âƒŖ0ī¸âƒŖ, đŸ“Ĩ 💁‍♂ âšĒī¸âžĄī¸ 👇 đŸ“ļ **🤔** ☝ 🎑:
    
    * đŸ‘ļ ❎ ⚙ī¸ `Optional[SomeType]`
    * ↩ī¸ đŸ‘ļ **⚙ī¸ `Union[SomeType, None]`** đŸ‘ļ.
    
    đŸ‘¯â€â™‚ī¸ 🌓 & 🔘 đŸ‘Ģ 🎏, ✋ī¸ 👤 🔜 👍 `Union` ↩ī¸ `Optional` ↩ī¸ 🔤 "**đŸ“Ļ**" 🔜 😑 🔑 👈 💲 đŸ“Ļ, & âšĢī¸ 🤙 ⛓ "âšĢī¸ đŸ’Ē `None`", đŸšĨ âšĢī¸ đŸšĢ đŸ“Ļ & ✔.
    
    👤 💭 `Union[SomeType, None]` 🌖 🔑 🔃 âšĢī¸â” âšĢī¸ ⛓.
    
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sun Oct 06 20:36:54 UTC 2024
    - 13.4K bytes
    - Viewed (0)
  9. docs/em/docs/tutorial/query-params-str-validations.md

    ```Python hl_lines="7"
    {!> ../../docs_src/query_params_str_validations/tutorial001_py310.py!}
    ```
    
    ////
    
    đŸ”ĸ đŸ”ĸ `q` 🆎 `Union[str, None]` (⚖ī¸ `str | None` 🐍 3ī¸âƒŖ.1ī¸âƒŖ0ī¸âƒŖ), 👈 ⛓ 👈 âšĢī¸ 🆎 `str` ✋ī¸ đŸ’Ē `None`, & 👐, đŸ”ĸ 💲 `None`, FastAPI 🔜 💭 âšĢī¸ đŸšĢ ✔.
    
    /// note
    
    FastAPI 🔜 💭 👈 💲 `q` đŸšĢ ✔ ↩ī¸ đŸ”ĸ 💲 `= None`.
    
     `Union` `Union[str, None]` 🔜 ✔ 👆 👨‍🎨 🤝 👆 👍 🐕‍đŸĻē & 🔍 ❌.
    
    ///
    
    ## 🌖 đŸ”Ŧ
    
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sun Oct 06 20:36:54 UTC 2024
    - 11.7K bytes
    - Viewed (0)
  10. docs_src/body_fields/tutorial001.py

    from typing import Union
    
    from fastapi import Body, FastAPI
    from pydantic import BaseModel, Field
    
    app = FastAPI()
    
    
    class Item(BaseModel):
        name: str
        description: Union[str, None] = Field(
            default=None, title="The description of the item", max_length=300
        )
        price: float = Field(gt=0, description="The price must be greater than zero")
        tax: Union[float, None] = None
    
    
    @app.put("/items/{item_id}")
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Fri May 13 23:38:22 UTC 2022
    - 561 bytes
    - Viewed (0)
Back to top