Metadata Document
The $metadata endpoint returns the CSDL (Common Schema Definition Language) XML document describing the service's data model.
URL
GET /odata/$metadataResponse format
The response is XML with content type application/xml:
xml
<?xml version="1.0" encoding="UTF-8"?>
<edmx:Edmx Version="4.0" xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx">
<edmx:DataServices>
<Schema Namespace="App.Products" xmlns="http://docs.oasis-open.org/odata/ns/edm">
<EntityType Name="Product">
<Key>
<PropertyRef Name="id"/>
</Key>
<Property Name="id" Type="Edm.Int64" Nullable="false"/>
<Property Name="name" Type="Edm.String"/>
<Property Name="price" Type="Edm.Decimal"/>
<NavigationProperty Name="category" Type="App.Products.Category"/>
</EntityType>
<EntityContainer Name="DefaultContainer">
<EntitySet Name="Products" EntityType="App.Products.Product">
<NavigationPropertyBinding Path="category" Target="Categories"/>
</EntitySet>
</EntityContainer>
</Schema>
</edmx:DataServices>
</edmx:Edmx>What it contains
| Element | Description |
|---|---|
Schema | Namespace, entity types, complex types, enum types, functions |
EntityType | Key, structural properties, navigation properties, annotations |
ComplexType | Structural properties (no key) |
EnumType | Named constants |
Function | Parameters and return type |
EntityContainer | Entity sets, singletons, function imports |
EntitySet | Name, entity type, navigation property bindings |
Singleton | Name, entity type |
FunctionImport | Name, function reference |
Annotation | Vocabulary annotations on any element |
How it is generated
The CsdlSerializer walks the EdmxInterface object graph and emits XML. No template files are involved -- the XML is generated programmatically from the frozen Edm model.
Caching
For production, use php artisan odata:cache to pre-compile the Edm model into PHP classes. This makes metadata generation faster but does not cache the XML itself -- the CSDL serialization runs on each $metadata request.
You can also override cachedMetadataXMLPath() on your service to point to a static XML file.