@tjc-group/odata-v2-service-metadata
TypeScript icon, indicating that this package has built-in type declarations

0.0.8 • Public • Published

OData V2 Service Metadata Document (limited)

The package is based on odata-v4-service-metadata package. We need to generate OData V2 metadata. Currently its capabilities are limited: we only process Entities and Associations.

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('@tjc-group/odata-v2-service-metadata').ServiceMetadata;
var schema = require('./schema');
var serviceMetadata = ServiceMetadata.processMetadataJson(schema);
var serviceMetadataDocument = serviceMetadata.document();

An example schema JSON looks like this

Package Sidebar

Install

npm i @tjc-group/odata-v2-service-metadata

Weekly Downloads

1

Version

0.0.8

License

MIT

Unpacked Size

253 kB

Total Files

39

Last publish

Collaborators

  • skorolev-tjc