python-restx / flask-restx

Fork of Flask-RESTPlus: Fully featured framework for fast, easy and documented API development with Flask

Home Page:https://flask-restx.readthedocs.io/en/latest/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Please output the schema name that is giving error

Nafyaz opened this issue · comments

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'