sanic-org / sanic-openapi

Easily document your Sanic API with a UI
https://sanic-openapi.readthedocs.io/
MIT License
505 stars 108 forks source link

[Feature Request] Add ability to create descriptions for parameters #171

Closed AWegnerGitHub closed 4 years ago

AWegnerGitHub commented 4 years ago

Is your feature request related to a problem? Please describe your use case. Allow users a way to provide a description or prose for a parameter. Sometimes, a description is warranted for specific parameters and being able to add that would be helpful.

Describe the solution you'd like A way to add a description to a parameter.

Additional context image

Using this image from the docs as an example, I'd like to be able to describe to the user what X-API-VERSION means and possible values in the description column. Maybe some details about trade-offs between specific versions or information about when an older version will be sunset.

chenjr0719 commented 4 years ago

Hi @AWegnerGitHub, I think you can add description by:

from sanic import Sanic
from sanic_openapi import doc, swagger_blueprint

app = Sanic("test")
app.blueprint(swagger_blueprint)

@app.get("/")
@doc.consumes({"X-API-VERSION": doc.String("The version of API")}, location="header")
async def test(request):
    return {}

app.run()

And it will looks like:

image

Please have a try. 😃 And, I will close this issue first. If you have any questions, please feel free to reopen it.