|
| 1 | +from flask import Flask |
| 2 | +from flask_apidoc import ApiDoc |
| 3 | + |
| 4 | +app = Flask(__name__) |
| 5 | +doc = ApiDoc(app=app) |
| 6 | + |
| 7 | + |
| 8 | +@app.route('/users', methods=['POST']) |
| 9 | +def add_user(): |
| 10 | + """ |
| 11 | + @api {post} /user Adds a new User |
| 12 | + @apiVersion 1.0.0 |
| 13 | + @apiName add_user |
| 14 | + @apiGroup User |
| 15 | +
|
| 16 | + @apiParam {String} username The user's username. |
| 17 | + @apiParam {String} first_name The first name of the User. |
| 18 | + @apiParam {String} last_name the last name of the User. |
| 19 | + @apiParam {Object} profile The profile data |
| 20 | + @apiParam {Number} profile.age The user's age. |
| 21 | + @apiParam {String} profile.image The user's avatar-image. |
| 22 | +
|
| 23 | + @apiSuccess {Number} id The new user id. |
| 24 | + """ |
| 25 | + return |
| 26 | + |
| 27 | + |
| 28 | +@app.route('/users/<id>') |
| 29 | +def get_user(id): |
| 30 | + """ |
| 31 | + @api {get} /users/:id Gets an user |
| 32 | + @apiVersion 1.0.0 |
| 33 | + @apiName get_user |
| 34 | + @apiGroup User |
| 35 | +
|
| 36 | + @apiDescription Gets an user for the given id. |
| 37 | +
|
| 38 | + @apiExample Example usage: |
| 39 | + curl -i http://localhost/users/4711 |
| 40 | +
|
| 41 | + @apiParam {Number} id The user's i |
| 42 | +
|
| 43 | + @apiSuccess {Number} id The user's id. |
| 44 | + @apiSuccess {String} username The user's username. |
| 45 | + @apiSuccess {String} first_name The first name of the User. |
| 46 | + @apiSuccess {String} last_name The last name of the User. |
| 47 | + @apiSuccess {Object} profile The profile data |
| 48 | + @apiSuccess {Number} profile.age The user's age. |
| 49 | + @apiSuccess {String} profile.image The user's avatar-image. |
| 50 | +
|
| 51 | + @apiError UserNotFound The <code>id</code> of the User was not found. |
| 52 | + """ |
| 53 | + return |
| 54 | + |
| 55 | + |
| 56 | +@app.route('/users') |
| 57 | +def get_users(): |
| 58 | + """ |
| 59 | + @api {get} /users/:id Gets all the users |
| 60 | + @apiVersion 1.0.0 |
| 61 | + @apiName get_users |
| 62 | + @apiGroup User |
| 63 | +
|
| 64 | + @apiExample Example usage: |
| 65 | + curl -i http://localhost/users |
| 66 | +
|
| 67 | + @apiSuccess {Object} users The user data |
| 68 | + @apiSuccess {Number} users.id The user's id. |
| 69 | + @apiSuccess {String} users.username The user's username. |
| 70 | + @apiSuccess {String} users.first_name The first name of the User. |
| 71 | + @apiSuccess {String} users.last_name The last name of the User. |
| 72 | + @apiSuccess {Object} users.profile The profile data |
| 73 | + @apiSuccess {Number} users.profile.age The user's age. |
| 74 | + @apiSuccess {String} users.profile.image The user's avatar-image. |
| 75 | + """ |
| 76 | + return |
| 77 | + |
| 78 | + |
| 79 | +@app.route('/users/<id>', methods=['POST']) |
| 80 | +def update_user(): |
| 81 | + """ |
| 82 | + @api {post} /users/:id Updates a user |
| 83 | + @apiVersion 1.0.0 |
| 84 | + @apiName update_user |
| 85 | + @apiGroup User |
| 86 | +
|
| 87 | + @apiParam {Number} id The user's id |
| 88 | + @apiParam {String} first_name The first name of the User. |
| 89 | + @apiParam {String} last_name The last name of the User. |
| 90 | + """ |
| 91 | + return |
0 commit comments