Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 85 for VALID (0.02 sec)

  1. tests/test_serialize_response_model.py

    
    class Item(BaseModel):
        name: str = Field(alias="aliased_name")
        price: Optional[float] = None
        owner_ids: Optional[list[int]] = None
    
    
    @app.get("/items/valid", response_model=Item)
    def get_valid():
        return Item(aliased_name="valid", price=1.0)
    
    
    @app.get("/items/coerce", response_model=Item)
    def get_coerce():
        return Item(aliased_name="coerce", price="1.0")
    
    
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Wed Dec 17 21:25:59 UTC 2025
    - 4.2K bytes
    - Viewed (0)
  2. tests/test_serialize_response.py

    app = FastAPI()
    
    
    class Item(BaseModel):
        name: str
        price: Optional[float] = None
        owner_ids: Optional[list[int]] = None
    
    
    @app.get("/items/valid", response_model=Item)
    def get_valid():
        return {"name": "valid", "price": 1.0}
    
    
    @app.get("/items/coerce", response_model=Item)
    def get_coerce():
        return {"name": "coerce", "price": "1.0"}
    
    
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Wed Dec 17 21:25:59 UTC 2025
    - 1.4K bytes
    - Viewed (0)
  3. tests/test_tutorial/test_body_nested_models/test_tutorial008.py

        data = [{"url": "not a valid url", "name": "Example"}]
        response = client.post("/images/multiple", json=data)
        assert response.status_code == 422, response.text
        assert response.json() == {
            "detail": [
                {
                    "loc": ["body", 0, "url"],
                    "input": "not a valid url",
                    "msg": "Input should be a valid URL, relative URL without a base",
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Fri Dec 26 10:43:02 UTC 2025
    - 5.4K bytes
    - Viewed (0)
  4. tests/test_serialize_response_dataclass.py

    app = FastAPI()
    
    
    @dataclass
    class Item:
        name: str
        date: datetime
        price: Optional[float] = None
        owner_ids: Optional[list[int]] = None
    
    
    @app.get("/items/valid", response_model=Item)
    def get_valid():
        return {"name": "valid", "date": datetime(2021, 7, 26), "price": 1.0}
    
    
    @app.get("/items/object", response_model=Item)
    def get_object():
        return Item(
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Wed Dec 17 21:25:59 UTC 2025
    - 4.9K bytes
    - Viewed (0)
  5. tests/test_path.py

        assert response.json() == {
            "detail": [
                {
                    "type": "int_parsing",
                    "loc": ["path", "item_id"],
                    "msg": "Input should be a valid integer, unable to parse string as an integer",
                    "input": "foobar",
                }
            ]
        }
    
    
    def test_path_int_True():
        response = client.get("/path/int/True")
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Sat Dec 27 18:19:10 UTC 2025
    - 20.5K bytes
    - Viewed (1)
  6. tests/test_tutorial/test_body/test_tutorial001.py

        assert response.json() == {
            "detail": [
                {
                    "type": "float_parsing",
                    "loc": ["body", "price"],
                    "msg": "Input should be a valid number, unable to parse string as a number",
                    "input": "twenty",
                }
            ]
        }
    
    
    def test_post_with_no_data(client: TestClient):
        response = client.post("/items/", json={})
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Sat Dec 27 18:19:10 UTC 2025
    - 10.6K bytes
    - Viewed (0)
  7. tests/test_query.py

        assert response.json() == {
            "detail": [
                {
                    "type": "int_parsing",
                    "loc": ["query", "query"],
                    "msg": "Input should be a valid integer, unable to parse string as an integer",
                    "input": "42.5",
                }
            ]
        }
    
    
    def test_query_int_query_baz():
        response = client.get("/query/int?query=baz")
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Sat Dec 27 18:19:10 UTC 2025
    - 7.4K bytes
    - Viewed (0)
  8. tests/test_tutorial/test_body_nested_models/test_tutorial005.py

                "price": 35.4,
                "image": {"url": "not a valid url", "name": "example image"},
            },
        )
        assert response.status_code == 422, response.text
        assert response.json() == {
            "detail": [
                {
                    "loc": ["body", "image", "url"],
                    "input": "not a valid url",
                    "msg": "Input should be a valid URL, relative URL without a base",
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Fri Dec 26 10:43:02 UTC 2025
    - 9.6K bytes
    - Viewed (0)
  9. tests/test_tutorial/test_query_params_str_validations/test_tutorial006c.py

        mod = importlib.import_module(
            f"docs_src.query_params_str_validations.{request.param}"
        )
        client = TestClient(mod.app)
        return client
    
    
    @pytest.mark.xfail(
        reason="Code example is not valid. See https://github.com/fastapi/fastapi/issues/12419"
    )
    def test_query_params_str_validations_no_query(client: TestClient):
        response = client.get("/items/")
        assert response.status_code == 200
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Fri Dec 26 10:43:02 UTC 2025
    - 5K bytes
    - Viewed (0)
  10. tests/test_multi_query_errors.py

                    "loc": ["query", "q", 0],
                    "msg": "Input should be a valid integer, unable to parse string as an integer",
                    "input": "five",
                },
                {
                    "type": "int_parsing",
                    "loc": ["query", "q", 1],
                    "msg": "Input should be a valid integer, unable to parse string as an integer",
                    "input": "six",
                },
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Sat Dec 27 18:19:10 UTC 2025
    - 3.9K bytes
    - Viewed (0)
Back to top