Skip to content

jaystack/odata-v4-service-metadata

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

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'
            },
            annotations:[
                { 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.

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

About

OData V4 Service Metadata Document

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •