Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 13 for something (0.31 sec)

  1. tests/test_custom_schema_fields.py

    class Item(BaseModel):
        name: str
    
        if PYDANTIC_V2:
            model_config = {
                "json_schema_extra": {
                    "x-something-internal": {"level": 4},
                }
            }
        else:
    
            class Config:
                schema_extra = {
                    "x-something-internal": {"level": 4},
                }
    
    
    @app.get("/foo", response_model=Item)
    def foo():
        return {"name": "Foo item"}
    
    
    Python
    - Registered: Sun Apr 21 07:19:11 GMT 2024
    - Last Modified: Fri Jul 07 17:12:13 GMT 2023
    - 1.2K bytes
    - Viewed (0)
  2. tests/test_repeated_dependency_schema.py

    app = FastAPI()
    
    
    def get_header(*, someheader: str = Header()):
        return someheader
    
    
    def get_something_else(*, someheader: str = Depends(get_header)):
        return f"{someheader}123"
    
    
    @app.get("/")
    def get_deps(dep1: str = Depends(get_header), dep2: str = Depends(get_something_else)):
        return {"dep1": dep1, "dep2": dep2}
    
    
    client = TestClient(app)
    
    schema = {
        "components": {
    Python
    - Registered: Sun Apr 21 07:19:11 GMT 2024
    - Last Modified: Fri Jun 30 18:25:16 GMT 2023
    - 3.2K bytes
    - Viewed (0)
  3. tests/test_tutorial/test_handling_errors/test_tutorial003.py

    
    def test_get_exception():
        response = client.get("/unicorns/yolo")
        assert response.status_code == 418, response.text
        assert response.json() == {
            "message": "Oops! yolo did something. There goes a rainbow..."
        }
    
    
    def test_openapi_schema():
        response = client.get("/openapi.json")
        assert response.status_code == 200, response.text
        assert response.json() == {
    Python
    - Registered: Sun Apr 21 07:19:11 GMT 2024
    - Last Modified: Fri Jun 30 18:25:16 GMT 2023
    - 3.2K bytes
    - Viewed (0)
  4. docs_src/handling_errors/tutorial003.py

    @app.exception_handler(UnicornException)
    async def unicorn_exception_handler(request: Request, exc: UnicornException):
        return JSONResponse(
            status_code=418,
            content={"message": f"Oops! {exc.name} did something. There goes a rainbow..."},
        )
    
    
    @app.get("/unicorns/{name}")
    async def read_unicorn(name: str):
        if name == "yolo":
            raise UnicornException(name=name)
    Python
    - Registered: Sun Apr 21 07:19:11 GMT 2024
    - Last Modified: Thu Mar 26 19:09:53 GMT 2020
    - 626 bytes
    - Viewed (0)
  5. ci/official/containers/linux_arm64/devel.usertools/squash_testlogs.py

          # Sharded tests have target names like this:
          # WindowOpsTest.test_tflite_convert0 (<function hann_window at
          #     0x7fc61728dd40>, 10, False, tf.float32)
          # Where 0x... is a thread ID (or something) that is not important for
          # debugging, but breaks this "number of failures" counter because it's
          # different for repetitions of the same test. We use re.sub(r"0x\w+")
          # to remove it.
    Python
    - Registered: Tue Apr 23 12:39:09 GMT 2024
    - Last Modified: Mon Sep 18 19:00:37 GMT 2023
    - 4.8K bytes
    - Viewed (0)
  6. fastapi/encoders.py

                and those objects can't (and shouldn't be) serialized to JSON.
                """
            ),
        ] = True,
    ) -> Any:
        """
        Convert any object to something that can be encoded in JSON.
    
        This is used internally by FastAPI to make sure anything you return can be
        encoded as JSON before it is sent to the client.
    
    Python
    - Registered: Sun Apr 21 07:19:11 GMT 2024
    - Last Modified: Thu Apr 18 21:56:59 GMT 2024
    - 10.8K bytes
    - Viewed (0)
  7. tests/test_tutorial/test_sql_databases/test_sql_databases_middleware.py

        assert "email" in data[0]
        assert "id" in data[0]
    
    
    # TODO: pv2 add Pydantic v2 version
    @needs_pydanticv1
    def test_create_item(client):
        item = {"title": "Foo", "description": "Something that fights"}
        response = client.post("/users/1/items/", json=item)
        assert response.status_code == 200, response.text
        item_data = response.json()
        assert item["title"] == item_data["title"]
    Python
    - Registered: Sun Apr 21 07:19:11 GMT 2024
    - Last Modified: Wed Mar 13 19:07:10 GMT 2024
    - 16.3K bytes
    - Viewed (0)
  8. tests/test_tutorial/test_sql_databases/test_sql_databases.py

        assert "email" in data[0]
        assert "id" in data[0]
    
    
    # TODO: pv2 add Pydantic v2 version
    @needs_pydanticv1
    def test_create_item(client):
        item = {"title": "Foo", "description": "Something that fights"}
        response = client.post("/users/1/items/", json=item)
        assert response.status_code == 200, response.text
        item_data = response.json()
        assert item["title"] == item_data["title"]
    Python
    - Registered: Sun Apr 21 07:19:11 GMT 2024
    - Last Modified: Wed Mar 13 19:07:10 GMT 2024
    - 16.1K bytes
    - Viewed (0)
  9. tests/test_tutorial/test_sql_databases/test_sql_databases_middleware_py310.py

        assert "email" in data[0]
        assert "id" in data[0]
    
    
    @needs_py310
    # TODO: pv2 add Pydantic v2 version
    @needs_pydanticv1
    def test_create_item(client):
        item = {"title": "Foo", "description": "Something that fights"}
        response = client.post("/users/1/items/", json=item)
        assert response.status_code == 200, response.text
        item_data = response.json()
        assert item["title"] == item_data["title"]
    Python
    - Registered: Sun Apr 21 07:19:11 GMT 2024
    - Last Modified: Wed Mar 13 19:07:10 GMT 2024
    - 16.5K bytes
    - Viewed (0)
  10. fastapi/applications.py

            async def unicorn_exception_handler(request: Request, exc: UnicornException):
                return JSONResponse(
                    status_code=418,
                    content={"message": f"Oops! {exc.name} did something. There goes a rainbow..."},
                )
            ```
            """
    
            def decorator(func: DecoratedCallable) -> DecoratedCallable:
                self.add_exception_handler(exc_class_or_status_code, func)
    Python
    - Registered: Sun Apr 21 07:19:11 GMT 2024
    - Last Modified: Tue Apr 02 02:48:51 GMT 2024
    - 172.2K bytes
    - Viewed (0)
Back to top