python-restx / flask-restx

Fork of Flask-RESTPlus: Fully featured framework for fast, easy and documented API development with Flask
https://flask-restx.readthedocs.io/en/latest/
Other
2.14k stars 333 forks source link

Added support for empty JSON arguments #520

Open axc450 opened 1 year ago

axc450 commented 1 year ago

Adds support for empty JSON body inputs in the generated Swagger documentation:

image

The code is essentially just ignoring any arguments with a None name, so if it is the sole argument you can have an empty input:

empty_json_parser = RequestParser()
empty_json_parser.add_argument(None, location="json")

If there is a better way to do this or it is already supported, please let me know!