Skip to content
Snippets Groups Projects

Draft:Generic api v1

5 files
+ 49
12
Compare changes
  • Side-by-side
  • Inline

Files

from flask_restful import Resource
from flask_restful_swagger import swagger
from apispec import APISpec
from marshmallow import Schema, fields
from apispec.ext.marshmallow import MarshmallowPlugin
from flask_apispec.extension import FlaskApiSpec
from flask_apispec.views import MethodResource
from flask_apispec import marshal_with, doc, use_kwargs
class MiradorResource(Resource):
def get(self, id=None):
return {'method': 'get', 'id': id}
class MRResponseSchema(Schema):
message = fields.Str(default='Success')
def post(self):
return {'method': 'post'}
def put(self, id):
return {'method': 'put', 'id': id}
class MRRequestSchema(Schema):
api_type = fields.String(required=True, description="API type of awesome API")
def patch(self, id):
return {'method': 'patch', 'id': id}
def delete(self, id):
return {'method': 'delete', 'id': id}
class MiradorResource(MethodResource,Resource):
@doc(description='My First GET Awesome API.', tags=['Mirador resource'])
@marshal_with(MRResponseSchema) # marshalling
def get(self, id=None):
return {'method': 'get', 'id': id}
def post(self):
return {'method': 'post'}
def put(self, id):
return {'method': 'put', 'id': id}
def patch(self, id):
return {'method': 'patch', 'id': id}
def delete(self, id):
return {'method': 'delete', 'id': id}
Loading