示例#1
0
def create():
    """
    Create a new user
    ---
    parameters:
        - name: body
          in: body
          required: true
          schema:
            type: object
            properties:
                email:
                    type: string
                password:
                    type: string
                password_confirmation:
                    type: string
            required:
                - email
                - password
                - password_confirmation
    responses:
        201:
            description: User has been created
            schema:
                $ref: '#/definitions/User'
        422:
            description: Form Validation Error
            schema:
                type: string
                example: { "message": "A password is required"}
        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.create(input_data)
def createUser():
    return UserController.create()