Compare commits

...

6 Commits

Author SHA1 Message Date
Cristi Vîjdea 7065429d47 Remove python 2.7 + DRF 3.8 build from Travis CI jobs 2018-05-05 15:53:40 +03:00
Cristi Vîjdea bd727fbe88 Update swagger-ui to 3.14.1
Add settings key for ``showCommonExtensions``
2018-05-05 15:33:38 +03:00
Cristi Vîjdea 698a175a1b Remove python_requires from Django requirement
Fixes #113.
2018-05-02 20:30:09 +03:00
Fabian Weisshaar 5b225423ae Set min_length=1 when allow_blank=False (#112) 2018-04-27 13:02:26 +03:00
Cristi Vîjdea 209201b9a5 Make insertion order of SwaggerDict extra parameters consistent 2018-04-27 12:12:36 +03:00
Cristi Vîjdea ca00ed35be Install pytest-django from PyPI 2018-04-27 12:04:20 +03:00
17 changed files with 560 additions and 461 deletions
+3 -1
View File
@@ -2,7 +2,6 @@ language: python
cache: pip
python:
- '2.7'
- '3.4'
- '3.5'
- '3.6'
@@ -14,6 +13,9 @@ env:
jobs:
include:
- stage: test
python: '2.7'
env: DRF=3.7
-
python: '3.6'
env: DRF=master
-
+10
View File
@@ -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**
*********
+9
View File
@@ -255,6 +255,15 @@ Controls how many levels are expaned by default when showing nested models.
**Default**: :python:`3` |br|
*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_REDIRECT_URL
+414 -414
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -2,7 +2,7 @@
"name": "drf-yasg",
"dependencies": {
"redoc": "^2.0.0-alpha.17",
"swagger-ui-dist": "^3.13.6"
"swagger-ui-dist": "^3.14.1"
},
"repository": {
"type": "git",
+1 -2
View File
@@ -8,5 +8,4 @@ six>=1.10.0
uritemplate>=3.0.0
djangorestframework>=3.7.7
Django>=1.11.7,<2.0; python_version <= "2.7"
Django>=1.11.7; python_version >= "3.4"
Django>=1.11.7
+1 -2
View File
@@ -3,8 +3,7 @@ pytest>=2.9
pytest-pythonpath>=0.7.1
pytest-cov>=2.5.1
pytest-xdist>=1.22.0
# latest pip version of pytest-django is more than a year old and does not support Django 2.0
git+https://github.com/pytest-dev/pytest-django.git@94cccb956435dd7a719606744ee7608397e1eafb
pytest-django>=3.2.0
datadiff==2.0.0
-r testproj.txt
+1
View File
@@ -45,6 +45,7 @@ SWAGGER_DEFAULTS = {
'SHOW_EXTENSIONS': True,
'DEFAULT_MODEL_RENDERING': 'model',
'DEFAULT_MODEL_DEPTH': 3,
'SHOW_COMMON_EXTENSIONS': True,
'OAUTH2_REDIRECT_URL': None,
'OAUTH2_CONFIG': {},
'SUPPORTED_SUBMIT_METHODS': [
-1
View File
@@ -401,7 +401,6 @@ class OpenAPISchemaGenerator(object):
"""
parameters = []
queryset = getattr(view_cls, 'queryset', None)
model = getattr(getattr(view_cls, 'queryset', None), 'model', None)
for variable in sorted(uritemplate.variables(path)):
model, model_field = get_queryset_field(queryset, variable)
+4
View File
@@ -281,6 +281,10 @@ def find_limits(field):
if attr not in limits or improves(limit_value, limits[attr]):
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()))
+1 -1
View File
@@ -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
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)
@staticmethod
+1
View File
@@ -93,6 +93,7 @@ class _UIRenderer(BaseRenderer):
'defaultModelRendering': swagger_settings.DEFAULT_MODEL_RENDERING,
'defaultModelExpandDepth': swagger_settings.DEFAULT_MODEL_DEPTH,
'defaultModelsExpandDepth': swagger_settings.DEFAULT_MODEL_DEPTH,
'showCommonExtensions': swagger_settings.SHOW_COMMON_EXTENSIONS,
'oauth2RedirectUrl': swagger_settings.OAUTH2_REDIRECT_URL,
'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
+20
View File
@@ -202,6 +202,7 @@ paths:
type: string
pattern: ^69$
default: '69'
minLength: 1
- name: image_styles
in: formData
description: Parameter with Items
@@ -700,6 +701,7 @@ paths:
description: this field is generated from a query_serializer
required: false
type: string
minLength: 1
- name: is_staff
in: query
description: this one too!
@@ -800,6 +802,7 @@ definitions:
description: title model help_text
type: string
maxLength: 255
minLength: 1
author:
description: The ID of the user that created this article; if none is provided,
defaults to the currently logged in user.
@@ -809,6 +812,7 @@ definitions:
description: body serializer help_text
type: string
maxLength: 5000
minLength: 1
slug:
description: slug model help_text
type: string
@@ -830,6 +834,7 @@ definitions:
description: but i needed to test these 2 fields somehow
type: string
format: uri
minLength: 1
readOnly: true
uuid:
description: should articles have UUIDs?
@@ -872,10 +877,12 @@ definitions:
title: FirstName
type: string
maxLength: 30
minLength: 1
lastName:
title: LastName
type: string
maxLength: 30
minLength: 1
Person:
required:
- identity
@@ -897,10 +904,12 @@ definitions:
title: Project name
description: Name of the project
type: string
minLength: 1
githubRepo:
title: Github repo
description: Github repository of the project
type: string
minLength: 1
Snippet:
required:
- code
@@ -922,6 +931,7 @@ definitions:
description: The ID of the user that created this snippet.
type: string
readOnly: true
minLength: 1
title: Owner as string
title:
title: Title
@@ -930,6 +940,7 @@ definitions:
code:
title: Code
type: string
minLength: 1
linenos:
title: Linenos
type: boolean
@@ -1448,6 +1459,7 @@ definitions:
title: Title
type: string
maxLength: 50
minLength: 1
TodoAnother:
required:
- title
@@ -1458,6 +1470,7 @@ definitions:
title: Title
type: string
maxLength: 50
minLength: 1
todo:
$ref: '#/definitions/Todo'
TodoRecursive:
@@ -1473,6 +1486,7 @@ definitions:
title: Title
type: string
maxLength: 50
minLength: 1
parent:
$ref: '#/definitions/TodoRecursive'
parent_id:
@@ -1492,6 +1506,7 @@ definitions:
title: Title
type: string
maxLength: 50
minLength: 1
children:
type: array
items:
@@ -1505,6 +1520,7 @@ definitions:
title: Title
type: string
maxLength: 50
minLength: 1
todo:
required:
- title
@@ -1518,6 +1534,7 @@ definitions:
title: Title
type: string
maxLength: 50
minLength: 1
todo:
required:
- title
@@ -1531,6 +1548,7 @@ definitions:
title: Title
type: string
maxLength: 50
minLength: 1
readOnly: true
readOnly: true
UserSerializerrr:
@@ -1551,6 +1569,7 @@ definitions:
type: string
pattern: ^[\w.@+-]+$
maxLength: 150
minLength: 1
email:
title: Email address
type: string
@@ -1572,6 +1591,7 @@ definitions:
type: string
format: ipv4
readOnly: true
minLength: 1
last_connected_at:
title: Last connected at
description: really?
+15
View File
@@ -1,3 +1,6 @@
from collections import OrderedDict
from random import shuffle
from drf_yasg import openapi
@@ -51,3 +54,15 @@ def test_trailing_underscore_stripped():
del sd.in_
assert 'in' not in sd
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())