Search Options

Display Count
Sort
Preferred Language
Advanced Search

Results 1 - 10 of 236 for forbid (0.31 seconds)

  1. docs/en/docs/tutorial/query-param-models.md

    <div class="screenshot">
    <img src="/img/tutorial/query-param-models/image01.png">
    </div>
    
    ## Forbid Extra Query Parameters { #forbid-extra-query-parameters }
    
    In some special use cases (probably not very common), you might want to **restrict** the query parameters that you want to receive.
    
    You can use Pydantic's model configuration to `forbid` any `extra` fields:
    
    {* ../../docs_src/query_param_models/tutorial002_an_py310.py hl[10] *}
    
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Sun Aug 31 09:15:41 GMT 2025
    - 2.2K bytes
    - Click Count (0)
  2. docs/en/docs/tutorial/header-param-models.md

    <div class="screenshot">
    <img src="/img/tutorial/header-param-models/image01.png">
    </div>
    
    ## Forbid Extra Headers { #forbid-extra-headers }
    
    In some special use cases (probably not very common), you might want to **restrict** the headers that you want to receive.
    
    You can use Pydantic's model configuration to `forbid` any `extra` fields:
    
    {* ../../docs_src/header_param_models/tutorial002_an_py310.py hl[10] *}
    
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Sun Aug 31 09:15:41 GMT 2025
    - 2.6K bytes
    - Click Count (0)
  3. docs/en/docs/tutorial/request-form-models.md

    <div class="screenshot">
    <img src="/img/tutorial/request-form-models/image01.png">
    </div>
    
    ## Forbid Extra Form Fields { #forbid-extra-form-fields }
    
    In some special use cases (probably not very common), you might want to **restrict** the form fields to only those declared in the Pydantic model. And **forbid** any **extra** fields.
    
    /// note
    
    This is supported since FastAPI version `0.114.0`. 🤓
    
    ///
    
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Thu Mar 05 18:13:19 GMT 2026
    - 2.1K bytes
    - Click Count (0)
  4. docs/en/docs/tutorial/cookie-param-models.md

    But even if you **fill the data** and click "Execute", because the docs UI works with **JavaScript**, the cookies won't be sent, and you will see an **error** message as if you didn't write any values.
    
    ///
    
    ## Forbid Extra Cookies { #forbid-extra-cookies }
    
    In some special use cases (probably not very common), you might want to **restrict** the cookies that you want to receive.
    
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Tue Feb 10 11:48:27 GMT 2026
    - 3.1K bytes
    - Click Count (0)
  5. docs_src/query_param_models/tutorial002_an_py310.py

    from typing import Annotated, Literal
    
    from fastapi import FastAPI, Query
    from pydantic import BaseModel, Field
    
    app = FastAPI()
    
    
    class FilterParams(BaseModel):
        model_config = {"extra": "forbid"}
    
        limit: int = Field(100, gt=0, le=100)
        offset: int = Field(0, ge=0)
        order_by: Literal["created_at", "updated_at"] = "created_at"
        tags: list[str] = []
    
    
    @app.get("/items/")
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Tue Sep 17 18:54:10 GMT 2024
    - 483 bytes
    - Click Count (0)
  6. docs/zh-hant/docs/tutorial/cookie-param-models.md

    但即使你**填入資料**並點擊「Execute」,因為該文件介面是以 **JavaScript** 運作,Cookie 不會被送出,你會看到**錯誤**訊息,就像完全沒有填任何值一樣。
    
    ///
    
    ## 禁止額外的 Cookie { #forbid-extra-cookies }
    
    在某些特殊情境(可能不太常見)下,你可能會想**限制**允許接收的 Cookie。
    
    你的 API 現在也能掌控自己的 <dfn title="這只是個玩笑,提醒一下。這與 Cookie 同意無關,但有趣的是連 API 現在也能拒絕可憐的 Cookie。請收下這塊餅乾。🍪">Cookie 同意</dfn>。🤪🍪
    
    你可以使用 Pydantic 的模型設定來 `forbid` 任何 `extra` 欄位:
    
    {* ../../docs_src/cookie_param_models/tutorial002_an_py310.py hl[10] *}
    
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Sat Feb 14 08:15:26 GMT 2026
    - 2.9K bytes
    - Click Count (0)
  7. docs/zh/docs/tutorial/request-form-models.md

    <div class="screenshot">
    <img src="/img/tutorial/request-form-models/image01.png">
    </div>
    
    ## 禁止额外的表单字段 { #forbid-extra-form-fields }
    
    在某些特殊使用情况下(可能并不常见),你可能希望将表单字段**限制**为仅在 Pydantic 模型中声明过的字段,并**禁止**任何**额外**的字段。
    
    /// note | 注意
    
    自 FastAPI 版本 `0.114.0` 起支持此功能。🤓
    
    ///
    
    你可以使用 Pydantic 的模型配置来 `forbid` 任何 `extra` 字段:
    
    {* ../../docs_src/request_form_models/tutorial002_an_py310.py hl[12] *}
    
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Fri Mar 20 17:06:37 GMT 2026
    - 2.1K bytes
    - Click Count (0)
  8. docs_src/request_form_models/tutorial002_an_py310.py

    from typing import Annotated
    
    from fastapi import FastAPI, Form
    from pydantic import BaseModel
    
    app = FastAPI()
    
    
    class FormData(BaseModel):
        username: str
        password: str
        model_config = {"extra": "forbid"}
    
    
    @app.post("/login/")
    async def login(data: Annotated[FormData, Form()]):
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Thu Feb 12 13:19:43 GMT 2026
    - 307 bytes
    - Click Count (0)
  9. docs_src/cookie_param_models/tutorial002_py310.py

    from fastapi import Cookie, FastAPI
    from pydantic import BaseModel
    
    app = FastAPI()
    
    
    class Cookies(BaseModel):
        model_config = {"extra": "forbid"}
    
        session_id: str
        fatebook_tracker: str | None = None
        googall_tracker: str | None = None
    
    
    @app.get("/items/")
    async def read_items(cookies: Cookies = Cookie()):
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Tue Sep 17 18:54:10 GMT 2024
    - 343 bytes
    - Click Count (0)
  10. docs/zh/docs/tutorial/header-param-models.md

    您可以在文档 UI 的 `/docs` 中查看所需的 headers:
    
    <div class="screenshot">
    <img src="/img/tutorial/header-param-models/image01.png">
    </div>
    
    ## 禁止额外的 Headers { #forbid-extra-headers }
    
    在某些特殊使用情况下(可能并不常见),您可能希望**限制**您想要接收的 headers。
    
    您可以使用 Pydantic 的模型配置来禁止( `forbid` )任何额外( `extra` )字段:
    
    {* ../../docs_src/header_param_models/tutorial002_an_py310.py hl[10] *}
    
    如果客户尝试发送一些**额外的 headers**,他们将收到**错误**响应。
    
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Sun Feb 08 10:39:41 GMT 2026
    - 2.5K bytes
    - Click Count (0)
Back to Top