OpenQuizz
Une application de gestion des contenus pédagogiques
|
Public Member Functions | |
def | __init__ (self, app=None, version='1.0', title=None, description=None, terms_url=None, license=None, license_url=None, contact=None, contact_url=None, contact_email=None, authorizations=None, security=None, doc='/', default_id=default_id, default='default', default_label='Default namespace', validate=None, tags=None, prefix='', ordered=False, default_mediatype='application/json', decorators=None, catch_all_404s=False, serve_challenge_on_401=False, format_checker=None, **kwargs) |
def | init_app (self, app, **kwargs) |
def | __getattr__ (self, name) |
def | register_resource (self, namespace, resource, *urls, **kwargs) |
def | output (self, resource) |
def | make_response (self, data, *args, **kwargs) |
def | documentation (self, func) |
def | render_root (self) |
def | render_doc (self) |
def | default_endpoint (self, resource, namespace) |
def | get_ns_path (self, ns) |
def | ns_urls (self, ns, urls) |
def | add_namespace (self, ns, path=None) |
def | namespace (self, *args, **kwargs) |
def | endpoint (self, name) |
def | specs_url (self) |
def | base_url (self) |
def | base_path (self) |
def | __schema__ (self) |
def | errorhandler (self, exception) |
def | owns_endpoint (self, endpoint) |
def | error_router (self, original_handler, e) |
def | handle_error (self, e) |
def | as_postman (self, urlvars=False, swagger=False) |
def | payload (self) |
def | refresolver (self) |
def | mediatypes_method (self) |
def | mediatypes (self) |
def | representation (self, mediatype) |
def | unauthorized (self, response) |
def | url_for (self, resource, **values) |
The main entry point for the application. You need to initialize it with a Flask Application: :: >>> app = Flask(__name__) >>> api = Api(app) Alternatively, you can use :meth:`init_app` to set the Flask application after it has been constructed. The endpoint parameter prefix all views and resources: - The API root/documentation will be ``{endpoint}.root`` - A resource registered as 'resource' will be available as ``{endpoint}.resource`` :param flask.Flask|flask.Blueprint app: the Flask application object or a Blueprint :param str version: The API version (used in Swagger documentation) :param str title: The API title (used in Swagger documentation) :param str description: The API description (used in Swagger documentation) :param str terms_url: The API terms page URL (used in Swagger documentation) :param str contact: A contact email for the API (used in Swagger documentation) :param str license: The license associated to the API (used in Swagger documentation) :param str license_url: The license page URL (used in Swagger documentation) :param str endpoint: The API base endpoint (default to 'api). :param str default: The default namespace base name (default to 'default') :param str default_label: The default namespace label (used in Swagger documentation) :param str default_mediatype: The default media type to return :param bool validate: Whether or not the API should perform input payload validation. :param bool ordered: Whether or not preserve order models and marshalling. :param str doc: The documentation path. If set to a false value, documentation is disabled. (Default to '/') :param list decorators: Decorators to attach to every resource :param bool catch_all_404s: Use :meth:`handle_error` to handle 404 errors throughout your app :param dict authorizations: A Swagger Authorizations declaration as dictionary :param bool serve_challenge_on_401: Serve basic authentication challenge with 401 responses (default 'False') :param FormatChecker format_checker: A jsonschema.FormatChecker object that is hooked into the Model validator. A default or a custom FormatChecker can be provided (e.g., with custom checkers), otherwise the default action is to not enforce any format validation.
def __init__ | ( | self, | |
app = None , |
|||
version = '1.0' , |
|||
title = None , |
|||
description = None , |
|||
terms_url = None , |
|||
license = None , |
|||
license_url = None , |
|||
contact = None , |
|||
contact_url = None , |
|||
contact_email = None , |
|||
authorizations = None , |
|||
security = None , |
|||
doc = '/' , |
|||
default_id = default_id , |
|||
default = 'default' , |
|||
default_label = 'Default namespace' , |
|||
validate = None , |
|||
tags = None , |
|||
prefix = '' , |
|||
ordered = False , |
|||
default_mediatype = 'application/json' , |
|||
decorators = None , |
|||
catch_all_404s = False , |
|||
serve_challenge_on_401 = False , |
|||
format_checker = None , |
|||
** | kwargs | ||
) |
def __getattr__ | ( | self, | |
name | |||
) |
def __schema__ | ( | self | ) |
The Swagger specifications/schema for this API :returns dict: the schema as a serializable dict
def add_namespace | ( | self, | |
ns, | |||
path = None |
|||
) |
This method registers resources from namespace for current instance of api. You can use argument path for definition custom prefix url for namespace. :param Namespace ns: the namespace :param path: registration prefix of namespace
def as_postman | ( | self, | |
urlvars = False , |
|||
swagger = False |
|||
) |
Serialize the API as Postman collection (v1) :param bool urlvars: whether to include or not placeholders for query strings :param bool swagger: whether to include or not the swagger.json specifications
def base_path | ( | self | ) |
The API path :rtype: str
def base_url | ( | self | ) |
The API base absolute url :rtype: str
def default_endpoint | ( | self, | |
resource, | |||
namespace | |||
) |
Provide a default endpoint for a resource on a given namespace. Endpoints are ensured not to collide. Override this method specify a custom algoryhtm for default endpoint. :param Resource resource: the resource for which we want an endpoint :param Namespace namespace: the namespace holding the resource :returns str: An endpoint name
def documentation | ( | self, | |
func | |||
) |
A decorator to specify a view funtion for the documentation
def endpoint | ( | self, | |
name | |||
) |
def error_router | ( | self, | |
original_handler, | |||
e | |||
) |
This function decides whether the error occured in a flask-restplus endpoint or not. If it happened in a flask-restplus endpoint, our handler will be dispatched. If it happened in an unrelated view, the app's original error handler will be dispatched. In the event that the error occurred in a flask-restplus endpoint but the local handler can't resolve the situation, the router will fall back onto the original_handler as last resort. :param function original_handler: the original Flask error handler for the app :param Exception e: the exception raised while handling the request
def errorhandler | ( | self, | |
exception | |||
) |
A decorator to register an error handler for a given exception
def get_ns_path | ( | self, | |
ns | |||
) |
def handle_error | ( | self, | |
e | |||
) |
Error handler for the API transforms a raised exception into a Flask response, with the appropriate HTTP status code and body. :param Exception e: the raised Exception object
def init_app | ( | self, | |
app, | |||
** | kwargs | ||
) |
Allow to lazy register the API on a Flask application:: >>> app = Flask(__name__) >>> api = Api() >>> api.init_app(app) :param flask.Flask app: the Flask application object :param str title: The API title (used in Swagger documentation) :param str description: The API description (used in Swagger documentation) :param str terms_url: The API terms page URL (used in Swagger documentation) :param str contact: A contact email for the API (used in Swagger documentation) :param str license: The license associated to the API (used in Swagger documentation) :param str license_url: The license page URL (used in Swagger documentation)
def make_response | ( | self, | |
data, | |||
* | args, | ||
** | kwargs | ||
) |
Looks up the representation transformer for the requested media type, invoking the transformer to create a response object. This defaults to default_mediatype if no transformer is found for the requested mediatype. If default_mediatype is None, a 406 Not Acceptable response will be sent as per RFC 2616 section 14.1 :param data: Python object containing response data to be transformed
def mediatypes | ( | self | ) |
Returns a list of requested mediatypes sent in the Accept header
def mediatypes_method | ( | self | ) |
Return a method that returns a list of mediatypes
def namespace | ( | self, | |
* | args, | ||
** | kwargs | ||
) |
A namespace factory. :returns Namespace: a new namespace instance
def ns_urls | ( | self, | |
ns, | |||
urls | |||
) |
def output | ( | self, | |
resource | |||
) |
Wraps a resource (as a flask view function), for cases where the resource does not directly return a response object :param resource: The resource as a flask view function
def owns_endpoint | ( | self, | |
endpoint | |||
) |
Tests if an endpoint name (not path) belongs to this Api. Takes into account the Blueprint name part of the endpoint name. :param str endpoint: The name of the endpoint being checked :return: bool
def payload | ( | self | ) |
Store the input payload in the current request context
def refresolver | ( | self | ) |
def register_resource | ( | self, | |
namespace, | |||
resource, | |||
* | urls, | ||
** | kwargs | ||
) |
def render_doc | ( | self | ) |
Override this method to customize the documentation page
def render_root | ( | self | ) |
def representation | ( | self, | |
mediatype | |||
) |
Allows additional representation transformers to be declared for the api. Transformers are functions that must be decorated with this method, passing the mediatype the transformer represents. Three arguments are passed to the transformer: * The data to be represented in the response body * The http status code * A dictionary of headers The transformer should convert the data appropriately for the mediatype and return a Flask response object. Ex:: @api.representation('application/xml') def xml(data, code, headers): resp = make_response(convert_data_to_xml(data), code) resp.headers.extend(headers) return resp
def specs_url | ( | self | ) |
The Swagger specifications absolute url (ie. `swagger.json`) :rtype: str
def unauthorized | ( | self, | |
response | |||
) |
Given a response, change it to ask for credentials
def url_for | ( | self, | |
resource, | |||
** | values | ||
) |
Generates a URL to the given resource. Works like :func:`flask.url_for`.
app |
authorizations |
blueprint |
blueprint_setup |
catch_all_404s |
contact |
contact_email |
contact_url |
decorators |
default_id |
default_mediatype |
default_namespace |
description |
endpoints |
error_handlers |
format_checker |
license |
license_url |
models |
namespaces |
ns_paths |
ordered |
prefix |
representations |
resources |
security |
serve_challenge_on_401 |
tags |
terms_url |
title |
urls |
version |