Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 1 of 1 for Products (0.14 sec)

  1. tests/test_get_request_body.py

    from fastapi import FastAPI
    from fastapi.testclient import TestClient
    from pydantic import BaseModel
    
    app = FastAPI()
    
    
    class Product(BaseModel):
        name: str
        description: str = None  # type: ignore
        price: float
    
    
    @app.get("/product")
    async def create_item(product: Product):
        return product
    
    
    client = TestClient(app)
    
    
    def test_get_with_body():
    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)
Back to top