hyperschema package¶
Submodules¶
hyperschema.hypermedia module¶
Module that provides decorators for hypermedia handling and Schema validation using Json HyperSchema and Json Schema.
-
class
hyperschema.hypermedia.
HyperMedia
(schema_cache_size=50, schema_path='./schemas', base_url=None)[source]¶ Class wrapping methods for hypermedia
-
consumes
(type_mappings)[source]¶ Wrapper that finds matches the content with one of supported type and performs a json schema validation for the type.
Parameters: type_mappings – Dictionary of (content type, schema name) Returns: decorated function
-
static
produces
(type_mappings, default='application/json', set_mimetype=True, strict=False)[source]¶ Wrapper that does content negotiation based on accept headers and applies hyperschema to the response. It passes the negotiated header to the wrapped method. Currently it does a very basic negotitation. In future it can be modified to do full content negotiation.
Parameters: - type_mappings (dict) – Dictionary of (content type, hyperschema name)
- default (str) – Default Mime Type if no Accept header is specified.
- set_mimetype (bool) – If True: the mimetype is automatically set for response .
- strict (bool) – Boolean parameter specifying whether to use strict negotiation. If False, default mimetype is used if negotiation fails else 406 response is returned.
Returns: decorated function
-
register_error_handlers
(flask_app)[source]¶ Registers error handlers for schema with flask application.
Parameters: flask_app (Flask) – Flask application Returns: self instance Return type: HyperMedia
-
-
class
hyperschema.hypermedia.
SchemaApi
[source]¶ Bases:
flask.views.MethodView
Root API
-
get
(schema_id=None)[source]¶ Gets the schema by ID if schema_id is given or lists all schemas
Parameters: schema_id (str) – id/name for the schema. If None, all schemas are listed Returns: Flask Json Response containing version. Return type: flask.Response
-
hypermedia
= None¶
-
methods
= ['GET']¶
-