1
0
mirror of https://github.com/gsi-upm/senpy synced 2024-11-22 00:02:28 +00:00

Add 'help' as a parameter to the API, with two options: "true" and "false". It is false by default.

Modify all the /api blueprint to export the list of available params
This commit is contained in:
militarpancho 2017-07-13 13:35:56 +02:00
parent 312e7f7f12
commit aaad5e8f2b
2 changed files with 27 additions and 1 deletions

View File

@ -39,6 +39,14 @@ API_PARAMS = {
"required": True, "required": True,
"options": ["filtered", "nested", "full"], "options": ["filtered", "nested", "full"],
"default": "full" "default": "full"
},
"help": {
"@id": "help",
"description": "Show additional help to know more about the possible parameters",
"aliases": ["help", "h"],
"required": True,
"options": ["True", "False"],
"default": "False"
} }
} }

View File

@ -20,7 +20,7 @@ Blueprints for Senpy
from flask import (Blueprint, request, current_app, render_template, url_for, from flask import (Blueprint, request, current_app, render_template, url_for,
jsonify) jsonify)
from .models import Error, Response, Plugins, read_schema from .models import Error, Response, Plugins, read_schema
from .api import WEB_PARAMS, API_PARAMS, parse_params from .api import WEB_PARAMS, API_PARAMS, CLI_PARAMS, NIF_PARAMS, parse_params
from .version import __version__ from .version import __version__
from functools import wraps from functools import wraps
@ -144,3 +144,21 @@ def plugin(plugin=None):
else: else:
return Error(message="Plugin not found", status=404) return Error(message="Plugin not found", status=404)
return response return response
@api_blueprint.route('/params/', methods=['POST', 'GET'])
@basic_api
def params():
phelp = request.params.get('help')
if eval(phelp):
dic = {'WEB_PARAMS': WEB_PARAMS,
'CLI_PARAMS': CLI_PARAMS,
'NIF_PARAMS': NIF_PARAMS,
'API_PARAMS': API_PARAMS
}
response = Response(dic)
return response
else:
response = Response(request.params)
return response