Search Options

Results per page
Sort
Preferred Languages
Advance

Results 41 - 50 of 1,063 for body (0.15 sec)

  1. docs/ja/docs/tutorial/body-multiple-params.md

    ## ボディ内の単数値
    
    クエリとパスパラメータの追加データを定義するための `Query` と `Path` があるのと同じように、 **FastAPI** は同等の `Body` を提供します。
    
    例えば、前のモデルを拡張して、同じボディに `item` と `user` の他にもう一つのキー `importance` を入れたいと決めることができます。
    
    単数値なのでそのまま宣言すると、**FastAPI** はそれがクエリパラメータであるとみなします。
    
    しかし、`Body`を使用して、**FastAPI** に別のボディキーとして扱うように指示することができます:
    
    
    ```Python hl_lines="23"
    {!../../../docs_src/body_multiple_params/tutorial003.py!}
    ```
    
    この場合、**FastAPI** は以下のようなボディを期待します:
    
    
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Mon Jan 15 15:48:41 GMT 2024
    - 5.8K bytes
    - Viewed (0)
  2. tests/test_union_body.py

                                        }
                                    }
                                },
                            },
                        },
                        "summary": "Save Union Body",
                        "operationId": "save_union_body_items__post",
                        "requestBody": {
                            "content": {
                                "application/json": {
                                    "schema": {
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Fri Jul 07 17:12:13 GMT 2023
    - 4.6K bytes
    - Viewed (0)
  3. tests/test_multi_body_errors.py

    app = FastAPI()
    
    
    class Item(BaseModel):
        name: str
        age: condecimal(gt=Decimal(0.0))  # type: ignore
    
    
    @app.post("/items/")
    def save_item_no_body(item: List[Item]):
        return {"item": item}
    
    
    client = TestClient(app)
    
    
    def test_put_correct_body():
        response = client.post("/items/", json=[{"name": "Foo", "age": 5}])
        assert response.status_code == 200, response.text
        assert response.json() == {
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Thu Apr 18 19:40:57 GMT 2024
    - 7.6K bytes
    - Viewed (0)
  4. tests/test_regex_deprecated_body.py

                                                {
                                                    "$ref": "#/components/schemas/Body_read_items_items__post"
                                                }
                                            ],
                                            "title": "Body",
                                        }
                                    )
                                    | IsDict(
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Thu Apr 18 19:40:57 GMT 2024
    - 6.2K bytes
    - Viewed (0)
  5. tests/test_get_request_body.py

    @app.get("/product")
    async def create_item(product: Product):
        return product
    
    
    client = TestClient(app)
    
    
    def test_get_with_body():
        body = {"name": "Foo", "description": "Some description", "price": 5.5}
        response = client.request("GET", "/product", json=body)
        assert response.json() == body
    
    
    def test_openapi_schema():
        response = client.get("/openapi.json")
        assert response.status_code == 200, response.text
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Fri Jun 30 18:25:16 GMT 2023
    - 3.7K bytes
    - Viewed (0)
  6. tests/test_put_no_body.py

    app = FastAPI()
    
    
    @app.put("/items/{item_id}")
    def save_item_no_body(item_id: str):
        return {"item_id": item_id}
    
    
    client = TestClient(app)
    
    
    def test_put_no_body():
        response = client.put("/items/foo")
        assert response.status_code == 200, response.text
        assert response.json() == {"item_id": "foo"}
    
    
    def test_put_no_body_with_body():
        response = client.put("/items/foo", json={"name": "Foo"})
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Fri Jun 30 18:25:16 GMT 2023
    - 3.3K bytes
    - Viewed (0)
  7. tests/test_union_inherited_body.py

                                    }
                                },
                            },
                        },
                        "summary": "Save Union Different Body",
                        "operationId": "save_union_different_body_items__post",
                        "requestBody": {
                            "content": {
                                "application/json": {
                                    "schema": {
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Fri Jul 07 17:12:13 GMT 2023
    - 5.2K bytes
    - Viewed (0)
  8. tests/test_request_body_parameters_media_type.py

    async def create_product(data: Product = Body(media_type=media_type, embed=True)):
        pass  # pragma: no cover
    
    
    @app.post("/shops")
    async def create_shop(
        data: Shop = Body(media_type=media_type),
        included: typing.List[Product] = Body(default=[], media_type=media_type),
    ):
        pass  # pragma: no cover
    
    
    client = TestClient(app)
    
    
    def test_openapi_schema():
        response = client.get("/openapi.json")
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Fri Jul 07 17:12:13 GMT 2023
    - 6.4K bytes
    - Viewed (0)
  9. tests/test_response_code_no_body.py

    Sebastián Ramírez <******@****.***> 1688149516 +0200
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Fri Jun 30 18:25:16 GMT 2023
    - 3.2K bytes
    - Viewed (0)
  10. okhttp/src/test/java/okhttp3/ResponseBodyJvmTest.kt

    class ResponseBodyJvmTest {
      @Test
      fun stringEmpty() {
        val body = body("")
        assertThat(body.string()).isEqualTo("")
      }
    
      @Test
      fun stringLooksLikeBomButTooShort() {
        val body = body("000048")
        assertThat(body.string()).isEqualTo("\u0000\u0000H")
      }
    
      @Test
      fun stringDefaultsToUtf8() {
        val body = body("68656c6c6f")
        assertThat(body.string()).isEqualTo("hello")
      }
    
      @Test
    Plain Text
    - Registered: Fri May 03 11:42:14 GMT 2024
    - Last Modified: Mon Jan 08 01:13:22 GMT 2024
    - 13K bytes
    - Viewed (0)
Back to top