Fix SECURITY_DEFINITIONS and SECURITY_REQUIREMENTS ordering
parent
a993cba7aa
commit
f03d9d71e9
|
|
@ -4,12 +4,13 @@ Changelog
|
||||||
|
|
||||||
|
|
||||||
*********
|
*********
|
||||||
**1.7.2**
|
**1.7.2b**
|
||||||
*********
|
*********
|
||||||
|
|
||||||
*Release date: May 12, 2018*
|
*Release date: May 12, 2018*
|
||||||
|
|
||||||
- **FIXED:** fixed generation of default ``SECURITY_REQUIREMENTS`` to match documented behaviour
|
- **FIXED:** fixed generation of default ``SECURITY_REQUIREMENTS`` to match documented behaviour
|
||||||
|
- **FIXED:** ordering of ``SECURITY_REQUIREMENTS`` and ``SECURITY_DEFINITIONS`` is now stable
|
||||||
|
|
||||||
|
|
||||||
*********
|
*********
|
||||||
|
|
|
||||||
|
|
@ -204,9 +204,14 @@ class OpenAPISchemaGenerator(object):
|
||||||
paths, prefix = self.get_paths(endpoints, components, request, public)
|
paths, prefix = self.get_paths(endpoints, components, request, public)
|
||||||
|
|
||||||
security_definitions = swagger_settings.SECURITY_DEFINITIONS
|
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
|
security_requirements = swagger_settings.SECURITY_REQUIREMENTS
|
||||||
if security_requirements is None:
|
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]
|
||||||
|
else:
|
||||||
|
security_requirements = [OrderedDict(sorted(sr.items())) for sr in security_requirements]
|
||||||
|
|
||||||
url = self.url
|
url = self.url
|
||||||
if url is None and request is not None:
|
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
|
: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
|
SCRIPT_NAME prefix or Django's FORCE_SCRIPT_NAME if applicable
|
||||||
:param str _version: version string to override Info
|
: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[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] consumes: consumed MIME types; can be overriden in Operation
|
||||||
:param list[str] produces: produced MIME types; can be overriden in Operation
|
:param list[str] produces: produced MIME types; can be overriden in Operation
|
||||||
|
|
|
||||||
|
|
@ -24,9 +24,9 @@ securityDefinitions:
|
||||||
Basic:
|
Basic:
|
||||||
type: basic
|
type: basic
|
||||||
Bearer:
|
Bearer:
|
||||||
type: apiKey
|
|
||||||
name: Authorization
|
|
||||||
in: header
|
in: header
|
||||||
|
name: Authorization
|
||||||
|
type: apiKey
|
||||||
security:
|
security:
|
||||||
- Basic: []
|
- Basic: []
|
||||||
- Bearer: []
|
- Bearer: []
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue