protected function OpenApiGeneratorBase::getEntityResponses in OpenAPI 8.2
Same name and namespace in other branches
- 8 src/Plugin/openapi/OpenApiGeneratorBase.php \Drupal\openapi\Plugin\openapi\OpenApiGeneratorBase::getEntityResponses()
Get possible responses for an entity type.
Parameters
string $entity_type_id: The entity type.
string $method: The method.
string $bundle_name: The bundle name.
Return value
array The entity responses.
File
- src/
Plugin/ openapi/ OpenApiGeneratorBase.php, line 429
Class
- OpenApiGeneratorBase
- Defines base class for OpenApi Generator plugins.
Namespace
Drupal\openapi\Plugin\openapiCode
protected function getEntityResponses($entity_type_id, $method, $bundle_name = NULL) {
$method = strtolower($method);
$responses = [];
$schema_response = [];
if ($definition_ref = $this
->getDefinitionReference($entity_type_id, $bundle_name)) {
$schema_response = [
'schema' => [
'$ref' => $definition_ref,
],
];
}
switch ($method) {
case 'get':
$responses['200'] = [
'description' => 'successful operation',
] + $schema_response;
break;
case 'post':
unset($responses['200']);
$responses['201'] = [
'description' => 'Entity created',
] + $schema_response;
break;
case 'delete':
unset($responses['200']);
$responses['201'] = [
'description' => 'Entity deleted',
];
break;
}
return $responses;
}