Merge pull request #204 from axnsan12/release-1.10.1
Lotsa fixes. Sorry for the long time no see 😄
openapi3
commit
10abf46597
|
|
@ -16,7 +16,11 @@
|
|||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/testproj" isTestSource="false" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/.pytest_cache" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/dist" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/docs/_build" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/htmlcov" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/src/drf_yasg.egg-info" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/venv" />
|
||||
</content>
|
||||
<orderEntry type="jdk" jdkName="Python 3 (drf-yasg)" jdkType="Python SDK" />
|
||||
|
|
|
|||
|
|
@ -3,6 +3,24 @@ Changelog
|
|||
#########
|
||||
|
||||
|
||||
**********
|
||||
**1.10.1**
|
||||
**********
|
||||
|
||||
*Release date: Sep 10, 2018*
|
||||
|
||||
- **ADDED:** added the ``SPEC_URL`` setting for controlling the download link in ``swagger-ui`` and ``ReDoc``
|
||||
- **IMPROVED:** updated ``swagger-ui`` to version 3.18.2
|
||||
- **IMPROVED:** updated ``ReDoc`` to version 2.0.0-alpha.37
|
||||
- **FIXED:** stopped generating invalid OpenAPI by improper placement of ``readOnly`` Schemas
|
||||
- **FIXED:** fixed broken CSS when ``USE_SESSION_AUTH=False``
|
||||
- **FIXED:** fixed implementation of ``operation_summary`` and ``deprecated`` (:pr:`194`, :pr:`198`)
|
||||
- **FIXED:** fixed a bug related to nested ``typing`` hints (:pr:`195`)
|
||||
- **FIXED:** removed dependency on ``future`` (:issue:`196`)
|
||||
- **FIXED:** removed exceptions loged for fields with ``default=None`` (:issue:`203`)
|
||||
- **FIXED:** fixed ``request_body=no_body`` handling and related tests (:issue:`188`, :issue:`199`)
|
||||
|
||||
|
||||
**********
|
||||
**1.10.0**
|
||||
**********
|
||||
|
|
|
|||
|
|
@ -22,9 +22,9 @@
|
|||
"integrity": "sha512-ccav/yGvoa80BQDljCxsmmQ3Xvx60/UpBIij5QN21W3wBi/hhIC9OoO+KLpu9IJTS9j4DRVJ3aDDF9cMSoa2lw=="
|
||||
},
|
||||
"buffer": {
|
||||
"version": "5.2.0",
|
||||
"resolved": "https://registry.npmjs.org/buffer/-/buffer-5.2.0.tgz",
|
||||
"integrity": "sha512-nUJyfChH7PMJy75eRDCCKtszSEFokUNXC1hNVSe+o+VdcgvDPLs20k3v8UXI8ruRYAJiYtyRea8mYyqPxoHWDw==",
|
||||
"version": "5.2.1",
|
||||
"resolved": "https://registry.npmjs.org/buffer/-/buffer-5.2.1.tgz",
|
||||
"integrity": "sha512-c+Ko0loDaFfuPWiL02ls9Xd3GO3cPVmUobQ6t3rXNUk304u6hGq+8N/kFi+QEIKhzK3uwolVhLzszmfLmMLnqg==",
|
||||
"requires": {
|
||||
"base64-js": "^1.0.2",
|
||||
"ieee754": "^1.1.4"
|
||||
|
|
@ -96,9 +96,9 @@
|
|||
"integrity": "sha1-ZyIm3HTI95mtNTB9+TaroRrNYBg="
|
||||
},
|
||||
"dompurify": {
|
||||
"version": "1.0.7",
|
||||
"resolved": "https://registry.npmjs.org/dompurify/-/dompurify-1.0.7.tgz",
|
||||
"integrity": "sha512-1xK0JEda/jvIm3SgqHXKvRCh3AbEKCyBbUAGpNCMVIljBD145cPvBR66JSj3O4SdscFUx5NXsDkJpz6vDT8KLg=="
|
||||
"version": "1.0.8",
|
||||
"resolved": "https://registry.npmjs.org/dompurify/-/dompurify-1.0.8.tgz",
|
||||
"integrity": "sha512-vetRFbN1SXSPfP3ClIiYnxTrXquSqakBEOoB5JESn0SVcSYzpu6ougjakpKnskGctYdlNpwf+riUHSkG7d4XUw=="
|
||||
},
|
||||
"encoding": {
|
||||
"version": "0.1.12",
|
||||
|
|
@ -176,9 +176,9 @@
|
|||
"integrity": "sha512-rqcy4pJo55FTTLWt+bU8ukscqHeE/e9KWvsOW2b/a3afxQZhwkQdT1rPPCJ0rYXdj4vNcasY8zHTH+jF/qStxw=="
|
||||
},
|
||||
"iconv-lite": {
|
||||
"version": "0.4.23",
|
||||
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.23.tgz",
|
||||
"integrity": "sha512-neyTUVFtahjf0mB3dZT77u+8O0QB89jFdnBkd5P1JgYPbPaia3gXXOVL2fq8VyU2gMMD7SaN7QukTB/pmXYvDA==",
|
||||
"version": "0.4.24",
|
||||
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz",
|
||||
"integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==",
|
||||
"requires": {
|
||||
"safer-buffer": ">= 2.1.2 < 3"
|
||||
}
|
||||
|
|
@ -225,14 +225,14 @@
|
|||
}
|
||||
},
|
||||
"json-schema-ref-parser": {
|
||||
"version": "5.1.2",
|
||||
"resolved": "https://registry.npmjs.org/json-schema-ref-parser/-/json-schema-ref-parser-5.1.2.tgz",
|
||||
"integrity": "sha512-gP0mSqqkG99xNeA4F6bf2pXQYv5fFqe9SybbKO9qSMmyzzfFFIqd16s9Y65mRWKzZ0muTjyEtcSE/hLZLvIjZw==",
|
||||
"version": "5.1.3",
|
||||
"resolved": "https://registry.npmjs.org/json-schema-ref-parser/-/json-schema-ref-parser-5.1.3.tgz",
|
||||
"integrity": "sha512-CpDFlBwz/6la78hZxyB9FECVKGYjIIl3Ms3KLqFj99W7IIb7D00/RDgc++IGB4BBALl0QRhh5m4q5WNSopvLtQ==",
|
||||
"requires": {
|
||||
"call-me-maybe": "^1.0.1",
|
||||
"debug": "^3.1.0",
|
||||
"js-yaml": "^3.12.0",
|
||||
"ono": "^4.0.5"
|
||||
"ono": "^4.0.6"
|
||||
}
|
||||
},
|
||||
"loose-envify": {
|
||||
|
|
@ -244,9 +244,9 @@
|
|||
}
|
||||
},
|
||||
"lunr": {
|
||||
"version": "2.3.1",
|
||||
"resolved": "https://registry.npmjs.org/lunr/-/lunr-2.3.1.tgz",
|
||||
"integrity": "sha1-ETYWorYC3cEJMqe/ik5uV+v+zfI="
|
||||
"version": "2.3.3",
|
||||
"resolved": "https://registry.npmjs.org/lunr/-/lunr-2.3.3.tgz",
|
||||
"integrity": "sha512-rlAEsgU9Bnavca2w1WJ6+6cdeHMXNyadcersyk3ZpuhgWb5HBNj8l4WwJz9PjksAhYDlpQffCVXPctOn+wCIVA=="
|
||||
},
|
||||
"mark.js": {
|
||||
"version": "8.11.1",
|
||||
|
|
@ -259,9 +259,9 @@
|
|||
"integrity": "sha512-49i2QYhfULqaXzNZpxC808PisuCTGT2fgG0zrzdCI9N3rIfAWfW0nggvbXr6zvpynZdOG5+9xNxdzP0kwZnERw=="
|
||||
},
|
||||
"memoize-one": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/memoize-one/-/memoize-one-4.0.0.tgz",
|
||||
"integrity": "sha512-wdpOJ4XBejprGn/xhd1i2XR8Dv1A25FJeIvR7syQhQlz9eXsv+06llcvcmBxlWVGv4C73QBsWA8kxvZozzNwiQ=="
|
||||
"version": "4.0.2",
|
||||
"resolved": "https://registry.npmjs.org/memoize-one/-/memoize-one-4.0.2.tgz",
|
||||
"integrity": "sha512-ucx2DmXTeZTsS4GPPUZCbULAN7kdPT1G+H49Y34JjbQ5ESc6OGhVxKvb1iKhr9v19ZB9OtnHwNnhUnNR/7Wteg=="
|
||||
},
|
||||
"min-document": {
|
||||
"version": "2.19.0",
|
||||
|
|
@ -272,9 +272,9 @@
|
|||
}
|
||||
},
|
||||
"mobx-react": {
|
||||
"version": "5.2.3",
|
||||
"resolved": "https://registry.npmjs.org/mobx-react/-/mobx-react-5.2.3.tgz",
|
||||
"integrity": "sha512-OuSlF2nJEa1PGookZcZnINbvEK4iWNNYiqUh6aebk2AkWxj3sG8OafDOQMcMYApQALTHRsrBIjOx/K8TFxcz7w==",
|
||||
"version": "5.2.6",
|
||||
"resolved": "https://registry.npmjs.org/mobx-react/-/mobx-react-5.2.6.tgz",
|
||||
"integrity": "sha512-AGo3m/ICzN2SEbtNi8ZdF1ShDcAOnEKonZFc3mm8uuF2obDXg6rXqV5mtkr9ZHPYizGp51kT/vRg0TlGzok+CA==",
|
||||
"requires": {
|
||||
"hoist-non-react-statics": "^2.5.0",
|
||||
"react-lifecycles-compat": "^3.0.2"
|
||||
|
|
@ -300,17 +300,17 @@
|
|||
"integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM="
|
||||
},
|
||||
"ono": {
|
||||
"version": "4.0.5",
|
||||
"resolved": "https://registry.npmjs.org/ono/-/ono-4.0.5.tgz",
|
||||
"integrity": "sha512-ZVNuV9kJbr/2tWs83I2snrYo+WIS0DISF/xUfX9p9b6GyDD6F5N9PzHjW+p/dep6IGwSYylf1HCub5I/nM0R5Q==",
|
||||
"version": "4.0.7",
|
||||
"resolved": "https://registry.npmjs.org/ono/-/ono-4.0.7.tgz",
|
||||
"integrity": "sha512-FJiGEETwfSVyOwVTwQZD7XN69FRekvgtlobtvPwtilc7PxIHg3gKUykdNP7E9mC/VTF2cxqKZxUZfNKA3MuQLA==",
|
||||
"requires": {
|
||||
"format-util": "^1.0.3"
|
||||
}
|
||||
},
|
||||
"openapi-sampler": {
|
||||
"version": "1.0.0-beta.13",
|
||||
"resolved": "https://registry.npmjs.org/openapi-sampler/-/openapi-sampler-1.0.0-beta.13.tgz",
|
||||
"integrity": "sha512-NReKJh92NlUmY9CDo86L1Skkx3DMDeWmiLoqMxQSX7xBpoSx8WJ1JdTb7nEwz6M7S+WDPrQsEfS5BaIW27nMrQ==",
|
||||
"version": "1.0.0-beta.14",
|
||||
"resolved": "https://registry.npmjs.org/openapi-sampler/-/openapi-sampler-1.0.0-beta.14.tgz",
|
||||
"integrity": "sha512-NNmH9YAN5AaCE4w6MQXdCrmsOJJQTswHVSp075+h+iiG+OTonpZE8HzwocozovD2imx4lamkuxGLs4E4bO4Z+g==",
|
||||
"requires": {
|
||||
"json-pointer": "^0.6.0"
|
||||
}
|
||||
|
|
@ -361,17 +361,17 @@
|
|||
}
|
||||
},
|
||||
"react-dropdown": {
|
||||
"version": "1.5.0",
|
||||
"resolved": "https://registry.npmjs.org/react-dropdown/-/react-dropdown-1.5.0.tgz",
|
||||
"integrity": "sha512-rRv3a7NiP++yC1rzdjzkviC5ujq759i4SRa0M3C0Cr7loYT4Z3+JhSPekv1/04JiZNXX46cV3/g6A9kS7rkI4Q==",
|
||||
"version": "1.6.2",
|
||||
"resolved": "https://registry.npmjs.org/react-dropdown/-/react-dropdown-1.6.2.tgz",
|
||||
"integrity": "sha512-6RpKAFEVZLr53y91qnxC9rAWcoDvq8A9YstmeSV2AQgJxNFRcsreN1mJNRUctSvIwm0Hph07ouMvDc2GvfQBsA==",
|
||||
"requires": {
|
||||
"classnames": "^2.2.3"
|
||||
}
|
||||
},
|
||||
"react-hot-loader": {
|
||||
"version": "4.3.4",
|
||||
"resolved": "https://registry.npmjs.org/react-hot-loader/-/react-hot-loader-4.3.4.tgz",
|
||||
"integrity": "sha512-LlKjtHq+RhDq9xm6crXojbkzrEvli5F4/RaeJ//XtDWrwwsAHDjEqKfZZiPCxv7gWV2cxE3YE8TXeE9BDzLqOA==",
|
||||
"version": "4.3.6",
|
||||
"resolved": "https://registry.npmjs.org/react-hot-loader/-/react-hot-loader-4.3.6.tgz",
|
||||
"integrity": "sha512-iuBeBkLz7tdkKmKduNww9o5JY4ZH1XI0TWwkWToHIqfOSh1xMCqLMSYXUasWfgZWykWWa9IkueYab+cDq2jyWg==",
|
||||
"requires": {
|
||||
"fast-levenshtein": "^2.0.6",
|
||||
"global": "^4.3.0",
|
||||
|
|
@ -382,9 +382,9 @@
|
|||
}
|
||||
},
|
||||
"react-is": {
|
||||
"version": "16.4.2",
|
||||
"resolved": "https://registry.npmjs.org/react-is/-/react-is-16.4.2.tgz",
|
||||
"integrity": "sha512-rI3cGFj/obHbBz156PvErrS5xc6f1eWyTwyV4mo0vF2lGgXgS+mm7EKD5buLJq6jNgIagQescGSVG2YzgXt8Yg=="
|
||||
"version": "16.5.0",
|
||||
"resolved": "https://registry.npmjs.org/react-is/-/react-is-16.5.0.tgz",
|
||||
"integrity": "sha512-kpkCGLsChXTEQJVmowQqHpCjHKJFwB4SIChYaaaiAkq8OtE2aBg5pQe8/xnFlGmz9KmMx1H4oQRUyxP7qC9v5A=="
|
||||
},
|
||||
"react-lifecycles-compat": {
|
||||
"version": "3.0.4",
|
||||
|
|
@ -392,41 +392,41 @@
|
|||
"integrity": "sha512-fBASbA6LnOU9dOU2eW7aQ8xmYBSXUIWr+UmF9b1efZBazGNO+rcXT/icdKnYm2pTwcRylVUYwW7H1PHfLekVzA=="
|
||||
},
|
||||
"react-tabs": {
|
||||
"version": "2.2.2",
|
||||
"resolved": "https://registry.npmjs.org/react-tabs/-/react-tabs-2.2.2.tgz",
|
||||
"integrity": "sha512-jZGAAoq1yknr/XF60/2kH5X3UJdR1X8ItcsLZ1mJnHfoniKcCr3shT2TK5wiS2sO0LOmqwX2BtJQX3snKd50sg==",
|
||||
"version": "2.3.0",
|
||||
"resolved": "https://registry.npmjs.org/react-tabs/-/react-tabs-2.3.0.tgz",
|
||||
"integrity": "sha512-pYaefgVy76/36AMEP+B8YuVVzDHa3C5UFZ3REU78zolk0qMxEhKvUFofvDCXyLZwf0RZjxIfiwok1BEb18nHyA==",
|
||||
"requires": {
|
||||
"classnames": "^2.2.0",
|
||||
"prop-types": "^15.5.0"
|
||||
}
|
||||
},
|
||||
"redoc": {
|
||||
"version": "2.0.0-alpha.34",
|
||||
"resolved": "https://registry.npmjs.org/redoc/-/redoc-2.0.0-alpha.34.tgz",
|
||||
"integrity": "sha512-2ElniTCVdsIlU13gOwT2Aa5UEZyLU3bOkDfXbVA1H0E0LsSbZvt6h1k4vEvo6shXzsQtV2eDCn1+v21QTClWfA==",
|
||||
"version": "2.0.0-alpha.37",
|
||||
"resolved": "https://registry.npmjs.org/redoc/-/redoc-2.0.0-alpha.37.tgz",
|
||||
"integrity": "sha512-yuT8sTT+oNzg8G9PfsUhu8Jhd9rWYJCTSQnbgaq9KzAFcJ2O0XfvlstkGXDK1zmtSSBBe5cy9Z/1XcQGDiGYug==",
|
||||
"requires": {
|
||||
"classnames": "^2.2.6",
|
||||
"decko": "^1.2.0",
|
||||
"dompurify": "^1.0.6",
|
||||
"dompurify": "^1.0.7",
|
||||
"eventemitter3": "^3.0.0",
|
||||
"json-pointer": "^0.6.0",
|
||||
"json-schema-ref-parser": "^5.1.1",
|
||||
"lunr": "^2.3.0",
|
||||
"json-schema-ref-parser": "^5.1.2",
|
||||
"lunr": "^2.3.2",
|
||||
"mark.js": "^8.11.1",
|
||||
"marked": "0.3.18",
|
||||
"memoize-one": "^4.0.0",
|
||||
"mobx-react": "^5.2.3",
|
||||
"openapi-sampler": "1.0.0-beta.13",
|
||||
"mobx-react": "^5.2.5",
|
||||
"openapi-sampler": "1.0.0-beta.14",
|
||||
"perfect-scrollbar": "^1.4.0",
|
||||
"polished": "^1.9.3",
|
||||
"prismjs": "^1.15.0",
|
||||
"prop-types": "^15.6.2",
|
||||
"react-dropdown": "^1.3.0",
|
||||
"react-hot-loader": "^4.3.3",
|
||||
"react-dropdown": "^1.6.1",
|
||||
"react-hot-loader": "^4.3.4",
|
||||
"react-tabs": "^2.0.0",
|
||||
"slugify": "^1.2.1",
|
||||
"slugify": "^1.3.1",
|
||||
"stickyfill": "^1.1.1",
|
||||
"styled-components": "^3.3.3",
|
||||
"styled-components": "^3.4.2",
|
||||
"tslib": "^1.9.3"
|
||||
}
|
||||
},
|
||||
|
|
@ -467,9 +467,9 @@
|
|||
"integrity": "sha1-OUE/7p0CXHSn5ZzuyyN4TMDxfwI="
|
||||
},
|
||||
"styled-components": {
|
||||
"version": "3.4.2",
|
||||
"resolved": "https://registry.npmjs.org/styled-components/-/styled-components-3.4.2.tgz",
|
||||
"integrity": "sha512-eTmIiWstyDLccHZAyp+aCPirlkTvYiHlYGgWQxOYDv8Ko0o6mfnDo0+DnUnKinO8NzAfQXEDP7Bh0qlazwJgrw==",
|
||||
"version": "3.4.5",
|
||||
"resolved": "https://registry.npmjs.org/styled-components/-/styled-components-3.4.5.tgz",
|
||||
"integrity": "sha512-/4c4/72+QAZ8LO+VIzTcitdjMcJleOln1laK9HZr166O+OmGpKZYt3+hRn0YhYPytwDGfx9J5c7WhU7Oys+nSw==",
|
||||
"requires": {
|
||||
"buffer": "^5.0.3",
|
||||
"css-to-react-native": "^2.0.3",
|
||||
|
|
@ -501,9 +501,9 @@
|
|||
}
|
||||
},
|
||||
"swagger-ui-dist": {
|
||||
"version": "3.18.0",
|
||||
"resolved": "https://registry.npmjs.org/swagger-ui-dist/-/swagger-ui-dist-3.18.0.tgz",
|
||||
"integrity": "sha512-AwFwmd9pf4XJb/IwLvpZ6Bl6wDhjidwjgBiqGv3/kXHp1hbVWi5ZKGSwKjdJ9att6MDJFhgp0+Dvd/Zqb7uySA=="
|
||||
"version": "3.18.2",
|
||||
"resolved": "https://registry.npmjs.org/swagger-ui-dist/-/swagger-ui-dist-3.18.2.tgz",
|
||||
"integrity": "sha512-pWAEiKkgWUJvjmLW9AojudnutJ+NTn5g6OdNLj1iIJWwCkoy40K3Upwa24DqFbmIE4vLX4XplND61hp2L+s5vg=="
|
||||
},
|
||||
"tiny-emitter": {
|
||||
"version": "2.0.2",
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
{
|
||||
"name": "drf-yasg",
|
||||
"dependencies": {
|
||||
"redoc": "^2.0.0-alpha.34",
|
||||
"swagger-ui-dist": "^3.18.0"
|
||||
"redoc": "^2.0.0-alpha.37",
|
||||
"swagger-ui-dist": "^3.18.2"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ coreapi>=2.3.3
|
|||
coreschema>=0.0.4
|
||||
ruamel.yaml>=0.15.34
|
||||
inflection>=0.3.1
|
||||
future>=0.16.0
|
||||
six>=1.10.0
|
||||
uritemplate>=3.0.0
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
from future.utils import raise_from
|
||||
from six import raise_from
|
||||
|
||||
import copy
|
||||
import json
|
||||
|
|
|
|||
|
|
@ -134,7 +134,7 @@ class EndpointEnumerator(_EndpointEnumerator):
|
|||
"""Remove backslashe escapes from all path components outside {parameters}. This is needed because
|
||||
``simplify_regex`` does not handle this correctly - note however that this implementation is
|
||||
|
||||
**NOTE:** this might destructively affect some url regex patterns that contain metacharacters (e.g. \w, \d)
|
||||
**NOTE:** this might destructively affect some url regex patterns that contain metacharacters (e.g. \\w, \\d)
|
||||
outside path parameter groups; if you are in this category, God help you
|
||||
|
||||
:param str path: path possibly containing
|
||||
|
|
|
|||
|
|
@ -258,7 +258,7 @@ class SerializerInspector(FieldInspector):
|
|||
return NotHandled
|
||||
|
||||
def get_request_parameters(self, serializer, in_):
|
||||
"""Convert a DRF serializer into a list of :class:`.Parameter`\ s.
|
||||
"""Convert a DRF serializer into a list of :class:`.Parameter`\\ s.
|
||||
|
||||
Should return :data:`.NotHandled` if this inspector does not know how to handle the given `serializer`.
|
||||
|
||||
|
|
@ -372,7 +372,7 @@ class ViewInspector(BaseInspector):
|
|||
)
|
||||
|
||||
def serializer_to_parameters(self, serializer, in_):
|
||||
"""Convert a serializer to a possibly empty list of :class:`.Parameter`\ s.
|
||||
"""Convert a serializer to a possibly empty list of :class:`.Parameter`\\ s.
|
||||
|
||||
:param serializers.BaseSerializer serializer: the ``Serializer`` instance
|
||||
:param str in_: the location of the parameters, one of the `openapi.IN_*` constants
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import operator
|
|||
import uuid
|
||||
from collections import OrderedDict
|
||||
from decimal import Decimal
|
||||
from inspect import isclass
|
||||
|
||||
from django.core import validators
|
||||
from django.db import models
|
||||
|
|
@ -196,7 +197,7 @@ def get_related_model(model, source):
|
|||
|
||||
|
||||
class RelatedFieldInspector(FieldInspector):
|
||||
"""Provides conversions for ``RelatedField``\ s."""
|
||||
"""Provides conversions for ``RelatedField``\\ s."""
|
||||
|
||||
def field_to_swagger_object(self, field, swagger_object_type, use_references, **kwargs):
|
||||
SwaggerType, ChildSwaggerType = self._get_partial_types(field, swagger_object_type, use_references, **kwargs)
|
||||
|
|
@ -261,7 +262,12 @@ def find_regex(regex_field):
|
|||
regex_validator = validator
|
||||
|
||||
# regex_validator.regex should be a compiled re object...
|
||||
pattern = getattr(getattr(regex_validator, 'regex', None), 'pattern', None)
|
||||
try:
|
||||
pattern = getattr(getattr(regex_validator, 'regex', None), 'pattern', None)
|
||||
except Exception: # pragma: no cover
|
||||
logger.warning('failed to compile regex validator of ' + str(regex_field), exc_info=True)
|
||||
return None
|
||||
|
||||
if pattern:
|
||||
# attempt some basic cleanup to remove regex constructs not supported by JavaScript
|
||||
# -- swagger uses javascript-style regexes - see https://github.com/swagger-api/swagger-editor/issues/1601
|
||||
|
|
@ -511,7 +517,9 @@ class SerializerMethodFieldInspector(FieldInspector):
|
|||
# look for Python 3.5+ style type hinting of the return value
|
||||
hint_class = inspect.signature(method).return_annotation
|
||||
|
||||
if not issubclass(hint_class, inspect._empty):
|
||||
if not isclass(hint_class) and hasattr(hint_class, '__args__'):
|
||||
hint_class = hint_class.__args__[0]
|
||||
if isclass(hint_class) and not issubclass(hint_class, inspect._empty):
|
||||
type_info = get_basic_type_info_from_hint(hint_class)
|
||||
|
||||
if type_info is not None:
|
||||
|
|
@ -570,7 +578,7 @@ class ChoiceFieldInspector(FieldInspector):
|
|||
|
||||
|
||||
class FileFieldInspector(FieldInspector):
|
||||
"""Provides conversions for ``FileField``\ s."""
|
||||
"""Provides conversions for ``FileField``\\ s."""
|
||||
|
||||
def field_to_swagger_object(self, field, swagger_object_type, use_references, **kwargs):
|
||||
SwaggerType, ChildSwaggerType = self._get_partial_types(field, swagger_object_type, use_references, **kwargs)
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ from .base import FilterInspector, PaginatorInspector
|
|||
|
||||
|
||||
class CoreAPICompatInspector(PaginatorInspector, FilterInspector):
|
||||
"""Converts ``coreapi.Field``\ s to :class:`.openapi.Parameter`\ s for filters and paginators that implement a
|
||||
"""Converts ``coreapi.Field``\\ s to :class:`.openapi.Parameter`\\ s for filters and paginators that implement a
|
||||
``get_schema_fields`` method.
|
||||
"""
|
||||
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ class SwaggerAutoSchema(ViewInspector):
|
|||
- a list of primitive Parameters parsed as form data
|
||||
|
||||
:param list[str] consumes: a list of accepted MIME types as returned by :meth:`.get_consumes`
|
||||
:return: a (potentially empty) list of :class:`.Parameter`\ s either ``in: body`` or ``in: formData``
|
||||
:return: a (potentially empty) list of :class:`.Parameter`\\ s either ``in: body`` or ``in: formData``
|
||||
:rtype: list[openapi.Parameter]
|
||||
"""
|
||||
serializer = self.get_request_serializer()
|
||||
|
|
@ -106,7 +106,7 @@ class SwaggerAutoSchema(ViewInspector):
|
|||
|
||||
if body_override is not None:
|
||||
if body_override is no_body:
|
||||
return None
|
||||
return no_body
|
||||
if self.method not in self.body_methods:
|
||||
raise SwaggerGenerationError("request_body can only be applied to (" + ','.join(self.body_methods) +
|
||||
"); are you looking for query_serializer or manual_parameters?")
|
||||
|
|
@ -126,10 +126,13 @@ class SwaggerAutoSchema(ViewInspector):
|
|||
if body_override is None and self.method in self.implicit_body_methods:
|
||||
return self.get_view_serializer()
|
||||
|
||||
if body_override is no_body:
|
||||
return None
|
||||
|
||||
return body_override
|
||||
|
||||
def get_request_form_parameters(self, serializer):
|
||||
"""Given a Serializer, return a list of ``in: formData`` :class:`.Parameter`\ s.
|
||||
"""Given a Serializer, return a list of ``in: formData`` :class:`.Parameter`\\ s.
|
||||
|
||||
:param serializer: the view's request serializer as returned by :meth:`.get_request_serializer`
|
||||
:rtype: list[openapi.Parameter]
|
||||
|
|
@ -192,7 +195,11 @@ class SwaggerAutoSchema(ViewInspector):
|
|||
|
||||
:return: response serializer, :class:`.Schema`, :class:`.SchemaRef`, ``None``
|
||||
"""
|
||||
return self._get_request_body_override() or self.get_view_serializer()
|
||||
body_override = self._get_request_body_override()
|
||||
if body_override and body_override is not no_body:
|
||||
return body_override
|
||||
|
||||
return self.get_view_serializer()
|
||||
|
||||
def get_default_responses(self):
|
||||
"""Get the default responses determined for this view from the request serializer and request method.
|
||||
|
|
@ -207,8 +214,6 @@ class SwaggerAutoSchema(ViewInspector):
|
|||
default_schema = self.get_default_response_serializer()
|
||||
|
||||
default_schema = default_schema or ''
|
||||
if any(is_form_media_type(encoding) for encoding in self.get_consumes()):
|
||||
default_schema = ''
|
||||
if default_schema and not isinstance(default_schema, openapi.Schema):
|
||||
default_schema = self.serializer_to_schema(default_schema) or ''
|
||||
|
||||
|
|
@ -223,7 +228,7 @@ class SwaggerAutoSchema(ViewInspector):
|
|||
def get_response_serializers(self):
|
||||
"""Return the response codes that this view is expected to return, and the serializer for each response body.
|
||||
The return value should be a dict where the keys are possible status codes, and values are either strings,
|
||||
``Serializer``\ s, :class:`.Schema`, :class:`.SchemaRef` or :class:`.Response` objects. See
|
||||
``Serializer``\\ s, :class:`.Schema`, :class:`.SchemaRef` or :class:`.Response` objects. See
|
||||
:func:`@swagger_auto_schema <.swagger_auto_schema>` for more details.
|
||||
|
||||
:return: the response serializers
|
||||
|
|
|
|||
|
|
@ -434,9 +434,9 @@ class Schema(SwaggerDict):
|
|||
:param bool,.Schema,.SchemaRef additional_properties: allow wildcard properties not listed in `properties`
|
||||
:param list[str] required: list of requried property names
|
||||
:param .Schema,.SchemaRef items: type of array items, only valid if `type` is ``array``
|
||||
:param default: only valid when insider another ``Schema``\ 's ``properties``;
|
||||
:param default: only valid when insider another ``Schema``\\ 's ``properties``;
|
||||
the default value of this property if it is not provided, must conform to the type of this Schema
|
||||
:param read_only: only valid when insider another ``Schema``\ 's ``properties``;
|
||||
:param read_only: only valid when insider another ``Schema``\\ 's ``properties``;
|
||||
declares the property as read only - it must only be sent as part of responses, never in requests
|
||||
"""
|
||||
super(Schema, self).__init__(**extra)
|
||||
|
|
|
|||
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
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -50,7 +50,7 @@ def swagger_auto_schema(method=None, methods=None, auto_schema=unset, request_bo
|
|||
the `manual_parameters` argument.
|
||||
|
||||
If a ``Serializer`` class or instance is given, it will be automatically converted into a :class:`.Schema`
|
||||
used as a ``body`` :class:`.Parameter`, or into a list of ``form`` :class:`.Parameter`\ s, as appropriate.
|
||||
used as a ``body`` :class:`.Parameter`, or into a list of ``form`` :class:`.Parameter`\\ s, as appropriate.
|
||||
|
||||
:param .Serializer query_serializer: if you use a ``Serializer`` to parse query parameters, you can pass it here
|
||||
and have :class:`.Parameter` objects be generated automatically from it.
|
||||
|
|
@ -63,7 +63,7 @@ def swagger_auto_schema(method=None, methods=None, auto_schema=unset, request_bo
|
|||
|
||||
:param list[.Parameter] manual_parameters: a list of manual parameters to override the automatically generated ones
|
||||
|
||||
:class:`.Parameter`\ s are identified by their (``name``, ``in``) combination, and any parameters given
|
||||
:class:`.Parameter`\\ s are identified by their (``name``, ``in``) combination, and any parameters given
|
||||
here will fully override automatically generated parameters if they collide.
|
||||
|
||||
It is an error to supply ``form`` parameters when the request does not consume form-data.
|
||||
|
|
@ -107,6 +107,8 @@ def swagger_auto_schema(method=None, methods=None, auto_schema=unset, request_bo
|
|||
'query_serializer': query_serializer,
|
||||
'manual_parameters': manual_parameters,
|
||||
'operation_id': operation_id,
|
||||
'operation_summary': operation_summary,
|
||||
'deprecated': deprecated,
|
||||
'operation_description': operation_description,
|
||||
'security': security,
|
||||
'responses': responses,
|
||||
|
|
@ -120,7 +122,7 @@ def swagger_auto_schema(method=None, methods=None, auto_schema=unset, request_bo
|
|||
data.update(extra_overrides)
|
||||
if not data: # pragma: no cover
|
||||
# no overrides to set, no use in doing more work
|
||||
return
|
||||
return view_method
|
||||
|
||||
# if the method is an @action, it will have a bind_to_methods attribute, or a mapping attribute for drf>3.8
|
||||
bind_to_methods = getattr(view_method, 'bind_to_methods', [])
|
||||
|
|
@ -402,7 +404,7 @@ def get_field_default(field):
|
|||
"called; 'default' will not be set on schema", field, exc_info=True)
|
||||
default = serializers.empty
|
||||
|
||||
if default is not serializers.empty:
|
||||
if default is not serializers.empty and default is not None:
|
||||
try:
|
||||
default = field.to_representation(default)
|
||||
# JSON roundtrip ensures that the value is valid JSON;
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ from articles.models import Article
|
|||
from drf_yasg import openapi
|
||||
from drf_yasg.app_settings import swagger_settings
|
||||
from drf_yasg.inspectors import CoreAPICompatInspector, FieldInspector, NotHandled, SwaggerAutoSchema
|
||||
from drf_yasg.utils import swagger_auto_schema
|
||||
from drf_yasg.utils import no_body, swagger_auto_schema
|
||||
|
||||
|
||||
class DjangoFilterDescriptionInspector(CoreAPICompatInspector):
|
||||
|
|
@ -133,11 +133,13 @@ class ArticleViewSet(viewsets.ModelViewSet):
|
|||
"""
|
||||
pass
|
||||
|
||||
@swagger_auto_schema(request_body=no_body, operation_id='no_body_test')
|
||||
def update(self, request, *args, **kwargs):
|
||||
"""update method docstring"""
|
||||
return super(ArticleViewSet, self).update(request, *args, **kwargs)
|
||||
|
||||
@swagger_auto_schema(operation_description="partial_update description override", responses={404: 'slug not found'})
|
||||
@swagger_auto_schema(operation_description="partial_update description override", responses={404: 'slug not found'},
|
||||
operation_summary='partial_update summary', deprecated=True)
|
||||
def partial_update(self, request, *args, **kwargs):
|
||||
"""partial_update method docstring"""
|
||||
return super(ArticleViewSet, self).partial_update(request, *args, **kwargs)
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ from rest_framework.response import Response
|
|||
from rest_framework.views import APIView
|
||||
|
||||
from drf_yasg import openapi
|
||||
from drf_yasg.utils import no_body, swagger_auto_schema
|
||||
from drf_yasg.utils import swagger_auto_schema
|
||||
from users.serializers import UserListQuerySerializer, UserSerializerrr
|
||||
|
||||
|
||||
|
|
@ -36,7 +36,7 @@ class UserList(APIView):
|
|||
serializer.save()
|
||||
return Response(serializer.data, status=status.HTTP_201_CREATED)
|
||||
|
||||
@swagger_auto_schema(request_body=no_body, operation_id="users_dummy", operation_description="dummy operation")
|
||||
@swagger_auto_schema(operation_id="users_dummy", operation_description="dummy operation")
|
||||
def patch(self, request):
|
||||
pass
|
||||
|
||||
|
|
|
|||
|
|
@ -134,14 +134,9 @@ paths:
|
|||
tags:
|
||||
- articles
|
||||
put:
|
||||
operationId: articles_update
|
||||
operationId: no_body_test
|
||||
description: update method docstring
|
||||
parameters:
|
||||
- name: data
|
||||
in: body
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/Article'
|
||||
parameters: []
|
||||
responses:
|
||||
'200':
|
||||
description: ''
|
||||
|
|
@ -151,6 +146,7 @@ paths:
|
|||
- articles
|
||||
patch:
|
||||
operationId: articles_partial_update
|
||||
summary: partial_update summary
|
||||
description: partial_update description override
|
||||
parameters:
|
||||
- name: data
|
||||
|
|
@ -167,6 +163,7 @@ paths:
|
|||
description: slug not found
|
||||
tags:
|
||||
- articles
|
||||
deprecated: true
|
||||
delete:
|
||||
operationId: articles_delete
|
||||
description: destroy method docstring
|
||||
|
|
@ -192,6 +189,8 @@ paths:
|
|||
responses:
|
||||
'200':
|
||||
description: ''
|
||||
schema:
|
||||
$ref: '#/definitions/Article'
|
||||
consumes:
|
||||
- multipart/form-data
|
||||
tags:
|
||||
|
|
@ -228,6 +227,8 @@ paths:
|
|||
responses:
|
||||
'201':
|
||||
description: ''
|
||||
schema:
|
||||
$ref: '#/definitions/ImageUpload'
|
||||
consumes:
|
||||
- multipart/form-data
|
||||
tags:
|
||||
|
|
@ -890,6 +891,32 @@ definitions:
|
|||
type: string
|
||||
format: uuid
|
||||
readOnly: true
|
||||
ImageUpload:
|
||||
required:
|
||||
- image_styles
|
||||
type: object
|
||||
properties:
|
||||
what_am_i_doing:
|
||||
description: test
|
||||
type: string
|
||||
pattern: ^69$
|
||||
default: '69'
|
||||
minLength: 1
|
||||
image_styles:
|
||||
description: Parameter with Items
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
enum:
|
||||
- wide
|
||||
- tall
|
||||
- thumb
|
||||
- social
|
||||
upload:
|
||||
description: image serializer help_text
|
||||
type: string
|
||||
readOnly: true
|
||||
format: uri
|
||||
Identity:
|
||||
title: Identity
|
||||
type: object
|
||||
|
|
|
|||
2
tox.ini
2
tox.ini
|
|
@ -60,7 +60,7 @@ not_skip = __init__.py
|
|||
atomic = true
|
||||
multi_line_output = 5
|
||||
line_length = 120
|
||||
known_future_library = future,six
|
||||
known_future_library = six
|
||||
known_standard_library =
|
||||
collections,copy,distutils,functools,inspect,io,json,logging,operator,os,pkg_resources,re,setuptools,sys,
|
||||
types,warnings
|
||||
|
|
|
|||
Loading…
Reference in New Issue