Project

General

Profile

Feature #1386

API: Flask restful framework

Added by Bernhard Koschiček-Krombholz 9 months ago. Updated 6 months ago.

Status:
Closed
Priority:
Low
Category:
API
Target version:
Start date:
2020-10-15
Estimated time:

Description

As discussed in the OpenAtlas development session 10th October, now is a good time to deploy a framework for a standardized output (header, status codes, other formats).
We will look into flask-restful

Installation

# apt install python3-flask-restful 


Related issues

Related to Feature #1274: API: Automatic documentation for code Closed2020-06-16Actions
Related to Feature #1184: API: add additional output format RDFSAssigned2020-03-27Actions
Related to Question #1382: API: Other jsonld mappings beside linked-placesClosed2020-10-12Actions
Related to Feature #1390: API: Swagger file in OpenAtlas repositoryClosed2020-10-16Actions

History

#1

Updated by Bernhard Koschiček-Krombholz 9 months ago

  • Related to Feature #1274: API: Automatic documentation for code added
#2

Updated by Bernhard Koschiček-Krombholz 9 months ago

  • Related to Feature #1184: API: add additional output format RDFS added
#3

Updated by Bernhard Koschiček-Krombholz 9 months ago

  • Related to Question #1382: API: Other jsonld mappings beside linked-places added
#4

Updated by Alexander Watzinger 9 months ago

  • Description updated (diff)
#5

Updated by Bernhard Koschiček-Krombholz 9 months ago

I looked into flask-restful. It is not complicated and quite intuitive. Right now, our API can quite the same but flask-restful is way easier to read.
One major problem I found is, that the flask-restful package alone is not compatable with swagger automatic annotation. For this we need another package named flask-restful-swagger which is not a Debian package. We also can you flask-restx which has the swagger annotation included, but again, no Debian package.

I will complete the transformation to restful anyway, because it is easier to read and maybe I find new way to make the API request faster. How we cope with swagger, besides manual manipulation, I don't know.

#6

Updated by Bernhard Koschiček-Krombholz 9 months ago

  • Related to Feature #1390: API: Swagger file in OpenAtlas repository added
#7

Updated by Alexander Watzinger 9 months ago

I'm no expert there but what about python3-flasgger? It's a Debian package and sounds promising:

Flasgger is a Flask extension to extract OpenAPI-Specification from all Flask views registered in your API. It also comes with SwaggerUI embedded so you can access http://localhost:5000/apidocs and visualize and interact with your API resources. It also provides validation of the incoming data, using the same specification it can validates if the data received as a POST, PUT, PATCH is valid against the schema defined using YAML, Python dictionaries or Marshmallow Schemas. Flasgger can work with simple function views or MethodViews using docstring as specification, or using @swag_from decorator to get specification from YAML or dict and also provides SwaggerView which can use Marshmallow Schemas as specification.

This article shows an example how to use it: https://kanoki.org/2020/07/18/python-api-documentation-using-flask-swagger/

#8

Updated by Bernhard Koschiček-Krombholz 9 months ago

As usual, you save the day or night. Thank you! This looks very promising.

#9

Updated by Bernhard Koschiček-Krombholz 7 months ago

  • Status changed from Assigned to In Progress

Basically it is done and in develop branch. After a final code review with Alex and maybe a look over from Christoph, this ticket can be closed.

#10

Updated by Bernhard Koschiček-Krombholz 6 months ago

  • Target version changed from API to 5.7.0
  • Status changed from In Progress to Closed
#11

Updated by Alexander Watzinger 6 months ago

  • Subject changed from API: Implement flask restful framework to API: Flask restful framework

Also available in: Atom PDF