8000 Support the API description from schema’s document by nickromano · Pull Request #39 · core-api/python-openapi-codec · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on Mar 18, 2019. It is now read-only.

Support the API description from schema’s document #39

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions openapi_codec/encode.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def generate_swagger_object(document):
swagger['info'] = OrderedDict()
swagger['info']['title'] = document.title
swagger['info']['version'] = '' # Required by the spec
swagger['info']['description'] = document.description

if parsed_url.netloc:
swagger['host'] = parsed_url.netloc
Expand Down
18 changes: 17 additions & 1 deletion tests/test_encode.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ def test_info(self):
self.assertIn('info', self.swagger)
expected = {
'title': self.document.title,
'version': ''
'version': '',
'description': ''
}
self.assertEquals(self.swagger['info'], expected)

Expand All @@ -33,6 +34,21 @@ def test_schemes(self):
self.assertEquals(self.swagger['schemes'], expected)


class TestInfoDescription(TestCase):
def setUp(self):
self.document = coreapi.Document(title='Example API', url='https://www.example.com/', description='Welcome to API Docs')
self.swagger = generate_swagger_object(self.document)

def test_info(self):
self.assertIn('info', self.swagger)
expected = {
'title': self.document.title,
'version': '',
'description': self.document.description
}
self.assertEquals(self.swagger['info'], expected)


class TestPaths(TestCase):
def setUp(self):
self.path = '/users/'
Expand Down
0