Пример #1
0
def add_student(body):  # noqa: E501
    """Add a new student
     # noqa: E501
    :param body: Student object that needs to be added
    :type body: dict | bytes
    :rtype: str
    """
    if connexion.request.is_json:
        body = Student.from_dict(connexion.request.get_json())  # noqa: E501
    return student_service.add_student(body)
Пример #2
0
def add_student(body):  # noqa: E501
    """Add a new student

     # noqa: E501

    :param body: Student object that needs to be added
    :type body: dict | bytes

    :rtype: str
    """
    if connexion.request.is_json:
        body = Student.from_dict(connexion.request.get_json())  # noqa: E501
        if not body or not body.last_name or not body.first_name:
            return 'Invalid input', 405
    return student_service.add_student(body)
Пример #3
0
def add_student(body):  # noqa: E501
    """Add a new student

     # noqa: E501

    :param body: Student object that needs to be added
    :type body: dict | bytes

    :rtype: str
    """
    if connexion.request.is_json:
        body = Student.from_dict(connexion.request.get_json())  # noqa: E501
        return student_service.add_student(body)
    else:
        return "Your request must include JSON, with at least one of the following: 'first_name', 'last_name'", 200
def add_student(body):  # noqa: E501
    """Add a new student

     # noqa: E501

    :param body: Student object that needs to be added
    :type body: dict | bytes

    :rtype: str
    """
    if connexion.request.is_json:
        try:
            body = Student.from_dict(
                connexion.request.get_json())  # noqa: E501
        except ValueError:
            return 'Invalid Input', 405
    return student_service.add_student(body)
Пример #5
0
def add_student(body):  # noqa: E501
    """Add a new student

     # noqa: E501

    :param body: Student object that needs to be added
    :type body: dict | bytes

    :rtype: int
    """
    if connexion.request.is_json:
        body = Student.from_dict(connexion.request.get_json())  # noqa: E501
        # print('default controller body', body)
        if (not body.first_name) or (not body.last_name):
            return "Not content", 405
    # return 'do some magic!'
    return student_service.add_student(body)