Search Options

Display Count
Sort
Preferred Language
Advanced Search

Results 41 - 50 of 844 for pydantic (0.05 seconds)

  1. docs/en/docs/advanced/json-base64-bytes.md

    Use base64 only if you definitely need to include binary data in JSON, and you can't use files for that.
    
    ## Pydantic `bytes` { #pydantic-bytes }
    
    You can declare a Pydantic model with `bytes` fields, and then use `val_json_bytes` in the model config to tell it to use base64 to *validate* input JSON data, as part of that validation it will decode the base64 string into bytes.
    
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Thu Mar 05 18:13:19 GMT 2026
    - 2.4K bytes
    - Click Count (0)
  2. docs/zh-hant/docs/tutorial/encoder.md

    在某些情況下,你可能需要將某種資料型別(例如 Pydantic 模型)轉換為與 JSON 相容的類型(例如 `dict`、`list` 等)。
    
    例如,當你需要把它儲存在資料庫中。
    
    為此,**FastAPI** 提供了 `jsonable_encoder()` 函式。
    
    ## 使用 `jsonable_encoder` { #using-the-jsonable-encoder }
    
    想像你有一個只接受與 JSON 相容資料的資料庫 `fake_db`。
    
    例如,它不接受 `datetime` 物件,因為那與 JSON 不相容。
    
    因此,必須將 `datetime` 物件轉為一個以 [ISO 格式](https://en.wikipedia.org/wiki/ISO_8601) 表示資料的 `str`。
    
    同樣地,這個資料庫不會接受 Pydantic 模型(帶有屬性的物件),只接受 `dict`。
    
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Fri Mar 20 17:05:38 GMT 2026
    - 1.5K bytes
    - Click Count (0)
  3. docs/en/docs/how-to/separate-openapi-schemas.md

    Since **Pydantic v2** was released, the generated OpenAPI is a bit more exact and **correct** than before. 😎
    
    In fact, in some cases, it will even have **two JSON Schemas** in OpenAPI for the same Pydantic model, for input and output, depending on if they have **default values**.
    
    Let's see how that works and how to change it if you need to do that.
    
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Sat Dec 20 15:55:38 GMT 2025
    - 4.5K bytes
    - Click Count (0)
  4. docs/en/docs/advanced/path-operation-advanced-configuration.md

    You could do that with `openapi_extra`:
    
    {* ../../docs_src/path_operation_advanced_configuration/tutorial006_py310.py hl[19:36, 39:40] *}
    
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Thu Mar 05 18:13:19 GMT 2026
    - 7.1K bytes
    - Click Count (0)
  5. docs/zh/docs/tutorial/cookie-param-models.md

    # Cookie 参数模型 { #cookie-parameter-models }
    
    如果您有一组相关的 **cookie**,您可以创建一个 **Pydantic 模型**来声明它们。🍪
    
    这将允许您在**多个地方**能够**重用模型**,并且可以一次性声明所有参数的验证方式和元数据。😎
    
    /// note | 注意
    
    自 FastAPI 版本 `0.115.0` 起支持此功能。🤓
    
    ///
    
    /// tip | 提示
    
    此技术同样适用于 `Query` 、 `Cookie` 和 `Header` 。😎
    
    ///
    
    ## 带有 Pydantic 模型的 Cookie { #cookies-with-a-pydantic-model }
    
    在 **Pydantic** 模型中声明所需的 **cookie** 参数,然后将参数声明为 `Cookie` :
    
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Fri Feb 13 13:37:57 GMT 2026
    - 3K bytes
    - Click Count (0)
  6. docs/zh/docs/tutorial/encoder.md

    在某些情况下,您可能需要将数据类型(如Pydantic模型)转换为与JSON兼容的数据类型(如`dict`、`list`等)。
    
    比如,如果您需要将其存储在数据库中。
    
    对于这种要求, **FastAPI**提供了`jsonable_encoder()`函数。
    
    ## 使用`jsonable_encoder` { #using-the-jsonable-encoder }
    
    让我们假设你有一个数据库名为`fake_db`,它只能接收与JSON兼容的数据。
    
    例如,它不接收`datetime`这类的对象,因为这些对象与JSON不兼容。
    
    因此,`datetime`对象必须转换为包含[ISO 格式](https://en.wikipedia.org/wiki/ISO_8601)的`str`类型对象。
    
    同样,这个数据库也不会接收Pydantic模型(带有属性的对象),而只接收`dict`。
    
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Fri Mar 20 17:06:37 GMT 2026
    - 1.5K bytes
    - Click Count (0)
  7. docs/zh/docs/tutorial/security/get-current-user.md

    上一章中,(基于依赖注入系统的)安全系统向*路径操作函数*传递了 `str` 类型的 `token`:
    
    {* ../../docs_src/security/tutorial001_an_py310.py hl[12] *}
    
    但这并不实用。
    
    接下来,我们学习如何返回当前用户。
    
    
    ## 创建用户模型 { #create-a-user-model }
    
    首先,创建 Pydantic 用户模型。
    
    与使用 Pydantic 声明请求体相同,并且可在任何位置使用:
    
    {* ../../docs_src/security/tutorial002_an_py310.py hl[5,12:6] *}
    
    ## 创建 `get_current_user` 依赖项 { #create-a-get-current-user-dependency }
    
    创建 `get_current_user` 依赖项。
    
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Fri Feb 13 13:37:57 GMT 2026
    - 3.6K bytes
    - Click Count (0)
  8. docs/zh-hant/docs/how-to/separate-openapi-schemas.md

    # 是否將輸入與輸出使用不同的 OpenAPI 結構描述 { #separate-openapi-schemas-for-input-and-output-or-not }
    
    自從 Pydantic v2 發佈後,生成的 OpenAPI 比以往更精確也更正確。😎
    
    實際上,在某些情況下,同一個 Pydantic 模型在 OpenAPI 中會同時有兩個 JSON Schema:分別用於輸入與輸出,這取決於它是否有預設值。
    
    來看看它如何運作,以及若需要時該如何調整。
    
    ## 作為輸入與輸出的 Pydantic 模型 { #pydantic-models-for-input-and-output }
    
    假設你有一個帶有預設值的 Pydantic 模型,如下所示:
    
    {* ../../docs_src/separate_openapi_schemas/tutorial001_py310.py ln[1:7] hl[7] *}
    
    ### 輸入用模型 { #model-for-input }
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Sat Feb 14 08:15:26 GMT 2026
    - 4.1K bytes
    - Click Count (0)
  9. docs/zh/docs/how-to/separate-openapi-schemas.md

    # 是否为输入和输出分别生成 OpenAPI JSON Schema { #separate-openapi-schemas-for-input-and-output-or-not }
    
    自从发布了 **Pydantic v2**,生成的 OpenAPI 比之前更精确、更**正确**了。😎
    
    事实上,在某些情况下,对于同一个 Pydantic 模型,OpenAPI 中会根据是否带有**默认值**,为输入和输出分别生成**两个 JSON Schema**。
    
    我们来看看它如何工作,以及在需要时如何修改。
    
    ## 用于输入和输出的 Pydantic 模型 { #pydantic-models-for-input-and-output }
    
    假设你有一个带有默认值的 Pydantic 模型,例如:
    
    {* ../../docs_src/separate_openapi_schemas/tutorial001_py310.py ln[1:7] hl[7] *}
    
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Fri Feb 13 13:37:57 GMT 2026
    - 4.3K bytes
    - Click Count (0)
  10. docs/en/docs/tutorial/response-model.md

    ///
    
    `response_model` receives the same type you would declare for a Pydantic model field, so, it can be a Pydantic model, but it can also be, e.g. a `list` of Pydantic models, like `List[Item]`.
    
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Thu Mar 05 18:13:19 GMT 2026
    - 15.5K bytes
    - Click Count (0)
Back to Top