Add OpenAPI schema endpoint to API (#147)

This commit is contained in:
Christopher C. Wells 2020-06-19 14:56:05 -07:00
parent 099e393f36
commit fddde9d46f
2 changed files with 12 additions and 1 deletions

View File

@ -474,6 +474,11 @@ header to `Token <user-key>`. E.g.
If the `Authorization` header is not set or the key is not valid, the API will
return `403 Forbidden` with additional details in the response body.
### Schema
A live version of the API schema in the [OpenAPI format](https://swagger.io/specification/)
is available at the `/api/scehma` path of a running instance.
### `GET` Method
#### Request

View File

@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
from django.urls import include, path
from rest_framework import routers
from rest_framework.schemas import get_schema_view
from . import views
@ -22,5 +23,10 @@ urlpatterns = [
path('api/auth/', include(
'rest_framework.urls',
namespace='rest_framework'
))
)),
path('api/schema', get_schema_view(
title='Baby Buddy API',
version=1,
description='API documentation for the Baby Buddy application'
), name='openapi-schema'),
]