Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 7065429d47 | |||
| bd727fbe88 | |||
| 698a175a1b | |||
| 5b225423ae | |||
| 209201b9a5 | |||
| ca00ed35be |
+3
-1
@@ -2,7 +2,6 @@ language: python
|
|||||||
cache: pip
|
cache: pip
|
||||||
|
|
||||||
python:
|
python:
|
||||||
- '2.7'
|
|
||||||
- '3.4'
|
- '3.4'
|
||||||
- '3.5'
|
- '3.5'
|
||||||
- '3.6'
|
- '3.6'
|
||||||
@@ -14,6 +13,9 @@ env:
|
|||||||
jobs:
|
jobs:
|
||||||
include:
|
include:
|
||||||
- stage: test
|
- stage: test
|
||||||
|
python: '2.7'
|
||||||
|
env: DRF=3.7
|
||||||
|
-
|
||||||
python: '3.6'
|
python: '3.6'
|
||||||
env: DRF=master
|
env: DRF=master
|
||||||
-
|
-
|
||||||
|
|||||||
@@ -3,6 +3,16 @@ Changelog
|
|||||||
#########
|
#########
|
||||||
|
|
||||||
|
|
||||||
|
*********
|
||||||
|
**1.7.1**
|
||||||
|
*********
|
||||||
|
|
||||||
|
*Release date: May 05, 2018*
|
||||||
|
|
||||||
|
- **IMPROVED:** updated ``swagger-ui`` to version 3.14.1
|
||||||
|
- **IMPROVED:** set ``swagger-ui`` ``showCommonExtensions`` to ``True`` by default and add
|
||||||
|
``SHOW_COMMON_EXTENSIONS`` setting key
|
||||||
|
|
||||||
*********
|
*********
|
||||||
**1.7.0**
|
**1.7.0**
|
||||||
*********
|
*********
|
||||||
|
|||||||
@@ -255,6 +255,15 @@ Controls how many levels are expaned by default when showing nested models.
|
|||||||
**Default**: :python:`3` |br|
|
**Default**: :python:`3` |br|
|
||||||
*Maps to parameter*: ``defaultModelExpandDepth``
|
*Maps to parameter*: ``defaultModelExpandDepth``
|
||||||
|
|
||||||
|
DEFAULT_MODEL_DEPTH
|
||||||
|
-------------------
|
||||||
|
|
||||||
|
Controls the display of extensions (``pattern``, ``maxLength``, ``minLength``, ``maximum``, ```minimum``) fields and
|
||||||
|
values for Parameters.
|
||||||
|
|
||||||
|
**Default**: :python:`True` |br|
|
||||||
|
*Maps to parameter*: ``showCommonExtensions``
|
||||||
|
|
||||||
.. _oauth2-settings:
|
.. _oauth2-settings:
|
||||||
|
|
||||||
OAUTH2_REDIRECT_URL
|
OAUTH2_REDIRECT_URL
|
||||||
|
|||||||
Generated
+414
-414
File diff suppressed because it is too large
Load Diff
+1
-1
@@ -2,7 +2,7 @@
|
|||||||
"name": "drf-yasg",
|
"name": "drf-yasg",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"redoc": "^2.0.0-alpha.17",
|
"redoc": "^2.0.0-alpha.17",
|
||||||
"swagger-ui-dist": "^3.13.6"
|
"swagger-ui-dist": "^3.14.1"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
|||||||
@@ -8,5 +8,4 @@ six>=1.10.0
|
|||||||
uritemplate>=3.0.0
|
uritemplate>=3.0.0
|
||||||
|
|
||||||
djangorestframework>=3.7.7
|
djangorestframework>=3.7.7
|
||||||
Django>=1.11.7,<2.0; python_version <= "2.7"
|
Django>=1.11.7
|
||||||
Django>=1.11.7; python_version >= "3.4"
|
|
||||||
|
|||||||
@@ -3,8 +3,7 @@ pytest>=2.9
|
|||||||
pytest-pythonpath>=0.7.1
|
pytest-pythonpath>=0.7.1
|
||||||
pytest-cov>=2.5.1
|
pytest-cov>=2.5.1
|
||||||
pytest-xdist>=1.22.0
|
pytest-xdist>=1.22.0
|
||||||
# latest pip version of pytest-django is more than a year old and does not support Django 2.0
|
pytest-django>=3.2.0
|
||||||
git+https://github.com/pytest-dev/pytest-django.git@94cccb956435dd7a719606744ee7608397e1eafb
|
|
||||||
datadiff==2.0.0
|
datadiff==2.0.0
|
||||||
|
|
||||||
-r testproj.txt
|
-r testproj.txt
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ SWAGGER_DEFAULTS = {
|
|||||||
'SHOW_EXTENSIONS': True,
|
'SHOW_EXTENSIONS': True,
|
||||||
'DEFAULT_MODEL_RENDERING': 'model',
|
'DEFAULT_MODEL_RENDERING': 'model',
|
||||||
'DEFAULT_MODEL_DEPTH': 3,
|
'DEFAULT_MODEL_DEPTH': 3,
|
||||||
|
'SHOW_COMMON_EXTENSIONS': True,
|
||||||
'OAUTH2_REDIRECT_URL': None,
|
'OAUTH2_REDIRECT_URL': None,
|
||||||
'OAUTH2_CONFIG': {},
|
'OAUTH2_CONFIG': {},
|
||||||
'SUPPORTED_SUBMIT_METHODS': [
|
'SUPPORTED_SUBMIT_METHODS': [
|
||||||
|
|||||||
@@ -401,7 +401,6 @@ class OpenAPISchemaGenerator(object):
|
|||||||
"""
|
"""
|
||||||
parameters = []
|
parameters = []
|
||||||
queryset = getattr(view_cls, 'queryset', None)
|
queryset = getattr(view_cls, 'queryset', None)
|
||||||
model = getattr(getattr(view_cls, 'queryset', None), 'model', None)
|
|
||||||
|
|
||||||
for variable in sorted(uritemplate.variables(path)):
|
for variable in sorted(uritemplate.variables(path)):
|
||||||
model, model_field = get_queryset_field(queryset, variable)
|
model, model_field = get_queryset_field(queryset, variable)
|
||||||
|
|||||||
@@ -281,6 +281,10 @@ def find_limits(field):
|
|||||||
if attr not in limits or improves(limit_value, limits[attr]):
|
if attr not in limits or improves(limit_value, limits[attr]):
|
||||||
limits[attr] = limit_value
|
limits[attr] = limit_value
|
||||||
|
|
||||||
|
if hasattr(field, "allow_blank") and not field.allow_blank:
|
||||||
|
if limits.get('min_length', 0) < 1:
|
||||||
|
limits['min_length'] = 1
|
||||||
|
|
||||||
return OrderedDict(sorted(limits.items()))
|
return OrderedDict(sorted(limits.items()))
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ class SwaggerDict(OrderedDict):
|
|||||||
which would result in the extra attributes being added first. For this reason, we defer the insertion of the
|
which would result in the extra attributes being added first. For this reason, we defer the insertion of the
|
||||||
attributes and require that subclasses call ._insert_extras__ at the end of their __init__ method.
|
attributes and require that subclasses call ._insert_extras__ at the end of their __init__ method.
|
||||||
"""
|
"""
|
||||||
for attr, val in self._extras__.items():
|
for attr, val in sorted(self._extras__.items()):
|
||||||
setattr(self, attr, val)
|
setattr(self, attr, val)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|||||||
@@ -93,6 +93,7 @@ class _UIRenderer(BaseRenderer):
|
|||||||
'defaultModelRendering': swagger_settings.DEFAULT_MODEL_RENDERING,
|
'defaultModelRendering': swagger_settings.DEFAULT_MODEL_RENDERING,
|
||||||
'defaultModelExpandDepth': swagger_settings.DEFAULT_MODEL_DEPTH,
|
'defaultModelExpandDepth': swagger_settings.DEFAULT_MODEL_DEPTH,
|
||||||
'defaultModelsExpandDepth': swagger_settings.DEFAULT_MODEL_DEPTH,
|
'defaultModelsExpandDepth': swagger_settings.DEFAULT_MODEL_DEPTH,
|
||||||
|
'showCommonExtensions': swagger_settings.SHOW_COMMON_EXTENSIONS,
|
||||||
'oauth2RedirectUrl': swagger_settings.OAUTH2_REDIRECT_URL,
|
'oauth2RedirectUrl': swagger_settings.OAUTH2_REDIRECT_URL,
|
||||||
'supportedSubmitMethods': swagger_settings.SUPPORTED_SUBMIT_METHODS,
|
'supportedSubmitMethods': swagger_settings.SUPPORTED_SUBMIT_METHODS,
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -202,6 +202,7 @@ paths:
|
|||||||
type: string
|
type: string
|
||||||
pattern: ^69$
|
pattern: ^69$
|
||||||
default: '69'
|
default: '69'
|
||||||
|
minLength: 1
|
||||||
- name: image_styles
|
- name: image_styles
|
||||||
in: formData
|
in: formData
|
||||||
description: Parameter with Items
|
description: Parameter with Items
|
||||||
@@ -700,6 +701,7 @@ paths:
|
|||||||
description: this field is generated from a query_serializer
|
description: this field is generated from a query_serializer
|
||||||
required: false
|
required: false
|
||||||
type: string
|
type: string
|
||||||
|
minLength: 1
|
||||||
- name: is_staff
|
- name: is_staff
|
||||||
in: query
|
in: query
|
||||||
description: this one too!
|
description: this one too!
|
||||||
@@ -800,6 +802,7 @@ definitions:
|
|||||||
description: title model help_text
|
description: title model help_text
|
||||||
type: string
|
type: string
|
||||||
maxLength: 255
|
maxLength: 255
|
||||||
|
minLength: 1
|
||||||
author:
|
author:
|
||||||
description: The ID of the user that created this article; if none is provided,
|
description: The ID of the user that created this article; if none is provided,
|
||||||
defaults to the currently logged in user.
|
defaults to the currently logged in user.
|
||||||
@@ -809,6 +812,7 @@ definitions:
|
|||||||
description: body serializer help_text
|
description: body serializer help_text
|
||||||
type: string
|
type: string
|
||||||
maxLength: 5000
|
maxLength: 5000
|
||||||
|
minLength: 1
|
||||||
slug:
|
slug:
|
||||||
description: slug model help_text
|
description: slug model help_text
|
||||||
type: string
|
type: string
|
||||||
@@ -830,6 +834,7 @@ definitions:
|
|||||||
description: but i needed to test these 2 fields somehow
|
description: but i needed to test these 2 fields somehow
|
||||||
type: string
|
type: string
|
||||||
format: uri
|
format: uri
|
||||||
|
minLength: 1
|
||||||
readOnly: true
|
readOnly: true
|
||||||
uuid:
|
uuid:
|
||||||
description: should articles have UUIDs?
|
description: should articles have UUIDs?
|
||||||
@@ -872,10 +877,12 @@ definitions:
|
|||||||
title: FirstName
|
title: FirstName
|
||||||
type: string
|
type: string
|
||||||
maxLength: 30
|
maxLength: 30
|
||||||
|
minLength: 1
|
||||||
lastName:
|
lastName:
|
||||||
title: LastName
|
title: LastName
|
||||||
type: string
|
type: string
|
||||||
maxLength: 30
|
maxLength: 30
|
||||||
|
minLength: 1
|
||||||
Person:
|
Person:
|
||||||
required:
|
required:
|
||||||
- identity
|
- identity
|
||||||
@@ -897,10 +904,12 @@ definitions:
|
|||||||
title: Project name
|
title: Project name
|
||||||
description: Name of the project
|
description: Name of the project
|
||||||
type: string
|
type: string
|
||||||
|
minLength: 1
|
||||||
githubRepo:
|
githubRepo:
|
||||||
title: Github repo
|
title: Github repo
|
||||||
description: Github repository of the project
|
description: Github repository of the project
|
||||||
type: string
|
type: string
|
||||||
|
minLength: 1
|
||||||
Snippet:
|
Snippet:
|
||||||
required:
|
required:
|
||||||
- code
|
- code
|
||||||
@@ -922,6 +931,7 @@ definitions:
|
|||||||
description: The ID of the user that created this snippet.
|
description: The ID of the user that created this snippet.
|
||||||
type: string
|
type: string
|
||||||
readOnly: true
|
readOnly: true
|
||||||
|
minLength: 1
|
||||||
title: Owner as string
|
title: Owner as string
|
||||||
title:
|
title:
|
||||||
title: Title
|
title: Title
|
||||||
@@ -930,6 +940,7 @@ definitions:
|
|||||||
code:
|
code:
|
||||||
title: Code
|
title: Code
|
||||||
type: string
|
type: string
|
||||||
|
minLength: 1
|
||||||
linenos:
|
linenos:
|
||||||
title: Linenos
|
title: Linenos
|
||||||
type: boolean
|
type: boolean
|
||||||
@@ -1448,6 +1459,7 @@ definitions:
|
|||||||
title: Title
|
title: Title
|
||||||
type: string
|
type: string
|
||||||
maxLength: 50
|
maxLength: 50
|
||||||
|
minLength: 1
|
||||||
TodoAnother:
|
TodoAnother:
|
||||||
required:
|
required:
|
||||||
- title
|
- title
|
||||||
@@ -1458,6 +1470,7 @@ definitions:
|
|||||||
title: Title
|
title: Title
|
||||||
type: string
|
type: string
|
||||||
maxLength: 50
|
maxLength: 50
|
||||||
|
minLength: 1
|
||||||
todo:
|
todo:
|
||||||
$ref: '#/definitions/Todo'
|
$ref: '#/definitions/Todo'
|
||||||
TodoRecursive:
|
TodoRecursive:
|
||||||
@@ -1473,6 +1486,7 @@ definitions:
|
|||||||
title: Title
|
title: Title
|
||||||
type: string
|
type: string
|
||||||
maxLength: 50
|
maxLength: 50
|
||||||
|
minLength: 1
|
||||||
parent:
|
parent:
|
||||||
$ref: '#/definitions/TodoRecursive'
|
$ref: '#/definitions/TodoRecursive'
|
||||||
parent_id:
|
parent_id:
|
||||||
@@ -1492,6 +1506,7 @@ definitions:
|
|||||||
title: Title
|
title: Title
|
||||||
type: string
|
type: string
|
||||||
maxLength: 50
|
maxLength: 50
|
||||||
|
minLength: 1
|
||||||
children:
|
children:
|
||||||
type: array
|
type: array
|
||||||
items:
|
items:
|
||||||
@@ -1505,6 +1520,7 @@ definitions:
|
|||||||
title: Title
|
title: Title
|
||||||
type: string
|
type: string
|
||||||
maxLength: 50
|
maxLength: 50
|
||||||
|
minLength: 1
|
||||||
todo:
|
todo:
|
||||||
required:
|
required:
|
||||||
- title
|
- title
|
||||||
@@ -1518,6 +1534,7 @@ definitions:
|
|||||||
title: Title
|
title: Title
|
||||||
type: string
|
type: string
|
||||||
maxLength: 50
|
maxLength: 50
|
||||||
|
minLength: 1
|
||||||
todo:
|
todo:
|
||||||
required:
|
required:
|
||||||
- title
|
- title
|
||||||
@@ -1531,6 +1548,7 @@ definitions:
|
|||||||
title: Title
|
title: Title
|
||||||
type: string
|
type: string
|
||||||
maxLength: 50
|
maxLength: 50
|
||||||
|
minLength: 1
|
||||||
readOnly: true
|
readOnly: true
|
||||||
readOnly: true
|
readOnly: true
|
||||||
UserSerializerrr:
|
UserSerializerrr:
|
||||||
@@ -1551,6 +1569,7 @@ definitions:
|
|||||||
type: string
|
type: string
|
||||||
pattern: ^[\w.@+-]+$
|
pattern: ^[\w.@+-]+$
|
||||||
maxLength: 150
|
maxLength: 150
|
||||||
|
minLength: 1
|
||||||
email:
|
email:
|
||||||
title: Email address
|
title: Email address
|
||||||
type: string
|
type: string
|
||||||
@@ -1572,6 +1591,7 @@ definitions:
|
|||||||
type: string
|
type: string
|
||||||
format: ipv4
|
format: ipv4
|
||||||
readOnly: true
|
readOnly: true
|
||||||
|
minLength: 1
|
||||||
last_connected_at:
|
last_connected_at:
|
||||||
title: Last connected at
|
title: Last connected at
|
||||||
description: really?
|
description: really?
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
from collections import OrderedDict
|
||||||
|
from random import shuffle
|
||||||
|
|
||||||
from drf_yasg import openapi
|
from drf_yasg import openapi
|
||||||
|
|
||||||
|
|
||||||
@@ -51,3 +54,15 @@ def test_trailing_underscore_stripped():
|
|||||||
del sd.in_
|
del sd.in_
|
||||||
assert 'in' not in sd
|
assert 'in' not in sd
|
||||||
assert not hasattr(sd, 'in__')
|
assert not hasattr(sd, 'in__')
|
||||||
|
|
||||||
|
|
||||||
|
def test_extra_ordering():
|
||||||
|
"""Insertion order should also be consistent when setting undeclared parameters (kwargs) in SwaggerDict"""
|
||||||
|
extras = [('beta', 1), ('alpha', 2), ('omega', 3), ('gamma', 4)]
|
||||||
|
shuffled_extras = list(extras)
|
||||||
|
shuffle(shuffled_extras)
|
||||||
|
|
||||||
|
s1 = openapi.SwaggerDict(**OrderedDict(extras))
|
||||||
|
s2 = openapi.SwaggerDict(**OrderedDict(shuffled_extras))
|
||||||
|
|
||||||
|
assert list(s1.items()) == list(s2.items())
|
||||||
|
|||||||
Reference in New Issue
Block a user