コンテンツにスキップ
per page, with , order by , clip by
Results of 1 - 10 of about 11 for tax (0.004 sec.)
ボディ - 更新 10882
ボディ - 更新 PUT による置換での更新 項目を更新するには HTTPの PUT 操作を使用することができます。 jsonable_encoder を用いて、入力データをJSON形式で保存できるデータに変換することができます(例:NoSQLデータベース)。例えば、 datetime を str に ... odel ): name : Union [ str , None ] = None description : Union [ str , None ] = None price : Union [ float , None ] = None tax : float = 10.5 tags : List [ str ] = [] items = { "foo" : { "name" : "Foo" , "price" : 50.2 }, "bar" : { "name" : "Bar" , ... "description" : "The bartenders" , "price" : 62 , "tax" : 20.2 }, "baz" : { "name" : "Baz" , "description" : None , "price" : 50.2 , "tax" : 10.5 , "tags" : []}, } @app . get ( ... FastAPI () class Item ( BaseModel ): name : str | None = None description : str | None = None price : float | None = None tax : float = 10.5 tags : list [ str ] = [] items = { "foo" : { "name" : "Foo" , "price" : 50.2 }, "bar" : { "name" : "Bar" , ...
https://man.mtool.work/fastapi/0.115/tutorial/body-updates/
Path Operationの設定 10882
Path Operationの設定 path operationデコレータ を設定するためのパラメータがいくつかあります。 注意 これらのパラメータは path operation関数 ではなく、 path operationデコレータ に直接渡されることに注意してください。 レスポンスステータスコード ... rt BaseModel app = FastAPI () class Item ( BaseModel ): name : str description : Union [ str , None ] = None price : float tax : Union [ float , None ] = None tags : Set [ str ] = set () @app . post ( "/items/" , response_model = Item , status_code ... antic import BaseModel app = FastAPI () class Item ( BaseModel ): name : str description : str | None = None price : float tax : float | None = None tags : set [ str ] = set () @app . post ( "/items/" , response_model = Item , status_code = status . ... rt BaseModel app = FastAPI () class Item ( BaseModel ): name : str description : Union [ str , None ] = None price : float tax : Union [ float , None ] = None tags : set [ str ] = set () @app . post ( "/items/" , response_model = Item , status_code ...
https://man.mtool.work/fastapi/0.115/tutorial/path-operation-configuration/
レスポンスモデル 10829
レスポンスモデル path operations のいずれにおいても、 response_model パラメータを使用して、レスポンスのモデルを宣言することができます: @app.get() @app.post() @app.put() @app.delete() など。 Python 3.8+ from typing import Any , List , Union ... rt BaseModel app = FastAPI () class Item ( BaseModel ): name : str description : Union [ str , None ] = None price : float tax : Union [ float , None ] = None tags : List [ str ] = [] @app . post ( "/items/" , response_model = Item ) async def creat ... antic import BaseModel app = FastAPI () class Item ( BaseModel ): name : str description : str | None = None price : float tax : float | None = None tags : list [ str ] = [] @app . post ( "/items/" , response_model = Item ) async def create_item ( i ... rt BaseModel app = FastAPI () class Item ( BaseModel ): name : str description : Union [ str , None ] = None price : float tax : Union [ float , None ] = None tags : list [ str ] = [] @app . post ( "/items/" , response_model = Item ) async def creat ...
https://man.mtool.work/fastapi/0.115/tutorial/response-model/
リクエストボディ 9975
リクエストボディ クライアント (ブラウザなど) からAPIにデータを送信する必要があるとき、データを リクエストボディ (request body) として送ります。 リクエスト ボディはクライアントによってAPIへ送られます。 レスポンス ボディはAPIがクライアントに送 ... rom pydantic import BaseModel class Item ( BaseModel ): name : str description : Union [ str , None ] = None price : float tax : Union [ float , None ] = None app = FastAPI () @app . post ( "/items/" ) async def create_item ( item : Item ): return i ... FastAPI from pydantic import BaseModel class Item ( BaseModel ): name : str description : str | None = None price : float tax : float | None = None app = FastAPI () @app . post ( "/items/" ) async def create_item ( item : Item ): return item データ ... rom pydantic import BaseModel class Item ( BaseModel ): name : str description : Union [ str , None ] = None price : float tax : Union [ float , None ] = None app = FastAPI () @app . post ( "/items/" ) async def create_item ( item : Item ): return i ...
https://man.mtool.work/fastapi/0.115/tutorial/body/
ボディ - 複数のパラメータ 9584
ボディ - 複数のパラメータ これまで Path と Query をどう使うかを見てきましたが、リクエストボディの宣言のより高度な使い方を見てみましょう。 Path 、 Query とボディパラメータを混ぜる まず、もちろん、 Path と Query とリクエストボディのパラメータ ... rt BaseModel app = FastAPI () class Item ( BaseModel ): name : str description : Union [ str , None ] = None price : float tax : Union [ float , None ] = None @app . put ( "/items/ {item_id} " ) async def update_item ( * , item_id : int = Path ( tit ... antic import BaseModel app = FastAPI () class Item ( BaseModel ): name : str description : str | None = None price : float tax : float | None = None @app . put ( "/items/ {item_id} " ) async def update_item ( item_id : Annotated [ int , Path ( title ... rt BaseModel app = FastAPI () class Item ( BaseModel ): name : str description : Union [ str , None ] = None price : float tax : Union [ float , None ] = None @app . put ( "/items/ {item_id} " ) async def update_item ( item_id : Annotated [ int , Pa ...
https://man.mtool.work/fastapi/0.115/tutorial/body-multiple-params/
ボディ - ネストされたモデル 9424
ボディ - ネストされたモデル FastAPI を使用すると、深くネストされた任意のモデルを定義、検証、文書化、使用することができます(Pydanticのおかげです)。 リストのフィールド 属性をサブタイプとして定義することができます。例えば、Pythonの list は以 ... rt BaseModel app = FastAPI () class Item ( BaseModel ): name : str description : Union [ str , None ] = None price : float tax : Union [ float , None ] = None tags : list = [] @app . put ( "/items/ {item_id} " ) async def update_item ( item_id : int ... antic import BaseModel app = FastAPI () class Item ( BaseModel ): name : str description : str | None = None price : float tax : float | None = None tags : list = [] @app . put ( "/items/ {item_id} " ) async def update_item ( item_id : int , item : ... rt BaseModel app = FastAPI () class Item ( BaseModel ): name : str description : Union [ str , None ] = None price : float tax : Union [ float , None ] = None tags : List [ str ] = [] @app . put ( "/items/ {item_id} " ) async def update_item ( item_ ...
https://man.mtool.work/fastapi/0.115/tutorial/body-nested-models/
スキーマの追加 - 例 9228
スキーマの追加 - 例 JSON Schemaに追加する情報を定義することができます。 一般的なユースケースはこのドキュメントで示されているように example を追加することです。 JSON Schemaの追加情報を宣言する方法はいくつかあります。 Pydanticの schema_extra ... rt BaseModel app = FastAPI () class Item ( BaseModel ): name : str description : Union [ str , None ] = None price : float tax : Union [ float , None ] = None model_config = { "json_schema_extra" : { "examples" : [ { "name" : "Foo" , "description" : ... "A very nice Item" , "price" : 35.4 , "tax" : 3.2 , } ] } } @app . put ( "/items/ {item_id} " ) async def update_item ( item_id : int , item : Item ): results = { "i ... antic import BaseModel app = FastAPI () class Item ( BaseModel ): name : str description : str | None = None price : float tax : float | None = None model_config = { "json_schema_extra" : { "examples" : [ { "name" : "Foo" , "description" : "A very n ...
https://man.mtool.work/fastapi/0.115/tutorial/schema-extra-example/
ボディ - フィールド 7877
ボディ - フィールド Query や Path 、 Body を使って path operation関数 のパラメータに追加のバリデーションやメタデータを宣言するのと同じように、Pydanticの Field を使ってPydanticモデルの内部でバリデーションやメタデータを宣言することができます。 ... n of the item" , max_length = 300 ) price : float = Field ( gt = 0 , description = "The price must be greater than zero" ) tax : Union [ float , None ] = None @app . put ( "/items/ {item_id} " ) async def update_item ( item_id : int , item : Item = ... n of the item" , max_length = 300 ) price : float = Field ( gt = 0 , description = "The price must be greater than zero" ) tax : float | None = None @app . put ( "/items/ {item_id} " ) async def update_item ( item_id : int , item : Annotated [ Item ... n of the item" , max_length = 300 ) price : float = Field ( gt = 0 , description = "The price must be greater than zero" ) tax : Union [ float , None ] = None @app . put ( "/items/ {item_id} " ) async def update_item ( item_id : int , item : Annotat ...
https://man.mtool.work/fastapi/0.115/tutorial/body-fields/
Path Operationの高度な設定 6739
Path Operationの高度な設定 OpenAPI operationId 注意 あなたがOpenAPIの「エキスパート」でなければ、これは必要ないかもしれません。 path operation で operation_id パラメータを利用することで、OpenAPIの operationId を設定できます。 operation_id は ... rt BaseModel app = FastAPI () class Item ( BaseModel ): name : str description : Union [ str , None ] = None price : float tax : Union [ float , None ] = None tags : Set [ str ] = set () @app . post ( "/items/" , response_model = Item , summary = "C ... ll the information: - **name**: each item must have a name - **description**: a long description - **price**: required - **tax**: if the item doesn't have tax, you can omit this - **tags**: a set of unique tag strings for this item \f :param item: U ...
https://man.mtool.work/fastapi/0.115/advanced/path-operation-advanced-configurat...
Using Dataclasses 6383
Using Dataclasses Warning The current page still doesn't have a translation for this language. But you can help translating it: Contributing . FastAPI is built on top of Pydantic , and I have been showing you how to use Pydantic models to d ... ion from fastapi import FastAPI @dataclass class Item : name : str price : float description : Union [ str , None ] = None tax : Union [ float , None ] = None app = FastAPI () @app . post ( "/items/" ) async def create_item ( item : Item ): return i ... name : str price : float tags : List [ str ] = field ( default_factory = list ) description : Union [ str , None ] = None tax : Union [ float , None ] = None app = FastAPI () @app . get ( "/items/next" , response_model = Item ) async def read_next_ ...
https://man.mtool.work/fastapi/0.115/advanced/dataclasses/
PREV 1 2 NEXT