Removed deprecated REST API

Prepare code to be compatible with swagger v2
This commit is contained in:
Laurent Destailleur 2017-11-17 12:46:30 +01:00
parent 92753273b9
commit a5a9b9b23f
2 changed files with 14 additions and 10 deletions

View File

@ -15,22 +15,24 @@ WARNING:
Following changes may create regressions for some external modules, but were necessary to make Dolibarr better: Following changes may create regressions for some external modules, but were necessary to make Dolibarr better:
* The methode "cloture" on contract were renamed into "closeAll". * The methode "cloture" on contract were renamed into "closeAll".
* The substitution key for reference of object is now __REF__ whatever is the object (it replaces __ORDERREF__, * The substitution key for reference of objects is now __REF__ whatever is the object (it replaces __ORDERREF__,
__PROPALREF__, ...) __PROPALREF__, ...)
* The substition key __SIGNATURE__ was renamed into __USER_SIGNATURE__ to follow naming conventions. * The substition key __SIGNATURE__ was renamed into __USER_SIGNATURE__ to follow naming conventions.
* Substitution keys with syntax %XXX% were renamed into __XXX__ to match others. * Substitution keys with syntax %XXX% were renamed into __XXX__ to match others.
* Removed old deprecated REST API (APIs found into '/root' section of the REST API explorer in Dolibarr v6).
* Some REST API to access setup features, like dictionaries (country, town, extrafields, ...) were moved into a * Some REST API to access setup features, like dictionaries (country, town, extrafields, ...) were moved into a
common API "/setup". common API "/setup".
* The REST API /documents were renamed into /documents/download and /documents/upload. * The REST API /documents were renamed into /documents/download and /documents/upload.
* Page bank/index.php, bank/bankentries.php and comm/actions/listactions.php were renamed into * Page bank/index.php, bank/bankentries.php and comm/actions/listactions.php were renamed into
bank/list.php, bank/bankentries_list.php and comm/actions/list.php to follow page naming bank/list.php, bank/bankentries_list.php and comm/actions/list.php to follow page naming
conventions (so default filter/sort order features can also work). conventions (so default filter/sort order features can also work for this pages).
* The trigger ORDER_SUPPLIER_STATUS_ONPROCESS was renamed into ORDER_SUPPLIER_STATUS_ORDERED. * The trigger ORDER_SUPPLIER_STATUS_ONPROCESS was renamed into ORDER_SUPPLIER_STATUS_ORDERED.
* The trigger ORDER_SUPPLIER_STATUS_RECEIVED_ALL was renamed into ORDER_SUPPLIER_STATUS_RECEIVED_COMPLETELY. * The trigger ORDER_SUPPLIER_STATUS_RECEIVED_ALL was renamed into ORDER_SUPPLIER_STATUS_RECEIVED_COMPLETELY.
* The parameter note into method cloture() is added at end of private note (previously in v6, it replaced). * The parameter note into method cloture() is added at end of private note (previously in v6, it replaced).
* The parameter $user is now mandatory for method createFromOrder and createFromPropal. * The parameter $user is now mandatory for method createFromOrder and createFromPropal.
* Removed js library 'fileupload' that was not used by core code. * Removed js library 'fileupload' that was not used by core code.
* IE8 and earlier and Firefox 12 and earlier (2012) are no more supported. * IE8 and earlier and Firefox 12 and earlier (< 2012) are no more supported.
***** ChangeLog for 6.0.3 compared to 6.0.2 ***** ***** ChangeLog for 6.0.3 compared to 6.0.2 *****
FIX: #7211 Update qty dispatched on qty change FIX: #7211 Update qty dispatched on qty change

View File

@ -96,7 +96,7 @@ preg_match('/index\.php\/([^\/]+)(.*)$/', $_SERVER["PHP_SELF"], $reg);
// Set the flag to say to refresh (when we reload the explorer, production must be for API call only) // Set the flag to say to refresh (when we reload the explorer, production must be for API call only)
$refreshcache=false; $refreshcache=false;
if (! empty($reg[1]) && $reg[1] == 'explorer' && ($reg[2] == '/resources.json' || $reg[2] == '/resources.json/root')) if (! empty($reg[1]) && $reg[1] == 'explorer' && ($reg[2] == '/swagger.json' || $reg[2] == '/swagger.json/root' || $reg[2] == '/resources.json' || $reg[2] == '/resources.json/root'))
{ {
$refreshcache=true; $refreshcache=true;
} }
@ -109,7 +109,7 @@ $api = new DolibarrApi($db, '', $refreshcache);
// See https://github.com/Luracast/Restler-API-Explorer for more info. // See https://github.com/Luracast/Restler-API-Explorer for more info.
$api->r->addAPIClass('Luracast\\Restler\\Explorer'); $api->r->addAPIClass('Luracast\\Restler\\Explorer');
$api->r->setSupportedFormats('JsonFormat', 'XmlFormat', 'UploadFormat'); $api->r->setSupportedFormats('JsonFormat', 'XmlFormat', 'UploadFormat'); // 'YamlFormat'
$api->r->addAuthenticationClass('DolibarrApiAccess',''); $api->r->addAuthenticationClass('DolibarrApiAccess','');
// Define accepted mime types // Define accepted mime types
@ -118,7 +118,7 @@ UploadFormat::$allowedMimeTypes = array('image/jpeg', 'image/png', 'text/plain',
// Call Explorer file for all APIs definitions // Call Explorer file for all APIs definitions
if (! empty($reg[1]) && $reg[1] == 'explorer' && ($reg[2] == '/resources.json' || $reg[2] == '/resources.json/root')) if (! empty($reg[1]) && $reg[1] == 'explorer' && ($reg[2] == '/swagger.json' || $reg[2] == '/swagger.json/root' || $reg[2] == '/resources.json' || $reg[2] == '/resources.json/root'))
{ {
// Scan all API files to load them // Scan all API files to load them
@ -164,7 +164,7 @@ if (! empty($reg[1]) && $reg[1] == 'explorer' && ($reg[2] == '/resources.json' |
if ($file_searched == 'api_access.class.php') continue; if ($file_searched == 'api_access.class.php') continue;
// Support of the deprecated API. // Support of the deprecated API.
if (is_readable($dir_part.$file_searched) && preg_match("/^api_deprecated_(.*)\.class\.php$/i",$file_searched,$regapi)) /*if (is_readable($dir_part.$file_searched) && preg_match("/^api_deprecated_(.*)\.class\.php$/i",$file_searched,$regapi))
{ {
$classname = ucwords($regapi[1]).'Api'; $classname = ucwords($regapi[1]).'Api';
require_once $dir_part.$file_searched; require_once $dir_part.$file_searched;
@ -178,7 +178,8 @@ if (! empty($reg[1]) && $reg[1] == 'explorer' && ($reg[2] == '/resources.json' |
dol_syslog("We found an api_xxx file (".$file_searched.") but class ".$classname." does not exists after loading file", LOG_WARNING); dol_syslog("We found an api_xxx file (".$file_searched.") but class ".$classname." does not exists after loading file", LOG_WARNING);
} }
} }
elseif (is_readable($dir_part.$file_searched) && preg_match("/^api_(.*)\.class\.php$/i",$file_searched,$regapi)) else*/
if (is_readable($dir_part.$file_searched) && preg_match("/^api_(.*)\.class\.php$/i",$file_searched,$regapi))
{ {
$classname = ucwords($regapi[1]); $classname = ucwords($regapi[1]);
$classname = str_replace('_', '', $classname); $classname = str_replace('_', '', $classname);
@ -213,15 +214,16 @@ if (! empty($reg[1]) && $reg[1] == 'explorer' && ($reg[2] == '/resources.json' |
{ {
$api->r->addAPIClass($classname, $apiname); $api->r->addAPIClass($classname, $apiname);
} }
//var_dump($api->r);
} }
// Call one APIs or one definition of an API // Call one APIs or one definition of an API
if (! empty($reg[1]) && ($reg[1] != 'explorer' || ($reg[2] != '/resources.json' && preg_match('/^\/resources.json\/(.+)$/', $reg[2], $regbis) && $regbis[1] != 'root'))) if (! empty($reg[1]) && ($reg[1] != 'explorer' || ($reg[2] != '/swagger.json' && $reg[2] != '/resources.json' && preg_match('/^\/(swagger|resources)\.json\/(.+)$/', $reg[2], $regbis) && $regbis[2] != 'root')))
{ {
$module = $reg[1]; $module = $reg[1];
if ($module == 'explorer') // If we call page to explore details of a service if ($module == 'explorer') // If we call page to explore details of a service
{ {
$module = $regbis[1]; $module = $regbis[2];
} }
$module=strtolower($module); $module=strtolower($module);