Skip to content

Add support for annotated_doc to document endpoint parameters #1603

@septatrix

Description

@septatrix

Is your feature request related to a problem? Please describe.
Currently django-ninja does not allow add docstring to each parameter. This, however, would be very useful if the name alone does not sufficiently explain the meaning or if there are additional things to watch out for.

Describe the solution you'd like
Doc from PEP 727 suggests adding a type which one can use together with Annotated to associate a docstring to a specific parameter. While the PEP was withdrawn due to concerns about verbosity and readability and reST (and others) already being established standards.

I (@tiangolo) originally wanted for this to be part of the Python standard library (in PEP 727), but the proposal was withdrawn as there was a fair amount of negative feedback and opposition.

The conclusion was that this was better done as an external effort, in a third-party library.

So, here it is, with a simpler approach, as a third-party library, in a way that can be used by others, starting with FastAPI and friends.

As you might know, tiangolo is the creator of FastAPI, and implemented Doc in a standalone lib as well as added support to FastAPI for it. It would be great if django-ninja would do the same, either by pulling in the same standalone lib, using typing_extensions.Doc though it might be deprecated and removed in the future, or simply reimplementing it (class Doc itself is just a few lines of code)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions