Skip to content

AntoonBeres/odata4-service-document

Repository files navigation

OData V4 Service Document

Using this module you can generate a service 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 document.

var serviceDocument = require('odata-v4-service-document').ServiceDocument;

// service document express.js route
app.get('/odata', ServiceDocument.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 ServiceDocument = require('odata-v4-service-document').ServiceDocument;
var schema = require('./schema');
var serviceDocument = ServiceDocument.processMetadataJson(schema);
var serviceDocumentJson = serviceDocument.document();

An example schema JSON looks like this

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published