mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-28 04:24:00 +03:00
Retain declared path ordering in OpenAPI YAML output. (#6680)
* Add pyyaml.dump(..., sort_keys=False) to not sort openapi keys alphabetically * Retain ordering of paths as provided in urlconf in OpenAPI schemas.
This commit is contained in:
parent
819c46ea80
commit
4d228257ac
|
@ -44,6 +44,7 @@ You can determine your currently installed version using `pip show`:
|
||||||
|
|
||||||
**Date**: [Unreleased][3.10.0-milestone]
|
**Date**: [Unreleased][3.10.0-milestone]
|
||||||
|
|
||||||
|
* Updated PyYaml dependency for OpenAPI schema generation to `pyyaml>=5.1` [#6680][gh6680]
|
||||||
* Resolve DeprecationWarning with markdown. [#6317][gh6317]
|
* Resolve DeprecationWarning with markdown. [#6317][gh6317]
|
||||||
* Add `generateschema --generator_class` CLI option
|
* Add `generateschema --generator_class` CLI option
|
||||||
|
|
||||||
|
@ -2138,4 +2139,5 @@ For older release notes, [please see the version 2.x documentation][old-release-
|
||||||
[gh6613]: https://github.com/encode/django-rest-framework/issues/6613
|
[gh6613]: https://github.com/encode/django-rest-framework/issues/6613
|
||||||
|
|
||||||
<!-- 3.10.0 -->
|
<!-- 3.10.0 -->
|
||||||
|
[gh6680]: https://github.com/encode/django-rest-framework/issues/6680
|
||||||
[gh6317]: https://github.com/encode/django-rest-framework/issues/6317
|
[gh6317]: https://github.com/encode/django-rest-framework/issues/6317
|
||||||
|
|
|
@ -6,4 +6,4 @@ django-guardian==1.5.0
|
||||||
django-filter>=2.1.0, <2.2
|
django-filter>=2.1.0, <2.2
|
||||||
coreapi==2.3.1
|
coreapi==2.3.1
|
||||||
coreschema==0.0.4
|
coreschema==0.0.4
|
||||||
pyyaml
|
pyyaml>=5.1
|
||||||
|
|
|
@ -1049,7 +1049,7 @@ class OpenAPIRenderer(BaseRenderer):
|
||||||
assert yaml, 'Using OpenAPIRenderer, but `pyyaml` is not installed.'
|
assert yaml, 'Using OpenAPIRenderer, but `pyyaml` is not installed.'
|
||||||
|
|
||||||
def render(self, data, media_type=None, renderer_context=None):
|
def render(self, data, media_type=None, renderer_context=None):
|
||||||
return yaml.dump(data, default_flow_style=False).encode('utf-8')
|
return yaml.dump(data, default_flow_style=False, sort_keys=False).encode('utf-8')
|
||||||
|
|
||||||
|
|
||||||
class JSONOpenAPIRenderer(BaseRenderer):
|
class JSONOpenAPIRenderer(BaseRenderer):
|
||||||
|
|
|
@ -54,7 +54,7 @@ def endpoint_ordering(endpoint):
|
||||||
'PATCH': 3,
|
'PATCH': 3,
|
||||||
'DELETE': 4
|
'DELETE': 4
|
||||||
}.get(method, 5)
|
}.get(method, 5)
|
||||||
return (path, method_priority)
|
return (method_priority,)
|
||||||
|
|
||||||
|
|
||||||
_PATH_PARAMETER_COMPONENT_RE = re.compile(
|
_PATH_PARAMETER_COMPONENT_RE = re.compile(
|
||||||
|
|
Loading…
Reference in New Issue
Block a user