def usersDetail(id): if request.method == "GET": return UserController.show(id) elif request.method == "PUT": return UserController.update(id) elif request.method == "DELETE": return UserController.delete(id)
def update(model_id): """ Update an existing User --- parameters: - name: model_id in: path description: The ID of the user required: true type: string - name: body in: body required: true schema: type: object properties: email: type: string password: type: string password_confirmation: type: string required: - email responses: 200: description: User has been updated schema: $ref: '#/definitions/User' 404: description: User could not be found schema: type: string example: { "message": "User could not be found"} 422: description: Form Validation Error schema: type: string example: { "message": "password and confirmation are not the same"} 400: description: Bad Request schema: type: string example: { "message": "Request data must be a JSON object"} """ try: input_data = request.get_json(force=True) except Exception as error: return jsonify({"error": "Request data must be a JSON object"}), 400 if not isinstance(input_data, dict): return jsonify({"error": "Request data must be a JSON object"}), 400 return UserController.update(model_id, input_data)