Project

General

Profile

Actions

Feature #1386

closed

API: Flask restful framework

Added by Bernhard Koschiček-Krombholz over 3 years ago. Updated over 3 years ago.

Status:
Closed
Priority:
Normal
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 4 (0 open4 closed)

Related to OpenAtlas - Feature #1274: API: Automatic documentation for code ClosedBernhard Koschiček-Krombholz2020-06-16Actions
Related to OpenAtlas - Feature #1184: API: add additional output format RDFSClosedBernhard Koschiček-Krombholz2020-03-27Actions
Related to OpenAtlas - Question #1382: API: Other jsonld mappings beside linked-placesClosedBernhard Koschiček-Krombholz2020-10-12Actions
Related to OpenAtlas - Feature #1390: API: Swagger file in OpenAtlas repositoryClosedBernhard Koschiček-Krombholz2020-10-16Actions
Actions #1

Updated by Bernhard Koschiček-Krombholz over 3 years ago

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

Updated by Bernhard Koschiček-Krombholz over 3 years ago

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

Updated by Bernhard Koschiček-Krombholz over 3 years ago

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

Updated by Alexander Watzinger over 3 years ago

  • Description updated (diff)
Actions #5

Updated by Bernhard Koschiček-Krombholz over 3 years 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.

Actions #6

Updated by Bernhard Koschiček-Krombholz over 3 years ago

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

Updated by Alexander Watzinger over 3 years 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/

Actions #8

Updated by Bernhard Koschiček-Krombholz over 3 years ago

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

Actions #9

Updated by Bernhard Koschiček-Krombholz over 3 years 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.

Actions #10

Updated by Bernhard Koschiček-Krombholz over 3 years ago

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

Updated by Alexander Watzinger over 3 years ago

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

Also available in: Atom PDF