From 548a95cc197e826382dd5e1a6fb60ac9458145de Mon Sep 17 00:00:00 2001 From: Oliver Date: Tue, 29 Jul 2025 08:11:10 +1000 Subject: [PATCH] Sort search fields (#10095) * Sort search fields * add api version bump --------- Co-authored-by: Matthias Mair --- src/backend/InvenTree/InvenTree/api_version.py | 5 ++++- src/backend/InvenTree/InvenTree/schema.py | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/backend/InvenTree/InvenTree/api_version.py b/src/backend/InvenTree/InvenTree/api_version.py index 6dd42b96ce..977ab1358b 100644 --- a/src/backend/InvenTree/InvenTree/api_version.py +++ b/src/backend/InvenTree/InvenTree/api_version.py @@ -1,11 +1,14 @@ """InvenTree API version information.""" # InvenTree API version -INVENTREE_API_VERSION = 374 +INVENTREE_API_VERSION = 375 """Increment this API version number whenever there is a significant change to the API that any clients need to know about.""" INVENTREE_API_TEXT = """ +v375 -> 2025-07-28 : https://github.com/inventree/InvenTree/pull/10095 + - Sorts searched fields to keep API stable + v374 -> 2025-07-28 : https://github.com/inventree/InvenTree/pull/10092 - Add nullable to a few details fields that lack it - Add the list of searched fields to the search parameter comments diff --git a/src/backend/InvenTree/InvenTree/schema.py b/src/backend/InvenTree/InvenTree/schema.py index 94f72b63c0..ac805e4f28 100644 --- a/src/backend/InvenTree/InvenTree/schema.py +++ b/src/backend/InvenTree/InvenTree/schema.py @@ -105,7 +105,11 @@ class ExtendedAutoSchema(AutoSchema): # Add valid search fields to the search description. search_fields = getattr(self.view, 'search_fields', None) + if search_fields is not None: + # Ensure consistent ordering of search fields + search_fields = sorted(search_fields) + parameters = operation.get('parameters', []) for parameter in parameters: if parameter['name'] == 'search':