We are going to add REST API interface to our forum, and we decided to begin with creating endpoints without authentication. It won't be secure but it will make development process easier. We will add authentication to these endpoints in the future.
We need an endpoint which will return the list of registered users with abitily to sort results. Sorting will be specified via order_by query parameter. order_by should accept a string with two words separated by comma. First word is the name of the sorting field (only username is acceptable for now). Second word is the sorting direction (asc or desc).
So in the scope of this task we need to create an endpoint GET /api/users which will return list of users info in json format, or 400 if request is not valid.
To validate requests we are going to use reqparse from flask-restx.
We are going to add REST API interface to our forum, and we decided to begin with creating endpoints without authentication. It won't be secure but it will make development process easier. We will add authentication to these endpoints in the future.
We need an endpoint which will return the list of registered users with abitily to sort results. Sorting will be specified via
order_by
query parameter.order_by
should accept a string with two words separated by comma. First word is the name of the sorting field (onlyusername
is acceptable for now). Second word is the sorting direction (asc
ordesc
).Request example:
Response example:
So in the scope of this task we need to create an endpoint
GET /api/users
which will return list of users info in json format, or 400 if request is not valid.To validate requests we are going to use reqparse from flask-restx.