Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 9 of 9 for CarItem (0.08 sec)

  1. docs_src/extra_models/tutorial003_py310.py

    from typing import Union
    
    from fastapi import FastAPI
    from pydantic import BaseModel
    
    app = FastAPI()
    
    
    class BaseItem(BaseModel):
        description: str
        type: str
    
    
    class CarItem(BaseItem):
        type: str = "car"
    
    
    class PlaneItem(BaseItem):
        type: str = "plane"
        size: int
    
    
    items = {
        "item1": {"description": "All my friends drive a low rider", "type": "car"},
        "item2": {
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Fri Jul 07 17:12:13 UTC 2023
    - 644 bytes
    - Viewed (0)
  2. docs/em/docs/tutorial/extra-models.md

    ### `Union` ๐Ÿ 3๏ธโƒฃ.1๏ธโƒฃ0๏ธโƒฃ
    
    ๐Ÿ‘‰ ๐Ÿ–ผ ๐Ÿ‘ฅ ๐Ÿšถโ€โ™€๏ธ `Union[PlaneItem, CarItem]` ๐Ÿ’ฒ โŒ `response_model`.
    
    โ†ฉ๏ธ ๐Ÿ‘ฅ ๐Ÿšถโ€โ™€๏ธ โšซ๏ธ **๐Ÿ’ฒ โŒ** โ†ฉ๏ธ ๐Ÿšฎ โšซ๏ธ **๐Ÿ†Ž โœ**, ๐Ÿ‘ฅ โœ”๏ธ โš™๏ธ `Union` ๐Ÿ 3๏ธโƒฃ.1๏ธโƒฃ0๏ธโƒฃ.
    
    ๐Ÿšฅ โšซ๏ธ ๐Ÿ†Ž โœ ๐Ÿ‘ฅ ๐Ÿ’ช โœ”๏ธ โš™๏ธ โธ โธ,:
    
    ```Python
    some_variable: PlaneItem | CarItem
    ```
    
    โœ‹๏ธ ๐Ÿšฅ ๐Ÿ‘ฅ ๐Ÿšฎ ๐Ÿ‘ˆ `response_model=PlaneItem | CarItem` ๐Ÿ‘ฅ ๐Ÿ”œ ๐Ÿคš โŒ, โ†ฉ๏ธ ๐Ÿ ๐Ÿ”œ ๐Ÿ”„ ๐ŸŽญ **โŒ ๐Ÿ› ๏ธ** ๐Ÿ–– `PlaneItem` & `CarItem` โ†ฉ๏ธ ๐Ÿ”ฌ ๐Ÿ‘ˆ ๐Ÿ†Ž โœ.
    
    ## ๐Ÿ“‡ ๐Ÿท
    
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sun Oct 06 20:36:54 UTC 2024
    - 6.8K bytes
    - Viewed (0)
  3. docs/en/docs/tutorial/extra-models.md

    ///
    
    //// tab | Python 3.10+
    
    ```Python hl_lines="1  14-15  18-20  33"
    {!> ../../docs_src/extra_models/tutorial003_py310.py!}
    ```
    
    ////
    
    //// tab | Python 3.8+
    
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sun Oct 06 20:36:54 UTC 2024
    - 7.7K bytes
    - Viewed (0)
  4. tests/test_tutorial/test_extra_models/test_tutorial003.py

                            "size": {"title": "Size", "type": "integer"},
                        },
                    },
                    "CarItem": {
                        "title": "CarItem",
                        "required": IsOneOf(
                            ["description", "type"],
                            # TODO: remove when deprecating Pydantic v1
                            ["description"],
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Fri Aug 04 20:47:07 UTC 2023
    - 5.1K bytes
    - Viewed (0)
  5. docs_src/extra_models/tutorial003.py

    from typing import Union
    
    from fastapi import FastAPI
    from pydantic import BaseModel
    
    app = FastAPI()
    
    
    class BaseItem(BaseModel):
        description: str
        type: str
    
    
    class CarItem(BaseItem):
        type: str = "car"
    
    
    class PlaneItem(BaseItem):
        type: str = "plane"
        size: int
    
    
    items = {
        "item1": {"description": "All my friends drive a low rider", "type": "car"},
        "item2": {
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Fri Jul 07 17:12:13 UTC 2023
    - 644 bytes
    - Viewed (0)
  6. tests/test_tutorial/test_extra_models/test_tutorial003_py310.py

                            "size": {"title": "Size", "type": "integer"},
                        },
                    },
                    "CarItem": {
                        "title": "CarItem",
                        "required": IsOneOf(
                            ["description", "type"],
                            # TODO: remove when deprecating Pydantic v1
                            ["description"],
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Fri Aug 04 20:47:07 UTC 2023
    - 5.3K bytes
    - Viewed (0)
  7. docs/pt/docs/tutorial/extra-models.md

    ///
    
    //// tab | Python 3.8 and above
    
    ```Python hl_lines="1  14-15  18-20  33"
    {!> ../../docs_src/extra_models/tutorial003.py!}
    ```
    
    ////
    
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sun Oct 06 20:36:54 UTC 2024
    - 7.8K bytes
    - Viewed (0)
  8. docs/de/docs/tutorial/extra-models.md

    ///
    
    //// tab | Python 3.10+
    
    ```Python hl_lines="1  14-15  18-20  33"
    {!> ../../docs_src/extra_models/tutorial003_py310.py!}
    ```
    
    ////
    
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sun Oct 06 20:36:54 UTC 2024
    - 8.7K bytes
    - Viewed (0)
  9. docs/zh/docs/tutorial/extra-models.md

    /// note | "็ฌ”่ฎฐ"
    
    ๅฎšไน‰ <a href="https://docs.pydantic.dev/latest/concepts/types/#unions" class="external-link" target="_blank">`Union`</a> ็ฑปๅž‹ๆ—ถ๏ผŒ่ฆๆŠŠ่ฏฆ็ป†็š„็ฑปๅž‹ๅ†™ๅœจๅ‰้ข๏ผŒ็„ถๅŽๆ˜ฏไธๅคช่ฏฆ็ป†็š„็ฑปๅž‹ใ€‚ไธ‹ไพ‹ไธญ๏ผŒๆ›ด่ฏฆ็ป†็š„ `PlaneItem` ไฝไบŽ `Union[PlaneItem๏ผŒCarItem]` ไธญ็š„ `CarItem` ไน‹ๅ‰ใ€‚
    
    ///
    
    //// tab | Python 3.10+
    
    ```Python hl_lines="1  14-15  18-20  33"
    {!> ../../docs_src/extra_models/tutorial003_py310.py!}
    ```
    
    ////
    
    //// tab | Python 3.8+
    
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sun Oct 06 20:36:54 UTC 2024
    - 6.6K bytes
    - Viewed (0)
Back to top