[Python] How to tell FastAPI to get the descriptions from the docstring

Discussão em 'Python' iniciado por Stack, Julho 21, 2025.

  1. Stack

    Stack Membro Participativo

    I want FastAPI to use my docstring. Is it possible?

    This is my code

    app = FastAPI()

    @app.get("/App/test2", tags=['App'])
    async def test2(name: str):
    """
    This API returns a simple message.
    :param str name: The name of the person to greet.
    """
    return {"message": "Hello " + name}


    And this is the swagger page.

    [​IMG]

    and I would prefer to put the "The name of the person to greet." at the bottom, next to the name.

    Continue reading...

Compartilhe esta Página