You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

5.9 KiB

💪 - 🔁 🏷

⏮️ FastAPI, 👆 💪 🔬, ✔, 📄, & ⚙️ 🎲 🙇 🐦 🏷 (👏 Pydantic).

📇 🏑

👆 💪 🔬 🔢 🏾. 🖼, 🐍 list:

{* ../../docs_src/body_nested_models/tutorial001.py hl[14] *}

👉 🔜tags 📇, 👐 🚫 📣 🆎 🔣 📇.

📇 🏑 ⏮️ 🆎 🔢

🐍 ✔️ 🎯 🌌 📣 📇 ⏮️ 🔗 🆎, ⚖️ "🆎 🔢":

🗄 ⌨ List

🐍 3️⃣.9️⃣ & 🔛 👆 💪 ⚙️ 🐩 list 📣 👫 🆎👥 🔜 👀 🔛. 👶

🐍 3️⃣.9️⃣ (3️⃣.6️⃣ & 🔛), 👆 🥇 💪 🗄 List ➡️ 🐩 🐍 typing 🕹:

{* ../../docs_src/body_nested_models/tutorial002.py hl[1] *}

📣 list ⏮️ 🆎 🔢

📣 🆎 👈 ✔️ 🆎 🔢 (🔗 🆎), 💖 list, dict, tuple:

  • 🚥 👆 🐍 🔅 🌘 3️⃣.9️⃣, 🗄 👫 🌓 ➡️ typing 🕹
  • 🚶‍♀️ 🔗 🆎(Ⓜ) "🆎 🔢" ⚙️ 🗜: [ & ]

🐍 3️⃣.9️⃣ 🔜:

my_list: list[str]

🐍3️⃣.9️⃣, 🔜:

from typing import List

my_list: List[str]

👈 🌐 🐩 🐍 🆎 📄.

⚙️ 👈 🎏 🐩 🏷 🔢 ⏮️ 🔗 🆎.

, 👆 🖼, 👥 💪tags 🎯 "📇 🎻":

{* ../../docs_src/body_nested_models/tutorial002.py hl[14] *}

🆎

⤴️ 👥 💭 🔃 ️, & 🤔 👈 🔖 🚫🔜 🚫 🔁, 👫 🔜 🎲 😍 🎻.

& 🐍 ✔️ 🎁 💽 🆎😍 🏬, set.

⤴️ 👥 💪 📣 tags🎻:

{* ../../docs_src/body_nested_models/tutorial003.py hl[1,14] *}

⏮️ 👉, 🚥 👆 📨 📨 ⏮️ 📊, 🔜 🗜 ⚒ 😍 🏬.

& 🕐 👆 🔢 👈 📊, 🚥✔️ , 🔜 🔢😍 🏬.

& 🔜 ✍ / 📄 ➡️ 💁‍♂️.

🐦 🏷

🔠 🔢 Pydantic 🏷 ✔️ 🆎.

👈 🆎 💪 1️⃣ Pydantic 🏷.

, 👆 💪 📣 🙇 🐦 🎻 "🎚" ⏮️ 🎯 🔢 📛, 🆎 & 🔬.

🌐 👈, 🎲 🐦.

🔬 📊

🖼, 👥 💪 🔬 Image 🏷:

{* ../../docs_src/body_nested_models/tutorial004.py hl[9:11] *}

⚙️ 📊 🆎

& ⤴️ 👥 💪 ⚙️ 🆎 🔢:

{* ../../docs_src/body_nested_models/tutorial004.py hl[20] *}

👉 🔜👈 FastAPI 🔜 💪 🎏:

{
    "name": "Foo",
    "description": "The pretender",
    "price": 42.0,
    "tax": 3.2,
    "tags": ["rock", "metal", "bar"],
    "image": {
        "url": "http://example.com/baz.jpg",
        "name": "The Foo live"
    }
}

🔄, 🤸 👈 📄, ⏮️ FastAPI 👆 🤚:

  • 👨‍🎨 🐕‍🦺 (🛠️, ️), 🐦 🏷
  • 💽 🛠️
  • 💽 🔬
  • 🏧 🧾

🎁 🆎 & 🔬

↖️ ➡️ 😐 🆎 💖 str, int, float, ️. 👆 💪 ⚙️ 🌅 🏗 🆎 👈 😖 ➡️ str.

👀 🌐 🎛 👆 ✔️, 🛒 🩺 Pydantic 😍 🆎. 👆 🔜 👀 🖼 ⏭ 📃.

🖼, Image 🏷 👥 ✔️ url 🏑, 👥 💪 📣 ↩️ str, Pydantic HttpUrl:

{* ../../docs_src/body_nested_models/tutorial005.py hl[4,10] *}

🎻 🔜 📛, & 📄 🎻 🔗 / 🗄 .

🔢 ⏮️ 📇 📊

👆 💪 ⚙️ Pydantic 🏷 🏾 list, set, ️:

{* ../../docs_src/body_nested_models/tutorial006.py hl[20] *}

👉 🔜 (🗜, ✔, 📄, ️) 🎻 💪 💖:

{
    "name": "Foo",
    "description": "The pretender",
    "price": 42.0,
    "tax": 3.2,
    "tags": [
        "rock",
        "metal",
        "bar"
    ],
    "images": [
        {
            "url": "http://example.com/baz.jpg",
            "name": "The Foo live"
        },
        {
            "url": "http://example.com/dave.jpg",
            "name": "The Baz"
        }
    ]
}

/// info

👀 images 🔑 🔜 ✔️ 📇 🖼 🎚.

///

🙇 🐦 🏷

👆 💪 🔬 🎲 🙇 🐦 🏷:

{* ../../docs_src/body_nested_models/tutorial007.py hl[9,14,20,23,27] *}

/// info

👀 Offer ✔️ 📇 ItemⓂ, 🔄 ✔️ 📦 📇 Image

///

💪 😁 📇

🚥 🔝 🎚 💲 🎻 💪 👆 🎻 array (🐍 list), 👆 💪 📣 🆎 🔢 🔢, 🎏 Pydantic 🏷:

images: List[Image]

⚖️ 🐍 3️⃣.9️⃣ & 🔛:

images: list[Image]

:

{* ../../docs_src/body_nested_models/tutorial008.py hl[15] *}

👨‍🎨 🐕‍🦺 🌐

& 👆 🤚 👨‍🎨 🐕‍🦺 🌐.

🏬 🔘 📇:

👆 🚫 🚫 🤚 👉 😇 👨‍🎨 🐕‍🦺 🚥 👆 👷 🔗 ⏮️ dict ↩️ Pydantic 🏷.

👆 🚫 ✔️ 😟 🔃 👫 👯‍♂️, 📨 #️⃣ 🗜 🔁 & 👆 🔢 🗜 🔁 🎻 💁‍♂️.

💪 dict

👆 💪 📣 💪 dict ⏮️ 🔑 🆎 & 💲 🎏 🆎.

🍵 ✔️ 💭 🏑/🔢 📛 (🔜 💼 ⏮️ Pydantic 🏷).

👉 🔜🚥 👆 💚 📨 🔑 👈 👆 🚫 💭.


🎏💼 🕐 👆 💚 ✔️ 🔑 🎏 🆎, int.

👈 👥 🔜 👀 📥.

👉 💼, 👆 🔜 🚫 🙆 dict 📏 ✔️ int 🔑 ⏮️ float 💲:

{* ../../docs_src/body_nested_models/tutorial009.py hl[9] *}

/// tip

✔️ 🤯 👈 🎻 🕴 🐕‍🦺 str 🔑.

️ Pydantic ✔️ 🏧 💽 🛠️.

👉👈, 👆 🛠️ 👩‍💻 💪 🕴 📨 🎻 🔑, 📏 👈 🎻 🔌 😁 🔢, Pydantic 🔜 🗜 👫 & ✔ 👫.

& dict 👆 📨 weights 🔜 🤙 ✔️ int 🔑 & float 💲.

///

🌃

⏮️ FastAPI 👆 ✔️ 🔆 💪 🚚 Pydantic 🏷, 🚧 👆 📟 🙅, 📏 & 😍.

⏮️ 🌐 💰:

  • 👨‍🎨 🐕‍🦺 (🛠️ 🌐 )
  • 💽 🛠️ (.Ⓜ.. ✍ / 🛠️)
  • 💽 🔬
  • 🔗 🧾
  • 🏧 🩺