From fddde9d46f9eb34cc61cb40408a6508a6e31dc79 Mon Sep 17 00:00:00 2001 From: "Christopher C. Wells" Date: Fri, 19 Jun 2020 14:56:05 -0700 Subject: [PATCH] Add OpenAPI schema endpoint to API (#147) --- README.md | 5 +++++ api/urls.py | 8 +++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index da5efc1c..a23c70d8 100644 --- a/README.md +++ b/README.md @@ -474,6 +474,11 @@ header to `Token `. 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 diff --git a/api/urls.py b/api/urls.py index c547c518..0a0155a9 100644 --- a/api/urls.py +++ b/api/urls.py @@ -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'), ]