Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 713c669e28 | |||
| 2545ae9657 | |||
| f03d9d71e9 | |||
| a993cba7aa | |||
| bfd88cbdb4 | |||
| 123a05c82c |
@@ -3,6 +3,16 @@ Changelog
|
||||
#########
|
||||
|
||||
|
||||
*********
|
||||
**1.7.2**
|
||||
*********
|
||||
|
||||
*Release date: May 12, 2018*
|
||||
|
||||
- **FIXED:** fixed generation of default ``SECURITY_REQUIREMENTS`` to match documented behaviour
|
||||
- **FIXED:** ordering of ``SECURITY_REQUIREMENTS`` and ``SECURITY_DEFINITIONS`` is now stable
|
||||
|
||||
|
||||
*********
|
||||
**1.7.1**
|
||||
*********
|
||||
@@ -12,6 +22,8 @@ Changelog
|
||||
- **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
|
||||
- **IMPROVED:** set ``min_length=1`` when ``allow_blank=False`` (:pr:`112`, thanks to :ghuser:`elnappo`)
|
||||
- **FIXED:** made documentation ordering of ``SwaggerDict`` extra attributes stable
|
||||
|
||||
*********
|
||||
**1.7.0**
|
||||
|
||||
+1
-1
@@ -39,7 +39,7 @@ Security requirements
|
||||
The second step is specifying, for each endpoint, which authentication mechanism can be used for interacting with it.
|
||||
See https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#security-requirement-object for details.
|
||||
|
||||
By default, a top-level `security` that accepts all the declared security definitions is generated.
|
||||
By default, a top-level `security` that accepts any one of the declared security definitions is generated.
|
||||
For the example above, that would be :code:`[{'Basic': []}, {'Bearer': []}]`. This can be overriden using the
|
||||
:ref:`SECURITY_REQUIREMENTS <security-definitions-settings>` setting.
|
||||
|
||||
|
||||
@@ -204,9 +204,15 @@ class OpenAPISchemaGenerator(object):
|
||||
paths, prefix = self.get_paths(endpoints, components, request, public)
|
||||
|
||||
security_definitions = swagger_settings.SECURITY_DEFINITIONS
|
||||
if security_definitions is not None:
|
||||
security_definitions = OrderedDict(sorted([(key, OrderedDict(sorted(sd.items())))
|
||||
for key, sd in swagger_settings.SECURITY_DEFINITIONS.items()]))
|
||||
security_requirements = swagger_settings.SECURITY_REQUIREMENTS
|
||||
if security_requirements is None:
|
||||
security_requirements = [{security_scheme: [] for security_scheme in swagger_settings.SECURITY_DEFINITIONS}]
|
||||
security_requirements = [{security_scheme: []} for security_scheme in swagger_settings.SECURITY_DEFINITIONS]
|
||||
|
||||
security_requirements = sorted(security_requirements, key=lambda od: list(sorted(od)))
|
||||
security_requirements = [OrderedDict(sorted(sr.items())) for sr in security_requirements]
|
||||
|
||||
url = self.url
|
||||
if url is None and request is not None:
|
||||
|
||||
@@ -221,7 +221,7 @@ class Swagger(SwaggerDict):
|
||||
:param str _prefix: api path prefix to use in setting basePath; this will be appended to the wsgi
|
||||
SCRIPT_NAME prefix or Django's FORCE_SCRIPT_NAME if applicable
|
||||
:param str _version: version string to override Info
|
||||
:param list[dict] security_definitions: list of supported authentication mechanisms
|
||||
:param dict[str,dict[str,str]] security_definitions: list of supported authentication mechanisms
|
||||
:param list[dict] security: authentication mechanisms accepted by default; can be overriden in Operation
|
||||
:param list[str] consumes: consumed MIME types; can be overriden in Operation
|
||||
:param list[str] produces: produced MIME types; can be overriden in Operation
|
||||
|
||||
@@ -66,7 +66,7 @@ def swagger_auto_schema(method=None, methods=None, auto_schema=unset, request_bo
|
||||
|
||||
:param str operation_id: operation ID override; the operation ID must be unique accross the whole API
|
||||
:param str operation_description: operation description override
|
||||
:param str security: security requirements override; used to specify which authetication mechanism
|
||||
:param list[dict] security: security requirements override; used to specify which authetication mechanism
|
||||
is requried to call this API; an empty list marks the endpoint as unauthenticated (i.e. removes all accepted
|
||||
authentication schemes), and ``None`` will inherit the top-level secuirty requirements
|
||||
:param dict[str,(.Schema,.SchemaRef,.Response,str,Serializer)] responses: a dict of documented manual responses
|
||||
|
||||
@@ -94,7 +94,18 @@ SWAGGER_SETTINGS = {
|
||||
'LOGIN_URL': '/admin/login',
|
||||
'LOGOUT_URL': '/admin/logout',
|
||||
|
||||
'DEFAULT_INFO': 'testproj.urls.swagger_info'
|
||||
'DEFAULT_INFO': 'testproj.urls.swagger_info',
|
||||
|
||||
'SECURITY_DEFINITIONS': {
|
||||
'Basic': {
|
||||
'type': 'basic'
|
||||
},
|
||||
'Bearer': {
|
||||
'type': 'apiKey',
|
||||
'name': 'Authorization',
|
||||
'in': 'header'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Internationalization
|
||||
|
||||
@@ -21,10 +21,15 @@ consumes:
|
||||
produces:
|
||||
- application/json
|
||||
securityDefinitions:
|
||||
basic:
|
||||
Basic:
|
||||
type: basic
|
||||
Bearer:
|
||||
in: header
|
||||
name: Authorization
|
||||
type: apiKey
|
||||
security:
|
||||
- basic: []
|
||||
- Basic: []
|
||||
- Bearer: []
|
||||
paths:
|
||||
/articles/:
|
||||
get:
|
||||
|
||||
Reference in New Issue
Block a user