Skip to content

Commit

Permalink
Specify schema.validate explicitly in documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
hfaran committed Feb 18, 2014
1 parent fd8853e commit bf676e6
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Tornado-JSON is a small extension of [Tornado](http://www.tornadoweb.org/en/stab

Some of the key features the included modules provide:

* Input and output [JSON Schema](http://json-schema.org/) validation by decorating RequestHandlers with `validate`
* Input and output [JSON Schema](http://json-schema.org/) validation by decorating RequestHandlers with `schema.validate`
* Automated *route generation* with `routes.get_routes(package)`
* *Automated Public API documentation* using schemas and provided descriptions
* Standardized output using the [JSend](http://labs.omniti.com/labs/jsend) specification
Expand Down
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ in the documentation.
Some of the key features the included modules provide:

- Input and output `JSON Schema <http://json-schema.org/>`__ validation
by decorating RequestHandlers with ``validate``
by decorating RequestHandlers with ``schema.validate``
- Automated *route generation* with ``routes.get_routes(package)``
- *Automated Public API documentation* using schemas and provided
descriptions
Expand All @@ -35,7 +35,7 @@ Some of the key features the included modules provide:
\ *Warning: Tornado-JSON is still very much a work in progress. No
guarantees on backwards-compatibility made, however, I try not to do
that since, as a user, I hate breaking it at least as much as you. That
being said, use it at your own risk.*\
being said, use it at your own risk.*\

Dependencies
============
Expand Down
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ in the documentation.
Some of the key features the included modules provide:

- Input and output `JSON Schema <http://json-schema.org/>`__ validation
by decorating RequestHandlers with ``validate``
by decorating RequestHandlers with ``schema.validate``
- Automated *route generation* with ``routes.get_routes(package)``
- *Automated Public API documentation* using schemas and provided
descriptions
Expand Down
8 changes: 4 additions & 4 deletions docs/requesthandler_guidelines.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ for an example. Here is an example for POST:
``doc`` is the **public** accompanying documentation that will be
available on the wiki.

Use the ``validate`` decorator on methods which will automatically
Use the ``schema.validate`` decorator on methods which will automatically
validate the request body and output against the schemas in
``apid[method_name]``. Additionally, ``return`` the data from the
request handler, rather than writing it back (the decorator will take
Expand All @@ -38,7 +38,7 @@ care of that).
.. code:: python
class ExampleHandler(APIHandler):
@validate
@schema.validate
def post(self):
...
return data
Expand All @@ -51,12 +51,12 @@ Assertions
Use ``exceptions.api_assert`` to fail when some the client does not meet some
API pre-condition/requirement, e.g., an invalid or incomplete request is
made. When using an assertion is not suitable,
``raise APIError( ... )``; don't use JSend ``fail`` directly.
``raise APIError( ... )``; don't use ``self.fail`` directly.

.. code:: python
class ExampleHandler(APIHandler):
@validate
@schema.validate
def post(self):
...
api_assert(condition, status_code, log_message=log_message)
8 changes: 4 additions & 4 deletions docs/using_tornado_json.rst
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@ helloworld/api.py

Now comes the fun part where we develop the actual web app. We'll import
``APIHandler`` (this is the handler you should subclass for API routes),
and the ``validate`` decorator which will validate input and output
and the ``schema.validate`` decorator which will validate input and output
schema for us.

.. code:: python
from tornado_json.requesthandlers import APIHandler
from tornado_json.schema import validate
from tornado_json import schema
class HelloWorldHandler(APIHandler):
"""Hello!"""
Expand Down Expand Up @@ -95,12 +95,12 @@ back. Notice that rather than using ``self.write`` as we usually would,
we simply return the data we want to write back, which will then be
validated against the output schema and be written back according to the
`JSend <http://labs.omniti.com/labs/jsend>`__ specification. The
``validate`` decorator handles all of this so be sure to decorate any
``schema.validate`` decorator handles all of this so be sure to decorate any
HTTP methods with it.

.. code:: python
@validate
@schema.validate
def get(self):
return "Hello world!"
Expand Down

0 comments on commit bf676e6

Please sign in to comment.