Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 586 for union (0.29 sec)

  1. tests/test_union_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 OtherItem(BaseModel):
        price: int
    
    
    @app.post("/items/")
    def save_union_body(item: Union[OtherItem, Item]):
        return {"item": item}
    
    
    Python
    - Registered: Sun Apr 14 07:19:09 GMT 2024
    - Last Modified: Fri Jul 07 17:12:13 GMT 2023
    - 4.6K 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}
    
    
    Python
    - Registered: Sun Apr 14 07:19:09 GMT 2024
    - Last Modified: Fri Jul 07 17:12:13 GMT 2023
    - 5.2K bytes
    - Viewed (0)
  3. fastapi/params.py

                ),
            ] = None,
            discriminator: Union[str, None] = None,
            strict: Union[bool, None] = _Unset,
            multiple_of: Union[float, None] = _Unset,
            allow_inf_nan: Union[bool, None] = _Unset,
            max_digits: Union[int, None] = _Unset,
            decimal_places: Union[int, None] = _Unset,
            examples: Optional[List[Any]] = None,
            example: Annotated[
    Python
    - Registered: Sun Apr 14 07:19:09 GMT 2024
    - Last Modified: Sat Aug 26 18:03:13 GMT 2023
    - 27.2K bytes
    - Viewed (1)
  4. fastapi/param_functions.py

            ),
        ] = None,
        discriminator: Annotated[
            Union[str, None],
            Doc(
                """
                Parameter field name for discriminating the type in a tagged union.
                """
            ),
        ] = None,
        strict: Annotated[
            Union[bool, None],
            Doc(
                """
                If `True`, strict validation is applied to the field.
    Python
    - Registered: Sun Apr 14 07:19:09 GMT 2024
    - Last Modified: Tue Apr 02 02:48:51 GMT 2024
    - 62.4K bytes
    - Viewed (0)
  5. docs_src/body_multiple_params/tutorial001.py

    from fastapi import FastAPI, Path
    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 = Path(title="The ID of the item to get", ge=0, le=1000),
        q: Union[str, None] = None,
    Python
    - Registered: Sun Apr 14 07:19:09 GMT 2024
    - Last Modified: Fri May 13 23:38:22 GMT 2022
    - 596 bytes
    - Viewed (0)
  6. tests/test_compat.py

        assert response2.json() == [1, 2]
    
    
    def test_is_bytes_sequence_annotation_union():
        # For coverage
        # TODO: in theory this would allow declaring types that could be lists of bytes
        # to be read from files and other types, but I'm not even sure it's a good idea
        # to support it as a first class "feature"
        assert is_bytes_sequence_annotation(Union[List[str], List[bytes]])
    
    
    def test_is_uploadfile_sequence_annotation():
    Python
    - Registered: Sun Apr 14 07:19:09 GMT 2024
    - Last Modified: Thu Sep 28 04:14:40 GMT 2023
    - 2.8K bytes
    - Viewed (0)
  7. docs_src/body_nested_models/tutorial004.py

    from typing import Set, Union
    
    from fastapi import FastAPI
    from pydantic import BaseModel
    
    app = FastAPI()
    
    
    class Image(BaseModel):
        url: str
        name: str
    
    
    class Item(BaseModel):
        name: str
        description: Union[str, None] = None
        price: float
        tax: Union[float, None] = None
        tags: Set[str] = set()
        image: Union[Image, None] = None
    
    
    @app.put("/items/{item_id}")
    Python
    - Registered: Sun Apr 14 07:19:09 GMT 2024
    - Last Modified: Sat May 14 11:59:59 GMT 2022
    - 504 bytes
    - Viewed (0)
  8. docs_src/body_nested_models/tutorial006.py

    from typing import List, Set, Union
    
    from fastapi import FastAPI
    from pydantic import BaseModel, HttpUrl
    
    app = FastAPI()
    
    
    class Image(BaseModel):
        url: HttpUrl
        name: str
    
    
    class Item(BaseModel):
        name: str
        description: Union[str, None] = None
        price: float
        tax: Union[float, None] = None
        tags: Set[str] = set()
        images: Union[List[Image], None] = None
    
    
    @app.put("/items/{item_id}")
    Python
    - Registered: Sun Apr 14 07:19:09 GMT 2024
    - Last Modified: Sat May 14 11:59:59 GMT 2022
    - 530 bytes
    - Viewed (0)
  9. docs_src/body_multiple_params/tutorial003.py

    from typing import 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
    
    
    class User(BaseModel):
        username: str
        full_name: Union[str, None] = None
    
    
    @app.put("/items/{item_id}")
    Python
    - Registered: Sun Apr 14 07:19:09 GMT 2024
    - Last Modified: Fri May 13 23:38:22 GMT 2022
    - 548 bytes
    - Viewed (0)
  10. docs_src/security/tutorial002.py

    from typing import Union
    
    from fastapi import Depends, FastAPI
    from fastapi.security import OAuth2PasswordBearer
    from pydantic import BaseModel
    
    app = FastAPI()
    
    oauth2_scheme = OAuth2PasswordBearer(tokenUrl="token")
    
    
    class User(BaseModel):
        username: str
        email: Union[str, None] = None
        full_name: Union[str, None] = None
        disabled: Union[bool, None] = None
    
    
    def fake_decode_token(token):
        return User(
    Python
    - Registered: Sun Apr 14 07:19:09 GMT 2024
    - Last Modified: Sat May 14 11:59:59 GMT 2022
    - 755 bytes
    - Viewed (0)
Back to top