8000 Retain declared path ordering in OpenAPI YAML output. (#6680) · coderanger/django-rest-framework@4d22825 · GitHub
[go: up one dir, main page]

Skip to content

Commit 4d22825

Browse files
n2ygkcarltongibson
authored andcommitted
Retain declared path ordering in OpenAPI YAML output. (encode#6680)
* Add pyyaml.dump(..., sort_keys=False) to not sort openapi keys alphabetically * Retain ordering of paths as provided in urlconf in OpenAPI schemas.
1 parent 819c46e commit 4d22825

File tree

4 files changed

+5
-3
lines changed

4 files changed

+5
-3
lines changed

docs/community/release-notes.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ You can determine your currently installed version using `pip show`:
4444

4545
**Date**: [Unreleased][3.10.0-milestone]
4646

47+
* Updated PyYaml dependency for OpenAPI schema generation to `pyyaml>=5.1` [#6680][gh6680]
4748
* Resolve DeprecationWarning with markdown. [#6317][gh6317]
4849
* Add `generateschema --generator_class` CLI option
4950

@@ -2138,4 +2139,5 @@ For older release notes, [please see the version 2.x documentation][old-release-
21382139
[gh6613]: https://github.com/encode/django-rest-framework/issues/6613
21392140

21402141
<!-- 3.10.0 -->
2142+
[gh6680]: https://github.com/encode/django-rest-framework/issues/6680
21412143
[gh6317]: https://github.com/encode/django-rest-framework/issues/6317

requirements/requirements-optionals.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ django-guardian==1.5.0
66
django-filter>=2.1.0, <2.2
77
coreapi==2.3.1
88
coreschema==0.0.4
9-
pyyaml
9+
pyyaml>=5.1

rest_framework/renderers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1049,7 +1049,7 @@ def __init__(self):
10491049
assert yaml, 'Using OpenAPIRenderer, but `pyyaml` is not installed.'
10501050

10511051
def render(self, data, media_type=None, renderer_context=None):
1052-
return yaml.dump(data, default_flow_style=False).encode('utf-8')
1052+
return yaml.dump(data, default_flow_style=False, sort_keys=False).encode('utf-8')
10531053

10541054

10551055
class JSONOpenAPIRenderer(BaseRenderer):

rest_framework/schemas/generators.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def endpoint_ordering(endpoint):
5454
'PATCH': 3,
5555
'DELETE': 4
5656
}.get(method, 5)
57-
return (path, method_priority)
57+
return (method_priority,)
5858

5959

6060
_PATH_PARAMETER_COMPONENT_RE = re.compile(

0 commit comments

Comments
 (0)
0