[FEATURE] parameter documentation
See original GitHub issueThe problem
I cannot add descriptions of parameters in OpenAPI documentation. (the specification by OpenAPI)
E.g.,
@app.get('/')
def get(param1: str, param2: int):
... do something
Here, there is no way to put descriptions of what param1 and param2 do.
Possible solutions
I can’t think of a clean solution. FastAPI is tightly using Python type check system for the documentation, which is a good thing, so we cannot easily add information to each parameter. Here are some possible solutions.
- Parse docstring and embed the corresponding contents to parameter description. For example
@app.get('/')
def get(param1: str, param2: int):
"""
- **param1**: param1 is doing the job1.
- **param2**: param2 is doing the job2.
"""
... do something
The descriptions could be added to the specification of the parameters.
- Use macro in comments. For example,
@app.get('/')
def get(param1: str, # %FASTAPI%param1 is doing the job1.
param2: int, # %FASTAPI%param2 is doing the job2.
):
... do something
- Based on @phy25’s comments, obviously
Field
could be supported at path, query and form parameters.
Please do let me know if I missed an existing feature for this. I am trying to switch from Flask to FastAPI for my basic web framework in Python, and most of the things look great so far. Thanks for the great project!
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:13 (2 by maintainers)
Top Results From Across the Web
Feature Parameter Metadata Types and Custom Objects
Feature parameters are represented as Metadata API types in your packaging org, as records of custom objects in your License Management Org, and...
Read more >Advanced Feature Parameters (DriveWorks Documentation)
To capture Advanced Feature Parameters a feature must already be captured (see Dimensions and Features):. Open the model which has the feature already...
Read more >How to document a method with parameter(s)? - Stack Overflow
To paraphrase an example from the Sphinx documentation as a Python snippet: ... formatted HTML docs for your parameters with their 'signatures' feature....
Read more >Model Rules Advanced Feature Parameter Rules - Overview
DriveWorks has the ability to drive advanced feature parameters of a large number of features. This topic outlines how to apply rules to...
Read more >Use JSDoc: @param
The @param tag provides the name, type, and description of a function parameter. The @param tag requires you to specify the name of...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Summary of the above discussion.
The solution to
when you have a query parameter like
is to do
and then change the above line to
Here is the relevant documentation.
Hi @phy25 When I use
It produces an error as
at
Would it be a bug?