2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-10-23 09:27:39 +00:00

refactor(backend): add enums for ordering fields (#10629)

* Add enums for ordering fields

* add version bump
This commit is contained in:
Matthias Mair
2025-10-21 01:13:32 +02:00
committed by GitHub
parent d71aae1ca9
commit 6cd733a83a
2 changed files with 9 additions and 5 deletions

View File

@@ -1,12 +1,14 @@
"""InvenTree API version information."""
# InvenTree API version
INVENTREE_API_VERSION = 413
INVENTREE_API_VERSION = 414
"""Increment this API version number whenever there is a significant change to the API that any clients need to know about."""
INVENTREE_API_TEXT = """
v414 -> 2025-06-20 : https://github.com/inventree/InvenTree/pull/10629
- Add enums for all ordering fields in schema - no functional changes
v413 -> 2025-10-20 : https://github.com/inventree/InvenTree/pull/10624
- Upstream fixes to django-allauth schema - no functional changes

View File

@@ -105,9 +105,11 @@ class ExtendedAutoSchema(AutoSchema):
parameters = operation.get('parameters', [])
for parameter in parameters:
if parameter['name'] == 'ordering':
parameter['description'] = (
f'{parameter["description"]} Possible fields: {", ".join(ordering_fields)}.'
)
schema_order = []
for field in ordering_fields:
schema_order.append(field)
schema_order.append('-' + field)
parameter['schema']['enum'] = schema_order
# Add valid search fields to the search description.
search_fields = getattr(self.view, 'search_fields', None)