Beispiel #1
0
from apps.api import ns_posts as ns, api
from apps.database import db
from .models import Post

post_parser = api.parser()
post_parser.add_argument('title',
                         type=str,
                         required=True,
                         help='Title cannot be blank!')
post_parser.add_argument('body', type=str)

post_fields = api.model(
    'Post', {
        'id': fields.Integer,
        'title': fields.String,
        'body': fields.String,
        'user_id': fields.Integer,
    })

create_post_fields = api.model('CreatePost', {
    'title': fields.String,
    'body': fields.String,
})


@ns.route('/')
class PostListAPI(Resource):
    @api.marshal_list_with(post_fields)
    def get(self):
        posts = Post.query.all()
Beispiel #2
0
from flask import Blueprint
from flask.ext.security import auth_token_required
from flask_restplus import Resource, fields

from apps.api import ns_posts as ns, api
from apps.database import db
from .models import Post


post_parser = api.parser()
post_parser.add_argument('title', type=str, required=True, help='Title cannot be blank!')
post_parser.add_argument('body', type=str)

post_fields = api.model('Post', {
    'id': fields.Integer,
    'title': fields.String,
    'body': fields.String,
    'user_id': fields.Integer,
})

create_post_fields = api.model('CreatePost', {
    'title': fields.String,
    'body': fields.String,
})


@ns.route('/')
class PostListAPI(Resource):

    @api.marshal_list_with(post_fields)
    def get(self):
        posts = Post.query.all()
Beispiel #3
0
from flask.ext.security.utils import login_user
from flask_restplus import Resource, fields

from apps.api import ns_users as ns, api
from .models import user_datastore


user_parser = api.parser()
user_parser.add_argument('email', type=str, required=True, help='Email cannot be blank!')
user_parser.add_argument('password', type=str, required=True, help='Password cannot be blank!')


user_fields = api.model('User', {
    'id': fields.Integer,
    'email': fields.String,
    'username': fields.String,
    'first_name': fields.String,
    'last_name': fields.String,
})

create_user_fields = api.model('CreateUser', {
    'email': fields.String(discriminator=True),
    'password': fields.String(discriminator=True),
    'password_confirm': fields.String(discriminator=True),
})

session_fields = api.model('Login', {
    'email': fields.String(discriminator=True),
    'password': fields.String(discriminator=True),
})
Beispiel #4
0
from flask_restplus import Resource, fields

from apps.api import ns_users as ns, api
from .models import user_datastore


user_parser = api.parser()
user_parser.add_argument("email", type=str, required=True, help="Email cannot be blank!")
user_parser.add_argument("password", type=str, required=True, help="Password cannot be blank!")


user_fields = api.model(
    "User",
    {
        "id": fields.Integer,
        "email": fields.String,
        "username": fields.String,
        "first_name": fields.String,
        "last_name": fields.String,
    },
)

create_user_fields = api.model(
    "CreateUser",
    {
        "email": fields.String(discriminator=True),
        "password": fields.String(discriminator=True),
        "password_confirm": fields.String(discriminator=True),
    },
)

session_fields = api.model(