Home / Function/ create_app() — fastapi Function Reference

create_app() — fastapi Function Reference

Architecture documentation for the create_app() function in test_schema_extra_examples.py from the fastapi codebase.

Entity Profile

Dependency Diagram

graph TD
  562dc8b3_7513_1235_4e0a_83c83e613a74["create_app()"]
  3fe4836c_ae70_fc66_8f09_91aac47b55e8["test_schema_extra_examples.py"]
  562dc8b3_7513_1235_4e0a_83c83e613a74 -->|defined in| 3fe4836c_ae70_fc66_8f09_91aac47b55e8
  cea1ac2f_5bc4_157f_9f19_0ba228bd5bc6["test_call_api()"]
  cea1ac2f_5bc4_157f_9f19_0ba228bd5bc6 -->|calls| 562dc8b3_7513_1235_4e0a_83c83e613a74
  b4c1b3db_c0b3_d44b_7817_a5d4c5e5d3c7["test_openapi_schema()"]
  b4c1b3db_c0b3_d44b_7817_a5d4c5e5d3c7 -->|calls| 562dc8b3_7513_1235_4e0a_83c83e613a74
  style 562dc8b3_7513_1235_4e0a_83c83e613a74 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

tests/test_schema_extra_examples.py lines 11–215

def create_app():
    app = FastAPI()

    class Item(BaseModel):
        data: str

        model_config = ConfigDict(
            json_schema_extra={"example": {"data": "Data in schema_extra"}}
        )

    @app.post("/schema_extra/")
    def schema_extra(item: Item):
        return item

    with pytest.warns(FastAPIDeprecationWarning):

        @app.post("/example/")
        def example(item: Item = Body(example={"data": "Data in Body example"})):
            return item

    @app.post("/examples/")
    def examples(
        item: Item = Body(
            examples=[
                {"data": "Data in Body examples, example1"},
                {"data": "Data in Body examples, example2"},
            ],
        ),
    ):
        return item

    with pytest.warns(FastAPIDeprecationWarning):

        @app.post("/example_examples/")
        def example_examples(
            item: Item = Body(
                example={"data": "Overridden example"},
                examples=[
                    {"data": "examples example_examples 1"},
                    {"data": "examples example_examples 2"},
                ],
            ),
        ):
            return item

    # TODO: enable these tests once/if Form(embed=False) is supported
    # TODO: In that case, define if File() should support example/examples too
    # @app.post("/form_example")
    # def form_example(firstname: str = Form(example="John")):
    #     return firstname

    # @app.post("/form_examples")
    # def form_examples(
    #     lastname: str = Form(
    #         ...,
    #         examples={
    #             "example1": {"summary": "last name summary", "value": "Doe"},
    #             "example2": {"value": "Doesn't"},
    #         },
    #     ),
    # ):
    #     return lastname

    # @app.post("/form_example_examples")
    # def form_example_examples(
    #     lastname: str = Form(
    #         ...,
    #         example="Doe overridden",
    #         examples={
    #             "example1": {"summary": "last name summary", "value": "Doe"},
    #             "example2": {"value": "Doesn't"},
    #         },
    #     ),
    # ):
    #     return lastname

    with pytest.warns(FastAPIDeprecationWarning):

        @app.get("/path_example/{item_id}")
        def path_example(
            item_id: str = Path(

Domain

Subdomains

Frequently Asked Questions

What does create_app() do?
create_app() is a function in the fastapi codebase, defined in tests/test_schema_extra_examples.py.
Where is create_app() defined?
create_app() is defined in tests/test_schema_extra_examples.py at line 11.
What calls create_app()?
create_app() is called by 2 function(s): test_call_api, test_openapi_schema.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free