protected static function JsonApiGenerator::buildRelationshipSchema in OpenAPI 8
Builds the relationship schema.
@todo: build this once and use '$ref' when necessary.
Parameters
bool $is_multiple: Indicates if the relationship is to-many.
string $resource_type_name: The resource type for the relationship.
Return value
array The schema definition.
2 calls to JsonApiGenerator::buildRelationshipSchema()
- JsonApiGenerator::getEntityResponsesJsonApi in src/
Plugin/ openapi/ OpenApiGenerator/ JsonApiGenerator.php - JsonApiGenerator::getMethodParameters in src/
Plugin/ openapi/ OpenApiGenerator/ JsonApiGenerator.php - Get the parameters array for a method on a route.
File
- src/
Plugin/ openapi/ OpenApiGenerator/ JsonApiGenerator.php, line 933
Class
- JsonApiGenerator
- Defines an OpenApi Schema Generator for the JsonApi module.
Namespace
Drupal\openapi\Plugin\openapi\OpenApiGeneratorCode
protected static function buildRelationshipSchema($is_multiple, $resource_type_name = NULL) {
$linkage_schema = [
'description' => 'The "type" and "id" to non-empty members.',
'type' => 'object',
'required' => [
'type',
'id',
],
'properties' => [
'type' => [
'title' => t('Resource type name'),
'type' => 'string',
],
'id' => [
'title' => t('Resource ID'),
'type' => 'string',
'format' => 'uuid',
],
'meta' => [
'description' => 'Non-standard meta-information that can not be represented as an attribute or relationship.',
'type' => 'object',
'additionalProperties' => TRUE,
'properties' => (object) [],
],
],
'additionalProperties' => FALSE,
];
if ($resource_type_name) {
$linkage_schema['properties']['type']['enum'] = [
$resource_type_name,
];
}
return [
'type' => 'object',
'properties' => [
'data' => $is_multiple ? [
'description' => 'An array of objects each containing \\"type\\" and \\"id\\" members for to-many relationships.',
'type' => 'array',
'items' => $linkage_schema,
'uniqueItems' => TRUE,
] : $linkage_schema,
],
];
}