This module uses python types to validate request and response data in Flask Python APIs and generate API documentation. It uses python 3 type hints to validate request parameters. It also supports generic schema validation for plain dictionaries.

Release History

Next release (in development)

v3.0.0-beta.5 (2018-03-05)

  • Fixed doctor attempting to document non doctor type params (#70)
  • String with format of date now returns (#69)
  • Fixed swallowing of TypeError from SuperType class in Object init (#68)
  • Changed the flask code to only raise response validation errors if an environment variable is set. Before it also raised them when DEBUG was True in the config. In practice this was incredibly annoying and slowed down development. Especially in the case where a datetime string was returned that didn’t include timezone information. Updated the docs to reflect this too.
  • Fixed issue that could create duplicate handler names which would cause an exception in flask restful (#67 )
  • Made the JsonSchema doctor type work in validating/coercing params in the api and for generating api documentation.

v3.0.0-beta.4 (2018-03-02)

  • Made validation errors better when raising http 400 exceptions. They now will display all missing required fields and all validation errors along with have the param in the error message.
  • Fixed issue with doctor types being passed to logic functions. Instead the native types are now passed to prevent downstream issues from other code encountering unexpected/unknown types.

v3.0.0-beta.3 (2018-02-28)

  • Added default example values for all doctor types.
  • Documentation updates
  • Updated doctor code to work agnostic of the framework so eventually other backends than flask could be used.

V3.0.0-beta (2018-02-27)

  • First beta release of 3.0. This is a backwards incompatible change. It drops support for python 2 and defining request parameters through the usage of json schemas. It’s still possible to use the json schemas from previous versions of doctor to generate new doctor types using doctor.types.json_schema_type. See the documentation for more information.

v1.3.5 (2018-01-23)

  • Fixed a few deprecation warnings about inspect.getargspec when running doctor using python 3. It will now use inspect.getfullargspec. This also fixes the issue of not being able to use type hints on logic functions in python 3.

v1.3.4 (2017-12-04)

  • Removed set operation on decorators when applying them to the logic function. Since set types don’t have an explicit order it caused unpredicatable behavior as the decorators weren’t always applied to the logic function in the same order with every call.

v1.3.3 (2017-10-18)

  • Add request option to router HTTP method dictionary, which allows you to override the schema used to validate the request body.

v1.3.2 (2017-09-18)

  • Fixed response validation when the response was an instance of doctor.response.Response

v1.3.1 (2017-08-29)

  • Fixed bug when auto generating documentation for GET endpoints that contained a parameter that was an array or object. It wasn’t getting json dumped, so when the request was made to generate the example response it would get a 400 error.
  • Fixed a few typos and bugs in the README quick start example.

v1.3.0 (2017-08-11)

  • Added a Response class that can be returned from logic functions in order to add/modify response headers.

v1.2.2 (2017-07-10)

  • More fixes for Python 3.

v1.2.1 (2017-07-07)

  • Fixed sphinx build error encountered on Sphinx v1.6.1+ when checking if the http domain has already been added.

v1.2.0 (2017-07-07)

  • Added support for Python 3.

v1.1.4 (2017-05-04)

  • Updates doctor to not parse json bodies on GET/DELETE requests, and instead try to parse them from the query string or form parameters.
  • Fixes a bug introducded in v1.1.3. This bug would only occur if a logic function was decorated and that decorator passed a positional argument to the logic function. Doctor would think the positional argument passed by the decorator was a required request parameter even if it was specified to be omitted in the router using omit_args.

v1.1.3 (2017-04-28)

  • Added new InternalError class to represent non-doctor internal errors.
  • Updated sphinx pin version to be minimum 1.5.4 and added new env kwarg to make_field amd make_xref.
  • Fixed bug where extra parameters passed on json requests would cause a TypeError if the logic function used a decorator.
  • Made sure to make decorators a set when applying them to a logic function when creating routes. This is to prevent a decorator from wrapping a function twice if it’s defined at the logic level and handler level when creating routes.

v1.1.2 (2017-02-27)

  • Fixes a bug where the logic function wouldn’t be undecorated properly.

v1.1.1 (2017-02-27)

  • Made logic function exceptions always raise when applicaiton is in debug mode.
  • Updated error message to be clearer when a logic function raises an exception.

v1.1.0 (2017-02-20)

  • Added ability to override the schema used for an individual endpoint.

v1.0.1 (2017-02-17)

  • Making required changes to for pypi.

v1.0.0 (2017-02-16)

  • Initial release.

Indices and tables