You are here

protected function RestGenerator::getRestSupportedFormats in OpenAPI for REST 8.2

Returns a list of supported Format on REST.

Return value

array The list of supported formats.

2 calls to RestGenerator::getRestSupportedFormats()
RestGenerator::getConsumes in src/Plugin/openapi/OpenApiGenerator/RestGenerator.php
RestGenerator::getProduces in src/Plugin/openapi/OpenApiGenerator/RestGenerator.php

File

src/Plugin/openapi/OpenApiGenerator/RestGenerator.php, line 522

Class

RestGenerator
Defines an OpenApi Schema Generator for the Rest module.

Namespace

Drupal\openapi_rest\Plugin\openapi\OpenApiGenerator

Code

protected function getRestSupportedFormats() {
  static $supported_formats = [];
  if (empty($supported_formats)) {
    $resource_configs = $this
      ->getResourceConfigs($this
      ->getOptions());
    if (empty($resource_configs)) {
      return [];
    }
    foreach ($resource_configs as $resource_config) {
      foreach ($resource_config
        ->getMethods() as $method) {
        $formats = $this
          ->getMethodSupportedFormats($method, $resource_config);
        $supported_formats = array_unique(array_merge($supported_formats, $formats), SORT_REGULAR);
      }
    }
  }
  return $supported_formats;
}