Search Options

Display Count
Sort
Preferred Language
Advanced Search

Results 111 - 120 of 349 for unionOf (0.04 seconds)

  1. docs_src/security/tutorial005_an_py39.py

    class Token(BaseModel):
        access_token: str
        token_type: str
    
    
    class TokenData(BaseModel):
        username: Union[str, None] = None
        scopes: list[str] = []
    
    
    class User(BaseModel):
        username: str
        email: Union[str, None] = None
        full_name: Union[str, None] = None
        disabled: Union[bool, None] = None
    
    
    class UserInDB(User):
        hashed_password: str
    
    
    Created: Sun Dec 28 07:19:09 GMT 2025
    - Last Modified: Mon Sep 29 02:57:38 GMT 2025
    - 5.3K bytes
    - Click Count (0)
  2. docs_src/response_model/tutorial003_05_py39.py

    from typing import Union
    
    from fastapi import FastAPI, Response
    from fastapi.responses import RedirectResponse
    
    app = FastAPI()
    
    
    @app.get("/portal", response_model=None)
    async def get_portal(teleport: bool = False) -> Union[Response, dict]:
        if teleport:
            return RedirectResponse(url="https://www.youtube.com/watch?v=dQw4w9WgXcQ")
    Created: Sun Dec 28 07:19:09 GMT 2025
    - Last Modified: Wed Dec 17 20:41:43 GMT 2025
    - 405 bytes
    - Click Count (0)
  3. docs_src/path_operation_configuration/tutorial004_py39.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
        tags: set[str] = set()
    
    
    @app.post("/items/", response_model=Item, summary="Create an item")
    async def create_item(item: Item):
        """
        Create an item with all the information:
    
    Created: Sun Dec 28 07:19:09 GMT 2025
    - Last Modified: Sat May 14 11:59:59 GMT 2022
    - 676 bytes
    - Click Count (0)
  4. docs_src/encoder/tutorial001_py39.py

    from datetime import datetime
    from typing import Union
    
    from fastapi import FastAPI
    from fastapi.encoders import jsonable_encoder
    from pydantic import BaseModel
    
    fake_db = {}
    
    
    class Item(BaseModel):
        title: str
        timestamp: datetime
        description: Union[str, None] = None
    
    
    app = FastAPI()
    
    
    @app.put("/items/{id}")
    def update_item(id: str, item: Item):
        json_compatible_item_data = jsonable_encoder(item)
    Created: Sun Dec 28 07:19:09 GMT 2025
    - Last Modified: Wed Dec 17 20:41:43 GMT 2025
    - 461 bytes
    - Click Count (0)
  5. docs_src/response_directly/tutorial001_py39.py

    from datetime import datetime
    from typing import Union
    
    from fastapi import FastAPI
    from fastapi.encoders import jsonable_encoder
    from fastapi.responses import JSONResponse
    from pydantic import BaseModel
    
    
    class Item(BaseModel):
        title: str
        timestamp: datetime
        description: Union[str, None] = None
    
    
    app = FastAPI()
    
    
    @app.put("/items/{id}")
    def update_item(id: str, item: Item):
    Created: Sun Dec 28 07:19:09 GMT 2025
    - Last Modified: Wed Dec 17 20:41:43 GMT 2025
    - 505 bytes
    - Click Count (0)
  6. docs_src/dependencies/tutorial001_an_py39.py

    from typing import Annotated, Union
    
    from fastapi import Depends, FastAPI
    
    app = FastAPI()
    
    
    async def common_parameters(
        q: Union[str, None] = None, skip: int = 0, limit: int = 100
    ):
        return {"q": q, "skip": skip, "limit": limit}
    
    
    @app.get("/items/")
    async def read_items(commons: Annotated[dict, Depends(common_parameters)]):
        return commons
    
    
    @app.get("/users/")
    Created: Sun Dec 28 07:19:09 GMT 2025
    - Last Modified: Sat Mar 18 12:29:59 GMT 2023
    - 473 bytes
    - Click Count (0)
  7. docs_src/query_params/tutorial004_py39.py

    from typing import Union
    
    from fastapi import FastAPI
    
    app = FastAPI()
    
    
    @app.get("/users/{user_id}/items/{item_id}")
    async def read_user_item(
        user_id: int, item_id: str, q: Union[str, None] = None, short: bool = False
    ):
        item = {"item_id": item_id, "owner_id": user_id}
        if q:
            item.update({"q": q})
        if not short:
            item.update(
    Created: Sun Dec 28 07:19:09 GMT 2025
    - Last Modified: Wed Dec 17 20:41:43 GMT 2025
    - 468 bytes
    - Click Count (0)
  8. docs_src/extra_data_types/tutorial001_py39.py

    from datetime import datetime, time, timedelta
    from typing import Union
    from uuid import UUID
    
    from fastapi import Body, FastAPI
    
    app = FastAPI()
    
    
    @app.put("/items/{item_id}")
    async def read_items(
        item_id: UUID,
        start_datetime: datetime = Body(),
        end_datetime: datetime = Body(),
        process_after: timedelta = Body(),
        repeat_at: Union[time, None] = Body(default=None),
    ):
    Created: Sun Dec 28 07:19:09 GMT 2025
    - Last Modified: Wed Dec 17 20:41:43 GMT 2025
    - 755 bytes
    - Click Count (0)
  9. docs_src/python_types/tutorial008b_py39.py

    from typing import Union
    
    
    def process_item(item: Union[int, str]):
    Created: Sun Dec 28 07:19:09 GMT 2025
    - Last Modified: Wed Dec 17 20:41:43 GMT 2025
    - 84 bytes
    - Click Count (0)
  10. docs/ru/docs/python-types.md

    ```
    
    ////
    
    #### Использовать `Union` или `Optional` { #using-union-or-optional }
    
    Если вы используете версию Python ниже 3.10, вот совет с моей весьма **субъективной** точки зрения:
    
    * 🚨 Избегайте использования `Optional[SomeType]`
    * Вместо этого ✨ **используйте `Union[SomeType, None]`** ✨.
    
    Created: Sun Dec 28 07:19:09 GMT 2025
    - Last Modified: Wed Dec 17 20:41:43 GMT 2025
    - 24.4K bytes
    - Click Count (0)
Back to Top