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.16k stars 334 forks source link

Please output the schema name that is giving error #605

Open Nafyaz opened 4 months ago

Nafyaz commented 4 months ago

I got Unable to render schema and I had to tweak the library code to find out which of my 20+ schemas is causing the problem. By tweaking, I mean just printing out schemas in swagger.py's serialize_definitions(self) to until I receive an error. It would be less frustrating if the library directly told the name of my schema.

Here is the full traceback:

Unable to render schema
Traceback (most recent call last):
  File "/home/ve/lib/python3.12/site-packages/flask_restx/api.py", line 571, in __schema__
    self._schema = Swagger(self).as_dict()
                   ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ve/lib/python3.12/site-packages/flask_restx/swagger.py", line 304, in as_dict
    "definitions": self.serialize_definitions() or None,
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ve/lib/python3.12/site-packages/flask_restx/swagger.py", line 661, in serialize_definitions
    print(model.__schema__)
          ^^^^^^^^^^^^^^^^
  File "/home/ve/lib/python3.12/site-packages/flask_restx/model.py", line 68, in __schema__
    schema = self._schema
             ^^^^^^^^^^^^
  File "/home/ve/lib/python3.12/site-packages/flask_restx/model.py", line 151, in _schema
    properties[name] = field.__schema__
                       ^^^^^^^^^^^^^^^^
  File "/home/ve/lib/python3.12/site-packages/werkzeug/utils.py", line 107, in __get__
    value = self.fget(obj)  # type: ignore
            ^^^^^^^^^^^^^^
  File "/home/ve/lib/python3.12/site-packages/flask_restx/fields.py", line 217, in __schema__
    return not_none(self.schema())
                    ^^^^^^^^^^^^^
  File "/home/ve/lib/python3.12/site-packages/flask_restx/fields.py", line 442, in schema
    enum = self._v("enum")
           ^^^^^^^^^^^^^^^
  File "/home/ve/lib/python3.12/site-packages/flask_restx/fields.py", line 213, in _v
    return value() if callable(value) else value
           ^^^^^^^
TypeError: EnumType.__call__() missing 1 required positional argument: 'value'