Search Options

Results per page
Sort
Preferred Languages
Advance

Results 141 - 150 of 530 for Union (0.06 sec)

  1. docs_src/schema_extra_example/tutorial001.py

    from typing import 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
    
        model_config = {
            "json_schema_extra": {
                "examples": [
                    {
                        "name": "Foo",
                        "description": "A very nice Item",
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Fri Jul 07 17:12:13 UTC 2023
    - 684 bytes
    - Viewed (0)
  2. docs_src/dependencies/tutorial005_an.py

    from typing import Union
    
    from fastapi import Cookie, Depends, FastAPI
    from typing_extensions import Annotated
    
    app = FastAPI()
    
    
    def query_extractor(q: Union[str, None] = None):
        return q
    
    
    def query_or_cookie_extractor(
        q: Annotated[str, Depends(query_extractor)],
        last_query: Annotated[Union[str, None], Cookie()] = None,
    ):
        if not q:
            return last_query
        return q
    
    
    @app.get("/items/")
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Tue Mar 26 16:56:53 UTC 2024
    - 558 bytes
    - Viewed (0)
  3. 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)
  4. 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)
  5. docs_src/schema_extra_example/tutorial001_pv1.py

    from typing import 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
    
        class Config:
            schema_extra = {
                "examples": [
                    {
                        "name": "Foo",
                        "description": "A very nice Item",
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Fri Jul 07 17:12:13 UTC 2023
    - 669 bytes
    - Viewed (0)
  6. 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)
  7. docs/pt/docs/tutorial/query-params-str-validations.md

    ```
    
    O parΓ’metro de consulta `q` Γ© do tipo `Union[str, None]`, o que significa que Γ© do tipo `str` mas que tambΓ©m pode ser `None`, e de fato, o valor padrΓ£o Γ© `None`, entΓ£o o FastAPI saberΓ‘ que nΓ£o Γ© obrigatΓ³rio.
    
    /// note | "Observação"
    
    O FastAPI saberΓ‘ que o valor de `q` nΓ£o Γ© obrigatΓ³rio por causa do valor padrΓ£o `= None`.
    
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sun Oct 06 20:36:54 UTC 2024
    - 9.3K bytes
    - Viewed (0)
  8. 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)
  9. 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)
  10. 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)
Back to top