forked from sanic-org/sanic-openapi
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(examples): add class based routing demonstration in cars example
- Loading branch information
Showing
4 changed files
with
38 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from sanic.views import HTTPMethodView | ||
from sanic.blueprints import Blueprint | ||
from sanic.response import json | ||
from sanic_openapi import doc | ||
|
||
blueprint = Blueprint('Repair', '/repair') | ||
from models import Station | ||
from data import test_station | ||
|
||
|
||
class RepairStation(HTTPMethodView): | ||
@doc.summary("Fetches all repair stations") | ||
@doc.produces([Station]) | ||
def get(self, request): | ||
return json([test_station]) | ||
|
||
@doc.summary("make an appointment") | ||
@doc.description("submit necessary information for appointment") | ||
def post(self, request): | ||
return json(request.json) | ||
|
||
|
||
blueprint.add_route(RepairStation.as_view(), "/station", strict_slashes=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters