I'm currently working on a javascript (react based) app that basically displays data from some database's tables, and allows to add, delete, update data from the tables. I implemented the services to access the database using Flask and SQLAlchemy, trying to follow the REST specification (more as a guideline than a 'dogma', since I'm not sharing my API over internet).
I want to implement a web-service that describes each table: let's take the table below
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:////tmp/test.db'
db = SQLAlchemy(app)
class User(db.Model):
id = db.Column(db.Integer, primary_key=True)
username = db.Column(db.String(80), unique=True, nullable=False)
email = db.Column(db.String(120), unique=True, nullable=False)
I want that kind of thing:
GET /user/description
Response: something like
[
{column_name: 'id', type: 'int' , p_key: 'True'},
{column_name: 'username', type: 'string'},
{column_name: 'email', type: 'string'}
]
(plus other useful metadata for a client willing to insert or update data)
I would like to know if there's such a kind of operation in the REST specification, and if not where can I find guidelines for implementing such a service (the dos and don'ts) - I would rather not reinvent the wheel for something that looks to me like a fairly common problem in programming.