Skip to content

Commit

Permalink
Fix content type and spiced up readme
Browse files Browse the repository at this point in the history
  • Loading branch information
channelcat committed Jan 30, 2017
1 parent c2a377a commit 13b71f4
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 10 deletions.
6 changes: 3 additions & 3 deletions README.md
Expand Up @@ -4,7 +4,9 @@
[![PyPI](https://img.shields.io/pypi/v/sanic-openapi.svg)](https://pypi.python.org/pypi/sanic-openapi/)
[![PyPI](https://img.shields.io/pypi/pyversions/sanic-openapi.svg)](https://pypi.python.org/pypi/sanic-openapi/)

Adds OpenAPI documentation to a Sanic project
Give your Sanic API a UI and OpenAPI documentation, all for the price of free!

![Example Swagger UI](images/code-to-ui.png?raw=true "Swagger UI")

## Installation

Expand All @@ -24,8 +26,6 @@ app.blueprint(swagger_blueprint)
You'll now have a Swagger UI at the URL `/swagger`.
Your routes will be automatically categorized by their blueprints.

![Example Swagger UI](images/example_pet_store.PNG?raw=true "Swagger UI")

## Usage

### Use simple decorators to document routes:
Expand Down
9 changes: 5 additions & 4 deletions examples/cars/main.py
Expand Up @@ -6,16 +6,17 @@
from blueprints.manufacturer import blueprint as manufacturer_blueprint

app = Sanic()

app.blueprint(openapi_blueprint)
app.blueprint(swagger_blueprint)
app.blueprint(car_blueprint)
app.blueprint(driver_blueprint)
app.blueprint(garage_blueprint)
app.blueprint(manufacturer_blueprint)

app.config['API_VERSION'] = '1.0.0'
app.config['API_TITLE'] = 'Car API'
app.config['API_TERMS_OF_SERVICE'] = 'Use with caution!'
app.config['API_CONTACT_EMAIL'] = 'channelcat@gmail.com'
app.config.API_VERSION = '1.0.0'
app.config.API_TITLE = 'Car API'
app.config.API_TERMS_OF_SERVICE = 'Use with caution!'
app.config.API_CONTACT_EMAIL = 'channelcat@gmail.com'

app.run(debug=True)
Binary file added images/code-to-ui.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion sanic_openapi/__init__.py
@@ -1,5 +1,5 @@
from .openapi import blueprint as openapi_blueprint
from .swagger import blueprint as swagger_blueprint

__version__ = '0.1.2'
__version__ = '0.1.3'
__all__ = ['openapi_blueprint', 'swagger_blueprint']
4 changes: 2 additions & 2 deletions sanic_openapi/openapi.py
Expand Up @@ -75,9 +75,9 @@ def build_spec(app, loop):
for _method, _handler in method_handlers:
route_spec = route_specs.get(_handler) or RouteSpec()
consumes_content_types = route_spec.consumes_content_type or \
getattr(app.config, 'API_CONSUMES_CONTENT_TYPE', 'application/json')
getattr(app.config, 'API_CONSUMES_CONTENT_TYPES', ['application/json'])
produces_content_types = route_spec.produces_content_type or \
getattr(app.config, 'API_PRODUCES_CONTENT_TYPE', 'application/json')
getattr(app.config, 'API_PRODUCES_CONTENT_TYPES', ['application/json'])

endpoint = remove_nulls({
'operationId': route_spec.operation or _handler.__name__,
Expand Down

0 comments on commit 13b71f4

Please sign in to comment.