コンテンツにスキップ
per page, with , order by , clip by
Results of 1 - 10 of about 32 for Description (0.003 sec.)
Separate OpenAPI Schemas for Input and Output or Not 11019
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 ... ike 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.10+ from fastapi import FastAPI from pydantic impo ... rt BaseModel class Item ( BaseModel ): name : str description : str | None = None app = FastAPI () @app . post ( "/items/" ) def create_item ( item : Item ): return item @app . get ( " ... /items/" ) def read_items () -> list [ Item ]: return [ Item ( name = "Portal Gun" , description = "Device to travel through the multi-rick-verse" , ), Item ( name = "Plumbus" ), ] ? Other versions and variants Python 3 ...
https://man.mtool.work/fastapi/0.115/how-to/separate-openapi-schemas/
Path Operationの設定 10938
Path Operationの設定 path operationデコレータ を設定するためのパラメータがいくつかあります。 注意 これらのパラメータは path operation関数 ではなく、 path operationデコレータ に直接渡されることに注意してください。 レスポンスステータスコード ... 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 [ float , None ] = None tags : Set [ str ] = set () @app . post ( ... 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 = None tags : set [ str ] = set () @app . post ( "/items/" , response ... 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 [ float , None ] = None tags : set [ str ] = set () @app . post ( ...
https://man.mtool.work/fastapi/0.115/tutorial/path-operation-configuration/
ボディ - フィールド 10761
ボディ - フィールド Query や Path 、 Body を使って path operation関数 のパラメータに追加のバリデーションやメタデータを宣言するのと同じように、Pydanticの Field を使ってPydanticモデルの内部でバリデーションやメタデータを宣言することができます。 ... fastapi import Body , FastAPI from pydantic import BaseModel , Field app = FastAPI () class Item ( BaseModel ): name : str description : Union [ str , None ] = Field ( default = None , title = "The description 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 de ... fastapi import Body , FastAPI from pydantic import BaseModel , Field app = FastAPI () class Item ( BaseModel ): name : str description : str | None = Field ( default = None , title = "The description of the item" , max_length = 300 ) price : float = Field ( ...
https://man.mtool.work/fastapi/0.115/tutorial/body-fields/
レスポンスモデル 10584
レスポンスモデル 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 [ float , None ] = None tags : List [ str ] = [] @app . post ( "/i ... mport 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 = None tags : list [ str ] = [] @app . post ( "/items/" , response_mo ... y , 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 [ float , None ] = None tags : list [ str ] = [] @app . post ( "/i ...
https://man.mtool.work/fastapi/0.115/tutorial/response-model/
テスト 10551
テスト Starlette のおかげで、 FastAPI アプリケーションのテストは簡単で楽しいものになっています。 HTTPX がベースなので、非常に使いやすく直感的です。 これを使用すると、 FastAPI と共に pytest を直接利用できます。 TestClient を使用 TestClient を ... from pydantic import BaseModel fake_secret_token = "coneofsilence" fake_db = { "foo" : { "id" : "foo" , "title" : "Foo" , "description" : "There goes my hero" }, "bar" : { "id" : "bar" , "title" : "Bar" , "description" : "The bartenders" }, } app = FastAPI ... () class Item ( BaseModel ): id : str title : str description : str | None = None @app . get ( "/items/ {item_id} " , response_model = Item ) async def read_main ( item_id : str , x_to ... from pydantic import BaseModel fake_secret_token = "coneofsilence" fake_db = { "foo" : { "id" : "foo" , "title" : "Foo" , "description" : "There goes my hero" }, "bar" : { "id" : "bar" , "title" : "Bar" , "description" : "The bartenders" }, } app = FastAPI ...
https://man.mtool.work/fastapi/0.115/tutorial/testing/
ボディ - 更新 10519
ボディ - 更新 PUT による置換での更新 項目を更新するには HTTPの PUT 操作を使用することができます。 jsonable_encoder を用いて、入力データをJSON形式で保存できるデータに変換することができます(例:NoSQLデータベース)。例えば、 datetime を str に ... nable_encoder from pydantic import BaseModel app = FastAPI () class Item ( BaseModel ): 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 , "t ... import jsonable_encoder from pydantic import BaseModel app = 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" : " ...
https://man.mtool.work/fastapi/0.115/tutorial/body-updates/
ボディ - ネストされたモデル 9601
ボディ - ネストされたモデル FastAPI を使用すると、深くネストされた任意のモデルを定義、検証、文書化、使用することができます(Pydanticのおかげです)。 リストのフィールド 属性をサブタイプとして定義することができます。例えば、Pythonの list は以 ... ort 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 [ float , None ] = None tags : list = [] @app . put ( "/items/ {it ... hon 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 = None tags : list = [] @app . put ( "/items/ {item_id} " ) async def ... t , 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 [ float , None ] = None tags : List [ str ] = [] @app . put ( "/it ...
https://man.mtool.work/fastapi/0.115/tutorial/body-nested-models/
ボディ - 複数のパラメータ 9392
ボディ - 複数のパラメータ これまで Path と Query をどう使うかを見てきましたが、リクエストボディの宣言のより高度な使い方を見てみましょう。 Path 、 Query とボディパラメータを混ぜる まず、もちろん、 Path と Query とリクエストボディのパラメータ ... on 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 [ float , None ] = None @app . put ( "/items/ {item_id} " ) async ... ed 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 = None @app . put ( "/items/ {item_id} " ) async def update_item ( it ... on 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 [ float , None ] = None @app . put ( "/items/ {item_id} " ) async ...
https://man.mtool.work/fastapi/0.115/tutorial/body-multiple-params/
スキーマの追加 - 例 9085
スキーマの追加 - 例 JSON Schemaに追加する情報を定義することができます。 一般的なユースケースはこのドキュメントで示されているように example を追加することです。 JSON Schemaの追加情報を宣言する方法はいくつかあります。 Pydanticの schema_extra ... ort 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 [ 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 ( ... hon 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 = None model_config = { "json_schema_extra" : { "examples" : [ { "nam ...
https://man.mtool.work/fastapi/0.115/tutorial/schema-extra-example/
Extending OpenAPI 8667
Extending OpenAPI Warning The current page still doesn't have a translation for this language. But you can help translating it: Contributing . There are some cases where you might need to modify the generated OpenAPI schema. In this section ... ion : The version of the OpenAPI specification used. By default, the latest: 3.1.0 . summary : A short summary of the API. description : The description of your API, this can include markdown and will be shown in the docs. routes : A list of routes, these a ... api_schema = get_openapi ( title = "Custom title" , version = "2.5.0" , summary = "This is a very custom OpenAPI schema" , description = "Here's a longer description of the custom **OpenAPI** schema" , routes = app . routes , ) openapi_schema [ "info" ][ "x ... api_schema = get_openapi ( title = "Custom title" , version = "2.5.0" , summary = "This is a very custom OpenAPI schema" , description = "Here's a longer description of the custom **OpenAPI** schema" , routes = app . routes , ) openapi_schema [ "info" ][ "x ...
https://man.mtool.work/fastapi/0.115/how-to/extending-openapi/
PREV 1 2 3 4 NEXT