### OData GET Request: Search Query Option Example Source: https://sap.github.io/odata-vocabularies/docs/v2-annotations This example shows a GET request to an OData service utilizing the custom 'search' query option. The 'search' option allows clients to pass a free-text search term to the backend, enabling flexible searching across entity properties. The backend service implementation determines how this term is matched and against which properties. ```http GET /Orders?search=blue ``` -------------------------------- ### Install Node.js Dependencies with npm Source: https://sap.github.io/odata-vocabularies/index This command installs the necessary Node.js dependencies for contributors working with the OData vocabularies repository. It requires Node.js to be installed on the system. ```shell npm install ``` -------------------------------- ### Common Text Annotation Example Source: https://sap.github.io/odata-vocabularies/vocabularies/UI Demonstrates how to use the Common.Text annotation to specify the text or ID property for an annotation value. This is useful for localizing or providing descriptive text for properties. ```odata Property Name @Common.Text : 'PropertyName' ``` -------------------------------- ### Example Hierarchical OData Query (OData) Source: https://sap.github.io/odata-vocabularies/vocabularies/Hierarchy Demonstrates a sample OData query utilizing hierarchical transformations such as 'descendants', 'ancestors', and 'Hierarchy.TopLevels'. It shows how to apply filters and specify hierarchy levels. ```odata SalesOrganizations?$apply= descendants(..., ID, filter(ID eq 'US'), keep start) /ancestors(..., ID, filter(contains(Name, 'New York')), keep start) /Hierarchy.TopLevels(..., NodeProperty='ID', Levels=2) &$top=10 ``` -------------------------------- ### Constant Annotation Values for Primitive Types (Reference) Source: https://sap.github.io/odata-vocabularies/docs/annotation-cheat-sheet-cap Provides a reference table for constructing constant annotation values for various EDM primitive types. This includes examples for strings, numbers, booleans, dates, and other scalar types. ```text Edm.Binary | 'T0RhdGE' Edm.Boolean | true Edm.Date | '2000-01-01' Edm.DateTimeOffset | '2000-01-01T16:00:00.000Z' Edm.Decimal | '3.14' Edm.Duration | 'P7D' Enumeration Type | #Red Edm.Double or Edm.Single | 3.14 Edm.Guid | '21EC2020-3AEA-1069-A2DD-08002B30309D' Edm.Int16, Edm.Int32, Edm.64, Edm.Byte, Edm.SByte | 42 Edm.Int64 | '42' Edm.String | 'annotation value' Edm.TimeOfDay | '21:45:00' Edm.AnnotationPath | 'Product/Supplier/@UI.LineItem' Edm.NavigationPropertyPath | Supplier Edm.PropertyPath | Details.ChangedAt ``` -------------------------------- ### MultiLevelExpand Function Example in OData Source: https://sap.github.io/odata-vocabularies/vocabularies/Analytics Demonstrates the usage of the experimental MultiLevelExpand function within an OData `$apply` transformation. This function is used to expand a leveled hierarchy with custom aggregation of properties, supporting complex filtering, grouping, and expansion logic. ```odata $apply=filter(Industry in ('IT','AI')) /groupby((Country,Region,Segment,Industry), filter($these/aggregate(Amount) gt 0 and $these/aggregate(Currency) ne null)) /concat( groupby((Country,Region,Segment,Industry)) /aggregate($count as LeavesCount), aggregate(Amount,Currency), Analytics.MultiLevelExpand( LevelProperties=[{"DimensionProperties":["Country"],"AdditionalProperties":["CountryName"]}, {"DimensionProperties":["Region"],"AdditionalProperties":["RegionName"]}, {"DimensionProperties":["Segment","Industry"],"AdditionalProperties":[]}], Aggregation=["Amount","Currency"], SiblingOrder=[{"Property":"Amount","Descending":true}], Levels=2, ExpandLevels=[{"Entry":["US"],"Levels":0}, {"Entry":["DE","BW"],"Levels":1}] )/concat(aggregate($count as ResultEntriesCount), skip(20)/top(10))) ``` -------------------------------- ### OData Batch Request for Copying and Reparenting Hierarchy Nodes Source: https://sap.github.io/odata-vocabularies/vocabularies/Hierarchy Demonstrates an OData batch request to copy a node and its descendants, followed by reparenting the copied node using a PATCH request. This example illustrates how to use CopyAction and ChangeNextSiblingAction in sequence. ```odata { "requests": [ { "id": "1", "method": "post", "url": "HierarchyDirectory(1)/Nodes('A')/CopyAction" }, { "id": "2", "dependsOn": ["1"], "method": "patch", "url": "$1", "body": { "Superordinate@odata.bind": "Nodes('B')" } } ] } ``` -------------------------------- ### Example Function Imports for Leave Request Approval in OData Source: https://sap.github.io/odata-vocabularies/docs/v2-annotations Demonstrates the use of `edm:FunctionImport` for actions like approving or rejecting leave requests. It includes attributes such as `sap:action-for` to specify the entity type and `sap:applicable-path` to control invocation. ```xml ``` -------------------------------- ### OData Error Message Structure Example (EDM) Source: https://sap.github.io/odata-vocabularies/vocabularies/Common Defines the minimum structure for OData error messages, including code, message, target, and severity. This structure is crucial for consistent error reporting in OData services. ```EDM : Edm.String : Edm.String : Edm.String nullable : Collection(Edm.String) : Edm.Boolean : Edm.Byte : Edm.String nullable ``` -------------------------------- ### Maintain Recursive Hierarchy Nodes - JSON Request Example Source: https://sap.github.io/odata-vocabularies/vocabularies/Hierarchy This JSON example demonstrates how to maintain nodes within a recursive hierarchy using OData actions. It includes requests for creating a child node and changing its sibling order. The 'dependsOn' property ensures sequential execution of dependent requests. ```json { "requests": [{ "id": "1", "method": "post", "url": "HierarchyDirectory(1)/Nodes", "body": { "Name": "child of A", "Superordinate@odata.bind": "Nodes('A')" } }, { "id": "2", "dependsOn": ["1"], "method": "post", "url": "$1/Hierarchy.ChangeNextSiblingAction", "body": { "NextSibling": null } }] } ``` -------------------------------- ### Example Recursive Rollup OData Query (OData) Source: https://sap.github.io/odata-vocabularies/vocabularies/Hierarchy Presents an OData query that uses 'rolluprecursive' for hierarchical data processing, combined with 'descendants', 'ancestors', and aggregation. It illustrates a more complex hierarchical data retrieval scenario. ```odata SalesOrganizations?$apply=groupby((rolluprecursive(..., ID, descendants(..., ID, filter(ID eq 'US')), ancestors(..., ID, filter(contains(Name, 'New York')), keep start))), aggregate(...)) /Hierarchy.TopLevels(..., NodeProperty='ID', Levels=2) &$top=10 ``` -------------------------------- ### OData Metadata: Instance Annotation Property Example Source: https://sap.github.io/odata-vocabularies/docs/v2-annotations This XML snippet demonstrates how to define a property in an OData metadata document that holds an instance annotation value. The 'sap:is-annotation="true"' attribute identifies the property as an annotation holder, separating it from regular data properties. This is crucial for distinguishing between metadata annotations and instance annotations. ```xml ``` -------------------------------- ### Build OData Vocabularies JSON/Markdown Files Source: https://sap.github.io/odata-vocabularies/CONTRIBUTING Executes the build process to synchronize XML source files with JSON and Markdown outputs. This command is crucial before committing changes to ensure data consistency. It is also automatically executed by GitHub Actions for pull requests. ```shell npm run build ``` -------------------------------- ### AtomPub Service Document - app:collection Element Source: https://sap.github.io/odata-vocabularies/docs/v2-annotations Explains the annotations and attributes applicable to the `app:collection` element in an AtomPub service document, including member titles, search links, and subscription links. ```APIDOC ## AtomPub Service Document - app:collection Element ### Description This section describes the annotations and attributes that can be applied to the `app:collection` element, representing a collection of resources within the service document. ### Annotations and Attributes - **``**: Defines a human-readable name or caption for individual items within the collection. This is often the singular form of the collection's title. - **`