public function RestGenerator::nonBundleResourcesJson in OpenAPI 8
Return resources for non-entity resources.
Return value
\Symfony\Component\HttpFoundation\JsonResponse A json response.
File
- src/
Plugin/ openapi/ OpenApiGenerator/ RestGenerator.php, line 40
Class
- RestGenerator
- Defines an OpenApi Schema Generator for the Rest module.
Namespace
Drupal\openapi\Plugin\openapi\OpenApiGeneratorCode
public function nonBundleResourcesJson() {
/** @var \Drupal\rest\Entity\RestResourceConfig[] $resource_configs */
$resource_configs = $this->entityTypeManager
->getStorage('rest_resource_config')
->loadMultiple();
$non_entity_configs = [];
foreach ($resource_configs as $resource_config) {
if (!$this
->isEntityResource($resource_config)) {
$non_entity_configs[] = $resource_config;
}
else {
$entity_type = $this
->getEntityType($resource_config);
if (!$entity_type
->getBundleEntityType()) {
$non_entity_configs[] = $resource_config;
}
}
}
$spec = $this
->getSpecification($non_entity_configs);
$response = new JsonResponse($spec);
return $response;
}