Closed enricosecco closed 11 months ago
Hi,
flask-appbuilder ModelRestApi
uses Rison or JSON as query parameters:
use:
https://127.0.0.1/api/v1/naziopenapi/?q=(page:0,page_size:25)
docs: https://flask-appbuilder.readthedocs.io/en/latest/rest_api.html#lists-and-queries
Environment
Flask-Appbuilder version: 4.3.9
pip freeze output: apispec==6.3.0 attrs==23.1.0 Babel==2.13.1 blinker==1.7.0 certifi==2023.7.22 charset-normalizer==3.3.2 click==8.1.7 colorama==0.4.6 Deprecated==1.2.14 dnspython==2.4.2 email-validator==1.3.1 flask==2.3.3 Flask-AppBuilder==4.3.9 Flask-Babel==2.0.0 Flask-DebugToolbar==0.13.1 Flask-JWT-Extended==4.5.3 Flask-Limiter==3.5.0 Flask-Login==0.6.3 Flask-SQLAlchemy==2.5.1 flask-wtf==1.2.1 greenlet==3.0.1 idna==3.4 importlib-metadata==6.8.0 importlib-resources==6.1.1 itsdangerous==2.1.2 Jinja2==3.1.2 jsonschema==4.19.2 jsonschema-specifications==2023.7.1 limits==3.6.0 markdown-it-py==3.0.0 MarkupSafe==2.1.3 marshmallow==3.20.1 marshmallow-sqlalchemy==0.26.1 mdurl==0.1.2 ordered-set==4.1.0 packaging==23.2 pkgutil-resolve-name==1.3.10 prison==0.2.1 psycopg2==2.9.9 Pygments==2.16.1 PyJWT==2.8.0 pyodbc==5.0.1 python-dateutil==2.8.2 pytz==2023.3.post1 PyYAML==6.0.1 referencing==0.30.2 requests==2.31.0 rich==13.6.0 rpds-py==0.12.0 six==1.16.0 SQLAlchemy==1.4.50 SQLAlchemy-Utils==0.41.1 typing-extensions==4.8.0 urllib3==2.1.0 werkzeug==2.3.8 wrapt==1.16.0 wtforms==3.1.1 zipp==3.17.0
expected results
I need to retrive paginated data from api
In models.py I have:
In views.py I have:
Describe the actual results
When i GET http://127.0.0.1:8000/api/v1/nazioneapi/ I retrieve the first 20 records (there are 248 records in the table) but I am unable to retrieve the next pages. From the ModelRestApi code and from the swagger page it seems that the params (page and page_size) are necessary. But GET http://127.0.0.1:8000/api/v1/nazioneapi/?page=2&page_size=20 or GET http://127.0.0.1:8000/api/v1/nazioneapi/?page=2 or other tempatives retrieve always the first 20 records. I have already implemented a function to retrieve the complete list but I would like to be able to extract the data also by page