You are here

private function RequestTestBase::getBasePath in OpenAPI 8.2

Gets the base path to be used in OpenAPI.

Return value

string The base path.

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

File

tests/src/Functional/RequestTestBase.php, line 377

Class

RequestTestBase
Base tests for requests on OpenAPI routes.

Namespace

Drupal\Tests\openapi\Functional

Code

private 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;
}