From b3e28505f30c34b0a4112c26cad45a92da4144c6 Mon Sep 17 00:00:00 2001 From: Anthony Geourjon <anthony.geourjon@tetras-libre.fr> Date: Thu, 19 Jan 2023 12:01:54 +0100 Subject: [PATCH] Some example of swagger --- Mirador_backend/resources/mirador_resource.py | 31 ++++++++++--------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/Mirador_backend/resources/mirador_resource.py b/Mirador_backend/resources/mirador_resource.py index 49909f4..054f667 100644 --- a/Mirador_backend/resources/mirador_resource.py +++ b/Mirador_backend/resources/mirador_resource.py @@ -9,27 +9,30 @@ from flask_apispec.views import MethodResource from flask_apispec import marshal_with, doc, use_kwargs class MRResponseSchema(Schema): - message = fields.Str(default='Success') + message = fields.Str(default='Success') class MRRequestSchema(Schema): - api_type = fields.String(required=True, description="API type of awesome API") + class Meta: + fields = ('name', 'description') # TODO just an example 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} + @doc(description='Mirador resource i e, manifest and collection of IIIF resource', tags=['Mirador resource']) + @marshal_with(MRResponseSchema) # marshalling + def get(self, id=None): + return {'method': 'get', 'id': id} - def post(self): - return {'method': 'post'} + @doc(description='Create Mirador resource i e, manifest and collection of IIIF resource', tags=['Mirador resource']) + @use_kwargs(MRRequestSchema, location=('json')) + def post(self): + return {'method': 'post'} - def put(self, id): - return {'method': 'put', 'id': id} + def put(self, id): + return {'method': 'put', 'id': id} - def patch(self, id): - return {'method': 'patch', 'id': id} + def patch(self, id): + return {'method': 'patch', 'id': id} - def delete(self, id): - return {'method': 'delete', 'id': id} + def delete(self, id): + return {'method': 'delete', 'id': id} -- GitLab