public function JsonApiGenerator::getPaths in OpenAPI 8
Returns the paths information.
Return value
array The info elements.
Overrides OpenApiGeneratorBase::getPaths
File
- src/
Plugin/ openapi/ OpenApiGenerator/ JsonApiGenerator.php, line 197
Class
- JsonApiGenerator
- Defines an OpenApi Schema Generator for the JsonApi module.
Namespace
Drupal\openapi\Plugin\openapi\OpenApiGeneratorCode
public function getPaths() {
$routes = $this
->getJsonApiRoutes();
$api_paths = [];
foreach ($routes as $route_name => $route) {
/** @var \Drupal\jsonapi\ResourceType\ResourceType $resource_type */
$resource_type = $this
->getResourceType($route_name, $route);
$entity_type_id = $resource_type
->getEntityTypeId();
$bundle_name = $resource_type
->getBundle();
if (!$this
->includeEntityTypeBundle($entity_type_id, $bundle_name)) {
continue;
}
$api_path = [];
$methods = $route
->getMethods();
foreach ($methods as $method) {
$method = strtolower($method);
$path_method = [
'summary' => $this
->getRouteMethodSummary($route, $route_name, $method),
'description' => $this
->getRouteMethodDescription($route, $route_name, $method, $resource_type
->getTypeName()),
'parameters' => $this
->getMethodParameters($route, $route_name, $resource_type, $method),
'tags' => [
$this
->getBundleTag($entity_type_id, $bundle_name),
],
'responses' => $this
->getEntityResponsesJsonApi($entity_type_id, $method, $bundle_name, $route_name, $route),
];
/*
* @TODO: #2977109 - Calculate oauth scopes required.
*
* if (array_key_exists('oauth2', $path_method['security'])) {
* ...
* }
*/
$api_path[$method] = $path_method;
}
// Each path contains the "base path" from a OpenAPI perspective.
$path = str_replace($this
->getJsonApiBase(), '', $route
->getPath());
$api_paths[$path] = NestedArray::mergeDeep(empty($api_paths[$path]) ? [] : $api_paths[$path], $api_path);
}
return $api_paths;
}