OData service metadata document

Downloads in past


920.1.66 years ago7 years agoMinified + gzip package size for odata-v4-service-metadata in KB


OData V4 Service Metadata Document
Using this module you can generate a service metadata document response from a simple JSON format, an advanced schema JSON format or an Edmx instance created with odata-v4-metadata.

Basic usage

Use the simple JSON format and convert your metadata JSON to a service metadata document. ```javascript var ServiceMetadata = require('odata-v4-service-metadata').ServiceMetadata; // $metadata express.js route app.get('/odata/\\$metadata', ServiceMetadata.defineEntities({
namespace: 'Default',
containerName: 'Container',
entities: [
name: 'Kitten',
collectionName: 'Kittens',
keys: ['Id'],
computedKey: true,
properties: {
Id: 'Edm.String',
Name: 'Edm.String',
Age: 'Edm.Int32',
Lives: 'Edm.Int32',
Owner: 'Edm.String'
{ name: 'UI.DisplayName', value: 'Meww' },
{ property: 'Id', name: 'UI.ReadOnly', value: 'true' },
{ property: 'Title', name: 'UI.DisplayName', value: 'Meww Meww' },
}).requestHandler()); ```

Advanced usage

Use a schema JSON, which is more verbose, but you can customize the metadata in a more advanced way. ```javascript var ServiceMetadata = require('odata-v4-service-metadata').ServiceMetadata; var schema = require('./schema'); var serviceMetadata = ServiceMetadata.processMetadataJson(schema); var serviceMetadataDocument = serviceMetadata.document(); ``` An example schema JSON looks like this