Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 7 of 7 for age (0.23 sec)

  1. tests/test_union_inherited_body.py

    class Item(BaseModel):
        name: Optional[str] = None
    
    
    class ExtendedItem(Item):
        age: int
    
    
    @app.post("/items/")
    def save_union_different_body(item: Union[ExtendedItem, Item]):
        return {"item": item}
    
    
    client = TestClient(app)
    
    
    def test_post_extended_item():
        response = client.post("/items/", json={"name": "Foo", "age": 5})
        assert response.status_code == 200, response.text
    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)
  2. docs_src/graphql/tutorial001.py

    import strawberry
    from fastapi import FastAPI
    from strawberry.asgi import GraphQL
    
    
    @strawberry.type
    class User:
        name: str
        age: int
    
    
    @strawberry.type
    class Query:
        @strawberry.field
        def user(self) -> User:
            return User(name="Patrick", age=100)
    
    
    schema = strawberry.Schema(query=Query)
    
    
    graphql_app = GraphQL(schema)
    
    app = FastAPI()
    app.add_route("/graphql", graphql_app)
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Sun Oct 03 18:00:28 GMT 2021
    - 446 bytes
    - Viewed (0)
  3. tests/test_response_model_include_exclude.py

    from pydantic import BaseModel
    
    
    class Model1(BaseModel):
        foo: str
        bar: str
    
    
    class Model2(BaseModel):
        ref: Model1
        baz: str
    
    
    class Model3(BaseModel):
        name: str
        age: int
        ref2: Model2
    
    
    app = FastAPI()
    
    
    @app.get(
        "/simple_include",
        response_model=Model2,
        response_model_include={"baz": ..., "ref": {"foo"}},
    )
    def simple_include():
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Mon Jul 19 19:14:58 GMT 2021
    - 4K bytes
    - Viewed (0)
  4. docs_src/python_types/tutorial003.py

    def get_name_with_age(name: str, age: int):
        name_with_age = name + " is this old: " + age
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Thu Mar 26 19:09:53 GMT 2020
    - 119 bytes
    - Viewed (0)
  5. tests/test_multi_body_errors.py

                        "loc": ["body", 0, "age"],
                        "msg": "ensure this value is greater than 0",
                        "type": "value_error.number.not_gt",
                    }
                ]
            }
        )
    
    
    def test_put_incorrect_body_multiple():
        response = client.post("/items/", json=[{"age": "five"}, {"age": "six"}])
        assert response.status_code == 422, response.text
    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)
  6. docs_src/python_types/tutorial004.py

    def get_name_with_age(name: str, age: int):
        name_with_age = name + " is this old: " + str(age)
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Thu Mar 26 19:09:53 GMT 2020
    - 124 bytes
    - Viewed (0)
  7. docs_src/python_types/tutorial012.py

    from typing import Optional
    
    from pydantic import BaseModel
    
    
    class User(BaseModel):
        name: str
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Sat May 14 11:59:59 GMT 2022
    - 122 bytes
    - Viewed (0)
Back to top