コンテンツにスキップ
per page, with , order by , clip by
Results of 1 - 10 of about 29 for update (0.012 sec.)
Release Notes 12971
Release Notes Latest Changes 0.115.11 Fixes ? Add docs examples and tests (support) for Annotated custom validations, like AfterValidator , revert #13440 . PR #13442 by @tiangolo . New docs: Query Parameters and String Validations - Custom ... tion . Translations ? Add Russian translation for docs/ru/docs/tutorial/middleware.md . PR #13412 by @alv2017 . Internal ? Update FastAPI GitHub topic repositories. PR #13439 by @tiangolo . ? Update FastAPI People - Contributors and Translators. PR #13 ... 432 by @tiangolo . ? Update FastAPI People - Sponsors. PR #13433 by @tiangolo . 0.115.10 Fixes ♻️ Update internal annotation usage for compatibility w ... y tests for app_testing . PR #13220 by @alv2017 . ✅ Simplify tests for dependency_testing . PR #13223 by @alv2017 . Docs ? Update sponsors: CodeRabbit logo. PR #13424 by @tiangolo . ? Unify the badges across all tutorial translations. PR #13329 by @svl ...
https://man.mtool.work/fastapi/0.115/release-notes/
ボディ - 更新 11143
ボディ - 更新 PUT による置換での更新 項目を更新するには HTTPの PUT 操作を使用することができます。 jsonable_encoder を用いて、入力データをJSON形式で保存できるデータに変換することができます(例:NoSQLデータベース)。例えば、 datetime を str に ... ead_item ( item_id : str ): return items [ item_id ] @app . put ( "/items/ {item_id} " , response_model = Item ) async def update_item ( item_id : str , item : Item ): update_item_encoded = jsonable_encoder ( item ) items [ item_id ] = update_item_enco ... ded return update_item_encoded ? Other versions and variants Python 3.10+ Python 3.9+ from fastapi import FastAPI from fastapi.encoders impo ... ead_item ( item_id : str ): return items [ item_id ] @app . put ( "/items/ {item_id} " , response_model = Item ) async def update_item ( item_id : str , item : Item ): update_item_encoded = jsonable_encoder ( item ) items [ item_id ] = update_item_enco ...
https://man.mtool.work/fastapi/0.115/tutorial/body-updates/
依存関係としてのクラス 10801
依存関係としてのクラス 依存性注入 システムを深く掘り下げる前に、先ほどの例をアップグレードしてみましょう。 前の例の dict 前の例では、依存関係("dependable")から dict を返していました: Python 3.8+ - non-Annotated from typing import Union fr ... c def read_items ( commons : CommonQueryParams = Depends ( CommonQueryParams )): response = {} if commons . q : response . update ({ "q" : commons . q }) items = fake_items_db [ commons . skip : commons . skip + commons . limit ] response . update ({ " ... ems ( commons : Annotated [ CommonQueryParams , Depends ( CommonQueryParams )]): response = {} if commons . q : response . update ({ "q" : commons . q }) items = fake_items_db [ commons . skip : commons . skip + commons . limit ] response . update ({ " ... ems ( commons : Annotated [ CommonQueryParams , Depends ( CommonQueryParams )]): response = {} if commons . q : response . update ({ "q" : commons . q }) items = fake_items_db [ commons . skip : commons . skip + commons . limit ] response . update ({ " ...
https://man.mtool.work/fastapi/0.115/tutorial/dependencies/classes-as-dependenci...
ボディ - 複数のパラメータ 10735
ボディ - 複数のパラメータ これまで Path と Query をどう使うかを見てきましたが、リクエストボディの宣言のより高度な使い方を見てみましょう。 Path 、 Query とボディパラメータを混ぜる まず、もちろん、 Path と Query とリクエストボディのパラメータ ... nion [ str , None ] = None price : float tax : Union [ float , None ] = None @app . put ( "/items/ {item_id} " ) async def update_item ( * , item_id : int = Path ( title = "The ID of the item to get" , ge = 0 , le = 1000 ), q : Union [ str , None ] = N ... one , item : Union [ Item , None ] = None , ): results = { "item_id" : item_id } if q : results . update ({ "q" : q }) if item : results . update ({ "item" : item }) return results ? Other versions and variants Python 3.10+ Pyt ... 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 = "The ID of the item to get" , ge = 0 , le = 1000 )], q : str | None = No ...
https://man.mtool.work/fastapi/0.115/tutorial/body-multiple-params/
クエリパラメータと文字列の検証 10556
クエリパラメータと文字列の検証 FastAPI ではパラメータの追加情報とバリデーションを宣言することができます。 以下のアプリケーションを例にしてみましょう: Python 3.8+ from typing import Union from fastapi import FastAPI app = FastAPI () @app . g ... q : Union [ str , None ] = None ): results = { "items" : [{ "item_id" : "Foo" }, { "item_id" : "Bar" }]} if q : results . update ({ "q" : q }) return results ? Other versions and variants Python 3.10+ from fastapi import FastAPI app = FastAPI () @app ... ad_items ( q : str | None = None ): results = { "items" : [{ "item_id" : "Foo" }, { "item_id" : "Bar" }]} if q : results . update ({ "q" : q }) return results クエリパラメータ q は Optional[str] 型で、 None を許容する str 型を意味しており、デフォルトは ... efault = None , max_length = 50 )): results = { "items" : [{ "item_id" : "Foo" }, { "item_id" : "Bar" }]} if q : results . update ({ "q" : q }) return results ? Other versions and variants Python 3.10+ Python 3.8+ Python 3.10+ - non-Annotated from typi ...
https://man.mtool.work/fastapi/0.115/tutorial/query-params-str-validations/
パスパラメータと数値の検証 9985
パスパラメータと数値の検証 クエリパラメータに対して Query でより多くのバリデーションとメタデータを宣言できるのと同じように、パスパラメータに対しても Path で同じ種類のバリデーションとメタデータを宣言することができます。 Pathのインポート まず ... on [ str , None ] = Query ( default = None , alias = "item-query" ), ): results = { "item_id" : item_id } if q : results . update ({ "q" : q }) return results ? Other versions and variants Python 3.10+ Python 3.9+ Python 3.8+ Python 3.10+ - non-Annotat ... : Annotated [ str | None , Query ( alias = "item-query" )] = None , ): results = { "item_id" : item_id } if q : results . update ({ "q" : q }) return results from typing import Annotated , Union from fastapi import FastAPI , Path , Query app = FastAPI ... ted [ Union [ str , None ], Query ( alias = "item-query" )] = None , ): results = { "item_id" : item_id } if q : results . update ({ "q" : q }) return results from typing import Union from fastapi import FastAPI , Path , Query from typing_extensions im ...
https://man.mtool.work/fastapi/0.115/tutorial/path-params-numeric-validations/
ボディ - ネストされたモデル 9071
ボディ - ネストされたモデル FastAPI を使用すると、深くネストされた任意のモデルを定義、検証、文書化、使用することができます(Pydanticのおかげです)。 リストのフィールド 属性をサブタイプとして定義することができます。例えば、Pythonの list は以 ... ] = None price : float tax : Union [ float , None ] = None tags : list = [] @app . put ( "/items/ {item_id} " ) async def update_item ( item_id : int , item : Item ): results = { "item_id" : item_id , "item" : item } return results ? Other versions an ... : str | None = None price : float tax : float | None = None tags : list = [] @app . put ( "/items/ {item_id} " ) async def update_item ( item_id : int , item : Item ): results = { "item_id" : item_id , "item" : item } return results これにより、各項目の ... e price : float tax : Union [ float , None ] = None tags : List [ str ] = [] @app . put ( "/items/ {item_id} " ) async def update_item ( item_id : int , item : Item ): results = { "item_id" : item_id , "item" : item } return results ? Other versions an ...
https://man.mtool.work/fastapi/0.115/tutorial/body-nested-models/
ボディ - フィールド 8321
ボディ - フィールド Query や Path 、 Body を使って path operation関数 のパラメータに追加のバリデーションやメタデータを宣言するのと同じように、Pydanticの Field を使ってPydanticモデルの内部でバリデーションやメタデータを宣言することができます。 ... "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 = Body ( embed = True )): results = { "item_id" : item_id , "item" : item } return resu ... cription = "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 , Body ( embed = True )]): results = { "item_id" : item_id , "item" : item ... "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 : Annotated [ Item , Body ( embed = True )]): results = { "item_id" : item_id , "item" : item ...
https://man.mtool.work/fastapi/0.115/tutorial/body-fields/
スキーマの追加 - 例 8223
スキーマの追加 - 例 JSON Schemaに追加する情報を定義することができます。 一般的なユースケースはこのドキュメントで示されているように example を追加することです。 JSON Schemaの追加情報を宣言する方法はいくつかあります。 Pydanticの schema_extra ... "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 = { "item_id" : item_id , "item" : item } return results ? Other versions an ... "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 = { "item_id" : item_id , "item" : item } return results その追加情報はそのま ... tax : Union [ float , None ] = Field ( default = None , examples = [ 3.2 ]) @app . put ( "/items/ {item_id} " ) async def update_item ( item_id : int , item : Item ): results = { "item_id" : item_id , "item" : item } return results ? Other versions an ...
https://man.mtool.work/fastapi/0.115/tutorial/schema-extra-example/
SQL (Relational) Databases 8043
SQL (Relational) Databases Warning The current page still doesn't have a translation for this language. But you can help translating it: Contributing . FastAPI doesn't require you to use a SQL (relational) database. But you can use any data ... l see that FastAPI is using these models to document the API, and it will use them to serialize and validate the data too. Update the App with Multiple Models Now let's refactor this app a bit to increase security and versatility . If you check the pre ... rue ) secret_name : str class HeroPublic ( HeroBase ): id : int class HeroCreate ( HeroBase ): secret_name : str class HeroUpdate ( HeroBase ): name : str | None = None age : int | None = None secret_name : str | None = None sqlite_file_name = "databas ... e = 404 , detail = "Hero not found" ) return hero @app . patch ( "/heroes/ {hero_id} " , response_model = HeroPublic ) def update_hero ( hero_id : int , hero : HeroUpdate , session : SessionDep ): hero_db = session . get ( Hero , hero_id ) if not hero_ ...
https://man.mtool.work/fastapi/0.115/tutorial/sql-databases/
PREV 1 2 3 NEXT