You are here

protected function RequestTest::getBasePath in OpenAPI 8

Gets the base path to be used in OpenAPI.

Return value

string The base path.

1 call to RequestTest::getBasePath()
RequestTest::requestOpenApiJson in tests/src/Functional/RequestTest.php
Makes OpenAPI request and checks the response.

File

tests/src/Functional/RequestTest.php, line 459

Class

RequestTest
Tests requests OpenAPI routes.

Namespace

Drupal\Tests\openapi\Functional

Code

protected function getBasePath() {
  $path = rtrim(parse_url($this->baseUrl, PHP_URL_PATH), '/');

  // OpenAPI spec states that the base path must start with a '/'.
  if (strlen($path) == 0) {

    // For a zero length string, set it to minimal value.
    $path = "/";
  }
  elseif (substr($path, 0, 1) !== '/') {

    // Prepend a slash to any other string that don't have one.
    $path = '/' . $path;
  }
  return $path;
}