Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 223 for pass (0.21 sec)

  1. tests/test_response_model_invalid.py

    import pytest
    from fastapi import FastAPI
    from fastapi.exceptions import FastAPIError
    
    
    class NonPydanticModel:
        pass
    
    
    def test_invalid_response_model_raises():
        with pytest.raises(FastAPIError):
            app = FastAPI()
    
            @app.get("/", response_model=NonPydanticModel)
            def read_root():
                pass  # pragma: nocover
    
    
    def test_invalid_response_model_sub_type_raises():
        with pytest.raises(FastAPIError):
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Sat Feb 29 13:04:35 GMT 2020
    - 1.1K bytes
    - Viewed (0)
  2. tests/test_ambiguous_params.py

                pass  # pragma: nocover
    
        with pytest.raises(
            AssertionError,
            match=(
                "`Query` default value cannot be set in `Annotated` for 'item_id'. Set the"
                " default value with `=` instead."
            ),
        ):
    
            @app.get("/")
            async def get(item_id: Annotated[int, Query(default=1)]):
                pass  # pragma: nocover
    
    
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Tue Dec 12 00:22:47 GMT 2023
    - 2.1K bytes
    - Viewed (0)
  3. docs/en/docs/how-to/configure-swagger-ui.md

    # Configure Swagger UI
    
    You can configure some extra <a href="https://swagger.io/docs/open-source-tools/swagger-ui/usage/configuration" class="external-link" target="_blank">Swagger UI parameters</a>.
    
    To configure them, pass the `swagger_ui_parameters` argument when creating the `FastAPI()` app object or to the `get_swagger_ui_html()` function.
    
    `swagger_ui_parameters` receives a dictionary with the configurations passed to Swagger UI directly.
    
    Plain Text
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Thu Apr 18 19:53:19 GMT 2024
    - 2.8K bytes
    - Viewed (0)
  4. docs_src/sql_databases/sql_app/schemas.py

    from typing import List, Union
    
    from pydantic import BaseModel
    
    
    class ItemBase(BaseModel):
        title: str
        description: Union[str, None] = None
    
    
    class ItemCreate(ItemBase):
        pass
    
    
    class Item(ItemBase):
        id: int
        owner_id: int
    
        class Config:
            orm_mode = True
    
    
    class UserBase(BaseModel):
        email: str
    
    
    class UserCreate(UserBase):
        password: str
    
    
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Sat May 14 11:59:59 GMT 2022
    - 502 bytes
    - Viewed (0)
  5. docs_src/dependencies/tutorial008c_an_py39.py

    from typing import Annotated
    
    from fastapi import Depends, FastAPI, HTTPException
    
    app = FastAPI()
    
    
    class InternalError(Exception):
        pass
    
    
    def get_username():
        try:
            yield "Rick"
        except InternalError:
            print("Oops, we didn't raise again, Britney 😱")
    
    
    @app.get("/items/{item_id}")
    def get_item(item_id: str, username: Annotated[str, Depends(get_username)]):
        if item_id == "portal-gun":
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Sat Feb 24 23:06:37 GMT 2024
    - 700 bytes
    - Viewed (0)
  6. tests/test_jsonable_encoder.py

            def serialize_dt_field(self, dt):
                return dt.replace(microsecond=0, tzinfo=timezone.utc).isoformat()
    
        class ModelWithCustomEncoderSubclass(ModelWithCustomEncoder):
            pass
    
        model = ModelWithCustomEncoder(dt_field=datetime(2019, 1, 1, 8))
        assert jsonable_encoder(model) == {"dt_field": "2019-01-01T08:00:00+00:00"}
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Thu Apr 18 21:56:59 GMT 2024
    - 9K bytes
    - Viewed (0)
  7. docs/en/docs/advanced/events.md

    In our code example above, we don't use it directly, but we pass it to FastAPI for it to use it.
    
    The `lifespan` parameter of the `FastAPI` app takes an **async context manager**, so we can pass our new `lifespan` async context manager to it.
    
    ```Python hl_lines="22"
    {!../../../docs_src/events/tutorial003.py!}
    ```
    
    Plain Text
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Thu Apr 18 19:53:19 GMT 2024
    - 7.8K bytes
    - Viewed (0)
  8. docs/en/docs/how-to/custom-docs-ui-assets.md

    ```
    
    ### Include the custom docs
    
    Now you can create the *path operations* for the custom docs.
    
    You can re-use FastAPI's internal functions to create the HTML pages for the docs, and pass them the needed arguments:
    
    * `openapi_url`: the URL where the HTML page for the docs can get the OpenAPI schema for your API. You can use here the attribute `app.openapi_url`.
    * `title`: the title of your API.
    Plain Text
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Mon Oct 30 09:58:58 GMT 2023
    - 7.5K bytes
    - Viewed (0)
  9. docs/en/docs/tutorial/handling-errors.md

    ```JSON
    {
      "detail": "Item not found"
    }
    ```
    
    !!! tip
        When raising an `HTTPException`, you can pass any value that can be converted to JSON as the parameter `detail`, not only `str`.
    
        You could pass a `dict`, a `list`, etc.
    
        They are handled automatically by **FastAPI** and converted to JSON.
    
    ## Add custom headers
    
    Plain Text
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Fri Mar 22 01:42:11 GMT 2024
    - 9.1K bytes
    - Viewed (0)
  10. docs/en/docs/advanced/templates.md

    * Create a `templates` object that you can re-use later.
    * Declare a `Request` parameter in the *path operation* that will return a template.
    * Use the `templates` you created to render and return a `TemplateResponse`, pass the name of the template, the request object, and a "context" dictionary with key-value pairs to be used inside of the Jinja2 template.
    
    ```Python hl_lines="4  11  15-18"
    {!../../../docs_src/templates/tutorial001.py!}
    ```
    
    Plain Text
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Thu Jan 11 22:25:37 GMT 2024
    - 3.2K bytes
    - Viewed (0)
Back to top