API Models TypeDefinition - evansims/openfga-php GitHub Wiki

Represents a type definition in your authorization model. A TypeDefinition defines an object type (like "document," "folder," "user") and specifies the relations that can exist for objects of this type. Each relation defines how users can be related to objects, such as "owner," "editor," or "viewer" relationships. Use this when defining the schema of object types and their allowed relationships in your authorization model.

Table of Contents


Namespace

OpenFGA\Models


Source

View source code


Implements


Related Classes


Constants

Name Value Description
OPENAPI_MODEL TypeDefinition


Methods

getMetadata

public function getMetadata(): ?OpenFGA\Models\MetadataInterface

Get the metadata associated with this type definition. Metadata provides additional context, documentation, and configuration information for the type definition. This can include source file information, module details, and other development-time context.

View source


Returns

MetadataInterface | null — The metadata, or null if not specified


getRelations

public function getRelations(): ?OpenFGA\Models\Collections\TypeDefinitionRelationsInterface

Get the collection of relations defined for this type. Relations define the authorized relationships that can exist between objects of this type and other entities in the system.

View source


Returns

TypeDefinitionRelationsInterface | null


getType

public function getType(): string

Get the name of this type. The type name uniquely identifies this type definition within the authorization model. Common examples include "user," "document," "folder," "organization," etc.

View source


Returns

string — The unique type name


jsonSerialize

public function jsonSerialize(): array

View source


Returns

array


schema

Implements Models\TypeDefinitionInterface

public function schema(): SchemaInterface

Get the schema definition for this model. This method returns the schema that defines the structure, validation rules, and serialization behavior for this model class. The schema is used for data validation, transformation, and ensuring consistency across API operations with the OpenFGA service. Each model's schema defines: - Required and optional properties - Data types and format constraints - Nested object relationships - Validation rules and business logic constraints The schema system enables the SDK to automatically validate incoming data, transform between different representations, and ensure compliance with the OpenFGA API specification.

View source


Returns

SchemaInterface — The schema definition containing validation rules and property specifications for this model

⚠️ **GitHub.com Fallback** ⚠️