Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 14 for CarItem (0.18 sec)

  1. 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": {
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Fri Jul 07 17:12:13 GMT 2023
    - 644 bytes
    - Viewed (1)
  2. 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"],
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Fri Aug 04 20:47:07 GMT 2023
    - 5.3K bytes
    - Viewed (0)
  3. docs/ru/docs/tutorial/extra-models.md

    ```Python
    some_variable: PlaneItem | CarItem
    ```
    
    Но если мы помещаем его в `response_model=PlaneItem | CarItem` мы получим ошибку, потому что Python попытается произвести **некорректную операцию** между `PlaneItem` и `CarItem` вместо того, чтобы интерпретировать это как аннотацию типа.
    
    ## Список моделей
    
    Таким же образом вы можете определять ответы как списки объектов.
    
    Plain Text
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Fri Mar 22 01:42:11 GMT 2024
    - 11.6K bytes
    - Viewed (0)
  4. docs/en/docs/tutorial/extra-models.md

    === "Python 3.10+"
    
        ```Python hl_lines="1  14-15  18-20  33"
        {!> ../../../docs_src/extra_models/tutorial003_py310.py!}
        ```
    
    === "Python 3.8+"
    
    Plain Text
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Thu Apr 18 19:53:19 GMT 2024
    - 7.7K bytes
    - Viewed (1)
  5. docs/pt/docs/tutorial/extra-models.md

    === "Python 3.8 and above"
    
        ```Python hl_lines="1  14-15  18-20  33"
        {!> ../../../docs_src/extra_models/tutorial003.py!}
        ```
    
    === "Python 3.10 and above"
    
    Plain Text
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Fri Mar 22 01:42:11 GMT 2024
    - 7.8K bytes
    - Viewed (0)
  6. 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` ↩️ 🔬 👈 🆎 ✍.
    
    ## 📇 🏷
    
    Plain Text
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Thu Apr 18 19:53:19 GMT 2024
    - 6.8K bytes
    - Viewed (0)
  7. 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": {
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Fri Jul 07 17:12:13 GMT 2023
    - 644 bytes
    - Viewed (0)
  8. 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"],
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Fri Aug 04 20:47:07 GMT 2023
    - 5.1K bytes
    - Viewed (0)
  9. docs/de/docs/tutorial/extra-models.md

    === "Python 3.10+"
    
        ```Python hl_lines="1  14-15  18-20  33"
        {!> ../../../docs_src/extra_models/tutorial003_py310.py!}
        ```
    
    === "Python 3.8+"
    
    Plain Text
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Sat Mar 30 20:26:47 GMT 2024
    - 8.7K bytes
    - Viewed (0)
  10. 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` 之前。
    
    === "Python 3.10+"
    
        ```Python hl_lines="1  14-15  18-20  33"
        {!> ../../../docs_src/extra_models/tutorial003_py310.py!}
        ```
    
    === "Python 3.8+"
    
    Plain Text
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Mon Apr 01 01:15:53 GMT 2024
    - 6.7K bytes
    - Viewed (0)
Back to top