diff --git a/htdocs/api/index.php b/htdocs/api/index.php
index e0abd839b6629896a59694ec5512ffa99ad8e537..e58d2370be7d20af2e432aac47f6205818b3bbfe 100644
--- a/htdocs/api/index.php
+++ b/htdocs/api/index.php
@@ -65,6 +65,8 @@ $api->r->addAPIClass('Luracast\\Restler\\Explorer');
$api->r->setSupportedFormats('JsonFormat', 'XmlFormat');
$api->r->addAuthenticationClass('DolibarrApiAccess','');
+$listofapis = array();
+
$modulesdir = dolGetModulesDirs();
foreach ($modulesdir as $dir)
{
@@ -117,7 +119,7 @@ foreach ($modulesdir as $dir)
if (class_exists($classname))
{
dol_syslog("Found API classname=".$classname);
- $api->r->addAPIClass($classname);
+ $listofapis[] = $classname;
}
}
}
@@ -128,6 +130,14 @@ foreach ($modulesdir as $dir)
}
}
+// Sort the classes before adding them to Restler. The Restler API Explorer
+// shows the classes in the order they are added and it's a mess if they are
+// not sorted.
+sort($listofapis);
+foreach ($listofapis as $classname)
+{
+ $api->r->addAPIClass($classname);
+}
// TODO If not found, redirect to explorer