Skip to content

Commit

Permalink
Example of responses in docs in readme
Browse files Browse the repository at this point in the history
  • Loading branch information
maximdanilchenko committed Feb 16, 2019
1 parent bd5b753 commit bb0ea1a
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,23 @@ class TheView(web.View):
app.router.add_view("/v1/view", TheView)
```

As alternative you can add responses info to `docs` decorator, which is more compact way.
And it allows you not to use schemas for responses documentation:

```python

@docs(tags=["mytag"],
summary="Test method summary",
description="Test method description",
responses={200: {"schema": ResponseSchema(), "description": "Success response"}, # regular response
404: {"description": "Not found"}, # responses without schema
422: {"description": "Validation error"},
})
@request_schema(RequestSchema(strict=True))
async def index(request):
return web.json_response({"msg": "done", "data": {}})
```

## Adding validation middleware

```Python
Expand Down

0 comments on commit bb0ea1a

Please sign in to comment.