From 74c0e8930542e79dc179859b67a3c842c0cbc7d5 Mon Sep 17 00:00:00 2001 From: Marc Carmier Date: Fri, 23 Feb 2018 20:29:15 +0100 Subject: [PATCH] Always retrieve schema description in unauthenticated mode --- src/Api.php | 16 +++++++++++++--- tests/ApiFunctionalTest.php | 2 +- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/Api.php b/src/Api.php index 2b44eb5..77b4435 100644 --- a/src/Api.php +++ b/src/Api.php @@ -331,9 +331,19 @@ class Api */ public function get($path, $content = null, $headers = null, $is_authenticated = true) { - return $this->decodeResponse( - $this->rawCall("GET", $path, $content, $is_authenticated, $headers) - ); + if(preg_match('/^\/[^\/]+\.json$/', $path)) + { + // Schema description must be access without authentication + return $this->decodeResponse( + $this->rawCall("GET", $path, $content, false, $headers) + ); + } + else + { + return $this->decodeResponse( + $this->rawCall("GET", $path, $content, $is_authenticated, $headers) + ); + } } /** diff --git a/tests/ApiFunctionalTest.php b/tests/ApiFunctionalTest.php index f8fd6b9..59d3954 100644 --- a/tests/ApiFunctionalTest.php +++ b/tests/ApiFunctionalTest.php @@ -257,6 +257,6 @@ class ApiFunctionalTest extends \PHPUnit_Framework_TestCase public function testApiGetWithoutAuthentication() { $api = new Api(NULL,NULL, $this->endpoint, null, $this->client); - $api->get('/hosting/web/moduleList'); + $api->get('/hosting/web/moduleList',null,null,false); } }