flask-restx
flask-restx copied to clipboard
How to set the ENUM path parameters for swagger.
Ask a question Currently im trying to set and path parameters and want to enum in swagger api docs. But i'm not able to find any clear documentation for that.
Hello!
To define a "list of possible values" for a parameter in swagger you must inform the list of values through the "choices" attribute in the model, for example:
post_model = reqparse.RequestParser()
post_model.add_argument(
'format',
required=True,
location="args",
type=str,
choices=["csv", "xlsx", "txt"],
help="Formato do arquivo."
)
In the swagger it will be displayed:
