From b6c50d0809f1f2397684b3eb7a550b5992860755 Mon Sep 17 00:00:00 2001 From: Mopsan Date: Wed, 22 Apr 2020 23:06:27 +0300 Subject: [PATCH] Update openapi.py --- rest_framework/schemas/openapi.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/rest_framework/schemas/openapi.py b/rest_framework/schemas/openapi.py index 9b3082822..6cf3637e1 100644 --- a/rest_framework/schemas/openapi.py +++ b/rest_framework/schemas/openapi.py @@ -27,15 +27,26 @@ from .utils import get_pk_description, is_list_view class SchemaGenerator(BaseSchemaGenerator): def get_info(self): - # Title and version are required by openapi specification 3.x + """ + Generate a OpenAPI Info Object. + + https://swagger.io/specification/#infoObject + """ + if self.title is None: + raise AssertionError("title is required for Swagger Info Object") + + if self.version is None: + raise AssertionError("version is required for Swagger Info Object") + info = { - 'title': self.title or '', - 'version': self.version or '' + 'title': self.title } if self.description is not None: info['description'] = self.description + info['version'] = self.version + return info def check_duplicate_operation_id(self, paths):