コード例 #1
0
def create_wishlist():

    """
    Creates a Wishlist object based on the JSON posted

    Will create a wishlist with an auto incremented id

    ---
    tags:
        - Wishlist
    parameters:
        - name: body
          in: body
          required: true
          schema:
            id: wishlist_entries
            required: true
                - customer_id
                - wishlist_name
            properties:
                customer_id:
                    type: integer
                    description: customer_id
                    default: "34"
                wishlist_name:
                    type: string
                    description: name of the wishlist 
                    default: "water Bottles"

    responses:
      201:
        description: Successfully Created wishlist

    """
    check_content_type('application/json')
    wishlist = Wishlist()
    json_post = request.get_json()
    wishlist.deserialize(json_post)
    wishlist.save()
    message = wishlist.serialize()

    location_url = url_for('get_wishlist', wishlist_id=wishlist.id, _external=True)
    return make_response(jsonify(message), status.HTTP_201_CREATED,
                         {
                            'Location': location_url
                         })