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

    0.0.9 • Public • Published

    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

    Install

    npm i @tjc-group/odata-v4-service-document

    DownloadsWeekly Downloads

    0

    Version

    0.0.9

    License

    MIT

    Unpacked Size

    47.9 kB

    Total Files

    16

    Last publish

    Collaborators

    • skorolev-tjc