コンテンツにスキップ
per page, with , order by , clip by
Results of 1 - 10 of about 31 for BaseModel (0.007 sec.)
ボディ - ネストされたモデル 10499
ボディ - ネストされたモデル FastAPI を使用すると、深くネストされた任意のモデルを定義、検証、文書化、使用することができます(Pydanticのおかげです)。 リストのフィールド 属性をサブタイプとして定義することができます。例えば、Pythonの list は以 ... 下のように定義できます: Python 3.8+ from typing import Union from fastapi import FastAPI from pydantic import BaseModel app = FastAPI () class Item ( BaseModel ): name : str description : Union [ str , None ] = None price : float tax : Union ... "item" : item } return results ? Other versions and variants Python 3.10+ from fastapi import FastAPI from pydantic import BaseModel app = FastAPI () class Item ( BaseModel ): name : str description : str | None = None price : float tax : float | None = N ... ルから List をインポートします: Python 3.8+ from typing import List , Union from fastapi import FastAPI from pydantic import BaseModel app = FastAPI () class Item ( BaseModel ): name : str description : Union [ str , None ] = None price : float tax : Union ...
https://man.mtool.work/fastapi/0.115/tutorial/body-nested-models/
ボディ - 複数のパラメータ 10143
ボディ - 複数のパラメータ これまで Path と Query をどう使うかを見てきましたが、リクエストボディの宣言のより高度な使い方を見てみましょう。 Path 、 Query とボディパラメータを混ぜる まず、もちろん、 Path と Query とリクエストボディのパラメータ ... こともできます: Python 3.8+ - non-Annotated from typing import Union from fastapi import FastAPI , Path from pydantic import BaseModel app = FastAPI () class Item ( BaseModel ): name : str description : Union [ str , None ] = None price : float tax : Union ... hon 3.8+ Python 3.10+ - non-Annotated from typing import Annotated from fastapi import FastAPI , Path from pydantic import BaseModel app = FastAPI () class Item ( BaseModel ): name : str description : str | None = None price : float tax : float | None = N ... tem" : item }) return results from typing import Annotated , Union from fastapi import FastAPI , Path from pydantic import BaseModel app = FastAPI () class Item ( BaseModel ): name : str description : Union [ str , None ] = None price : float tax : Union ...
https://man.mtool.work/fastapi/0.115/tutorial/body-multiple-params/
レスポンスモデル 9852
レスポンスモデル path operations のいずれにおいても、 response_model パラメータを使用して、レスポンスのモデルを宣言することができます: @app.get() @app.post() @app.put() @app.delete() など。 Python 3.8+ from typing import Any , List , Union ... from fastapi import FastAPI from pydantic import BaseModel app = FastAPI () class Item ( BaseModel ): name : str description : Union [ str , None ] = None price : float tax : Union ... her versions and variants Python 3.10+ Python 3.9+ from typing import Any from fastapi import FastAPI from pydantic import BaseModel app = FastAPI () class Item ( BaseModel ): name : str description : str | None = None price : float tax : float | None = N ... { "name" : "Plumbus" , "price" : 32.0 }, ] from typing import Any , Union from fastapi import FastAPI from pydantic import BaseModel app = FastAPI () class Item ( BaseModel ): name : str description : Union [ str , None ] = None price : float tax : Union ...
https://man.mtool.work/fastapi/0.115/tutorial/response-model/
現在のユーザーの取得 9787
現在のユーザーの取得 一つ前の章では、(依存性注入システムに基づいた)セキュリティシステムは、 path operation関数 に str として token を与えていました: Python 3.8+ - non-Annotated from fastapi import Depends , FastAPI from fastapi.security i ... import Union from fastapi import Depends , FastAPI from fastapi.security import OAuth2PasswordBearer from pydantic import BaseModel app = FastAPI () oauth2_scheme = OAuth2PasswordBearer ( tokenUrl = "token" ) class User ( BaseModel ): username : str emai ... ort Annotated from fastapi import Depends , FastAPI from fastapi.security import OAuth2PasswordBearer from pydantic import BaseModel app = FastAPI () oauth2_scheme = OAuth2PasswordBearer ( tokenUrl = "token" ) class User ( BaseModel ): username : str emai ... tated , Union from fastapi import Depends , FastAPI from fastapi.security import OAuth2PasswordBearer from pydantic import BaseModel app = FastAPI () oauth2_scheme = OAuth2PasswordBearer ( tokenUrl = "token" ) class User ( BaseModel ): username : str emai ...
https://man.mtool.work/fastapi/0.115/tutorial/security/get-current-user/
OAuth2 scopes 9755
OAuth2 scopes Warning The current page still doesn't have a translation for this language. But you can help translating it: Contributing . You can use OAuth2 scopes directly with FastAPI , they are integrated to work seamlessly. This would ... urityScopes , ) from jwt.exceptions import InvalidTokenError from passlib.context import CryptContext from pydantic import BaseModel , ValidationError # to get a string like this run: # openssl rand -hex 32 SECRET_KEY = "09d25e094faa6ca2556c818166b7a9563b ... hashed_password" : "$2b$12$gSvqqUPvlXP2tfVFaWK1Be7DlH.PKZbv5H8KnzzVgXXbVxpva.pFm" , "disabled" : True , }, } class Token ( BaseModel ): access_token : str token_type : str class TokenData ( BaseModel ): username : str | None = None scopes : list [ str ] = ... [] class User ( BaseModel ): username : str email : str | None = None full_name : str | None = None disabled : bool | None = None class UserInDB ( U ...
https://man.mtool.work/fastapi/0.115/advanced/security/oauth2-scopes/
Separate OpenAPI Schemas for Input and Output or Not 9690
Separate OpenAPI Schemas for Input and Output or Not Warning The current page still doesn't have a translation for this language. But you can help translating it: Contributing . When using Pydantic v2 , the generated OpenAPI is a bit more e ... ou have a Pydantic model with default values, like this one: Python 3.10+ from fastapi import FastAPI from pydantic import BaseModel class Item ( BaseModel ): name : str description : str | None = None # Code below omitted ? ? Full file preview Python 3.1 ... 0+ from fastapi import FastAPI from pydantic import BaseModel class Item ( BaseModel ): name : str description : str | None = None app = FastAPI () @app . post ( "/items/" ) def create ... versions and variants Python 3.9+ Python 3.8+ from typing import Optional from fastapi import FastAPI from pydantic import BaseModel class Item ( BaseModel ): name : str description : Optional [ str ] = None app = FastAPI () @app . post ( "/items/" ) def ...
https://man.mtool.work/fastapi/0.115/how-to/separate-openapi-schemas/
Header Parameter Models 9690
Header Parameter Models Warning The current page still doesn't have a translation for this language. But you can help translating it: Contributing . If you have a group of related header parameters , you can create a Pydantic model to decla ... parameter as Header : Python 3.10+ from typing import Annotated from fastapi import FastAPI , Header from pydantic import BaseModel app = FastAPI () class CommonHeaders ( BaseModel ): host : str save_data : bool if_modified_since : str | None = None trac ... Python 3.8+ - non-Annotated from typing import Annotated , Union from fastapi import FastAPI , Header from pydantic import BaseModel app = FastAPI () class CommonHeaders ( BaseModel ): host : str save_data : bool if_modified_since : Union [ str , None ] = ... rs , Header ()]): return headers from typing import List , Union from fastapi import FastAPI , Header from pydantic import BaseModel from typing_extensions import Annotated app = FastAPI () class CommonHeaders ( BaseModel ): host : str save_data : bool if ...
https://man.mtool.work/fastapi/0.115/tutorial/header-param-models/
Path Operationの設定 9593
Path Operationの設定 path operationデコレータ を設定するためのパラメータがいくつかあります。 注意 これらのパラメータは path operation関数 ではなく、 path operationデコレータ に直接渡されることに注意してください。 レスポンスステータスコード ... 使用することができます: Python 3.8+ from typing import Set , Union from fastapi import FastAPI , status from pydantic import BaseModel app = FastAPI () class Item ( BaseModel ): name : str description : Union [ str , None ] = None price : float tax : Union ... turn item ? Other versions and variants Python 3.10+ Python 3.9+ from fastapi import FastAPI , status from pydantic import BaseModel app = FastAPI () class Item ( BaseModel ): name : str description : str | None = None price : float tax : float | None = N ... reate_item ( item : Item ): return item from typing import Union from fastapi import FastAPI , status from pydantic import BaseModel app = FastAPI () class Item ( BaseModel ): name : str description : Union [ str , None ] = None price : float tax : Union ...
https://man.mtool.work/fastapi/0.115/tutorial/path-operation-configuration/
パスワード(およびハッシュ化)によるOAuth2、JWTトークンによるBearer 9593
パスワード(およびハッシュ化)によるOAuth2、JWTトークンによるBearer これでセキュリティの流れが全てわかったので、 JWT トークンと安全なパスワードのハッシュ化を使用して、実際にアプリケーションを安全にしてみましょう。 このコードは、アプリケーシ ... wordRequestForm from jwt.exceptions import InvalidTokenError from passlib.context import CryptContext from pydantic import BaseModel # to get a string like this run: # openssl rand -hex 32 SECRET_KEY = "09d25e094faa6ca2556c818166b7a9563b93f7099f6f0f4caa6c ... hashed_password" : "$2b$12$EixZaYVK1fsbw1ZfbX3OXePaWxn96p36WQoeG6Lruj3vjPGga31lW" , "disabled" : False , } } class Token ( BaseModel ): access_token : str token_type : str class TokenData ( BaseModel ): username : Union [ str , None ] = None class User ( ... wordRequestForm from jwt.exceptions import InvalidTokenError from passlib.context import CryptContext from pydantic import BaseModel # to get a string like this run: # openssl rand -hex 32 SECRET_KEY = "09d25e094faa6ca2556c818166b7a9563b93f7099f6f0f4caa6c ...
https://man.mtool.work/fastapi/0.115/tutorial/security/oauth2-jwt/
クエリパラメータモデル 9399
クエリパラメータモデル もし関連する 複数のクエリパラメータ から成るグループがあるなら、それらを宣言するために、 Pydanticモデル を作成できます。 こうすることで、 複数の場所 で そのPydanticモデルを再利用 でき、バリデーションやメタデータを、す ... 宣言しましょう: Python 3.10+ from typing import Annotated , Literal from fastapi import FastAPI , Query from pydantic import BaseModel , Field app = FastAPI () class FilterParams ( BaseModel ): limit : int = Field ( 100 , gt = 0 , le = 100 ) offset : int = ... Annotated Python 3.9+ - non-Annotated Python 3.8+ - non-Annotated from fastapi import FastAPI , Query from pydantic import BaseModel , Field from typing_extensions import Annotated , Literal app = FastAPI () class FilterParams ( BaseModel ): limit : int = ... rParams , Query ()]): return filter_query from typing import List from fastapi import FastAPI , Query from pydantic import BaseModel , Field from typing_extensions import Annotated , Literal app = FastAPI () class FilterParams ( BaseModel ): limit : int = ...
https://man.mtool.work/fastapi/0.115/tutorial/query-param-models/
PREV 1 2 3 4 NEXT