mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-07-29 17:39:48 +03:00
Replaced 'TODO' hardcoded version info by a parameter with default '0.1.0'
This commit is contained in:
parent
ec1b14174f
commit
9a94129ed5
|
@ -151,7 +151,7 @@ class BaseSchemaGenerator(object):
|
|||
# Set by 'SCHEMA_COERCE_PATH_PK'.
|
||||
coerce_path_pk = None
|
||||
|
||||
def __init__(self, title=None, url=None, description=None, patterns=None, urlconf=None):
|
||||
def __init__(self, title=None, url=None, description=None, patterns=None, urlconf=None, version='0.1.0'):
|
||||
if url and not url.endswith('/'):
|
||||
url += '/'
|
||||
|
||||
|
@ -161,6 +161,7 @@ class BaseSchemaGenerator(object):
|
|||
self.urlconf = urlconf
|
||||
self.title = title
|
||||
self.description = description
|
||||
self.version = version
|
||||
self.url = url
|
||||
self.endpoints = None
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ class SchemaGenerator(BaseSchemaGenerator):
|
|||
def get_info(self):
|
||||
info = {
|
||||
'title': self.title,
|
||||
'version': 'TODO',
|
||||
'version': self.version,
|
||||
}
|
||||
|
||||
if self.description is not None:
|
||||
|
|
|
@ -489,3 +489,17 @@ class TestGenerator(TestCase):
|
|||
|
||||
assert 'openapi' in schema
|
||||
assert 'paths' in schema
|
||||
|
||||
def test_schema_information(self):
|
||||
"""Construction of the top level dictionary."""
|
||||
patterns = [
|
||||
url(r'^example/?$', views.ExampleListView.as_view()),
|
||||
]
|
||||
generator = SchemaGenerator(patterns=patterns, title='My title', version='1.2.3', description='My description')
|
||||
|
||||
request = create_request('/')
|
||||
schema = generator.get_schema(request=request)
|
||||
|
||||
assert schema['info']['title'] == 'My title'
|
||||
assert schema['info']['version'] == '1.2.3'
|
||||
assert schema['info']['description'] == 'My description'
|
||||
|
|
Loading…
Reference in New Issue
Block a user