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.
Next release (in development)¶
- Fixed doctor attempting to document non doctor type params (#70)
- String with format of date now returns datetime.date (#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.
- 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.
- 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.
- 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.
- 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.
- 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.
- Add request option to router HTTP method dictionary, which allows you to override the schema used to validate the request body.
- Fixed response validation when the response was an instance of doctor.response.Response
- 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.
- Added a Response class that can be returned from logic functions in order to add/modify response headers.
- More fixes for Python 3.
- Fixed sphinx build error encountered on Sphinx v1.6.1+ when checking if the http domain has already been added.
- Added support for Python 3.
- 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.
- 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.
- Fixes a bug where the logic function wouldn’t be undecorated properly.
- 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.
- Added ability to override the schema used for an individual endpoint.
- Making required changes to setup.py for pypi.
- Initial release.