Service
class exposes simple api for entity sets and function imports. To explore and validate whole OData model, more powerful api can be used. Whole model is available under service.metadata.model
.
Model can contain multiple schemas, but it is very likely that service will contain just one default schema. It can be accessed like this service.defaultSchema.getEntityContainer()
.
Model implementation does some handy stuff, like resolving references to model elements so that you don't need to look it up by name.
let keyPropertyLabels = service.defaultSchema.getEntityContainer()
.getEntitySet('MySet')
.entityType
.key
.map(p => p.sap.label)
It is possible to validate service model for various requirements. That is useful especially for Fiori Elements applications services.
Following code finds all entity types that has UI visible column without label.
let missingLabelsEntityTypes = service.defaultSchema
.entityTypes
.filter(t => t.properties
.some(p => !p.sap.label && !p.hasTerm('UI.Hidden')))
});
Model implements OData CSDL protocol (combination of MS and OASIS specifications). Also SAP extensions for annotations and vocabularies are partially implemented.