This node module converts an existing OData metadata to OpeanAPI format.
Run npm install --save odata2openapi
Use the odata2openapi
method to download a particular OData metadata and convert it.
const { odata2openapi } = require('odata2openapi');
odata2openapi('http://services.odata.org/V3/Northwind/Northwind.svc/$metadata')
.then(swagger => console.log(JSON.stringify(swagger, null, 2)))
.catch(error => console.error(error))
import { odata2openapi } from 'odata2openapi';
odata2openapi('http://services.odata.org/V3/Northwind/Northwind.svc/$metadata')
.then(swagger => console.log(JSON.stringify(swagger, null, 2)))
.catch(error => console.error(error))
Use the parse
and convert
methods if you have the metadata as XML.
const { parse, convert } = require('odata2openapi');
const xml = '';
const options = {
host: 'services.odata.org',
path: '/V3/Northwind/Northwind.svc'
};
parse(xml)
.then(entitySets => convert(entitySets, options))
.then(swagger => console.log(JSON.stringify(swagger, null, 2)))
.catch(error => console.error(error))
import { parse, convert, Options } from 'odata2openapi';
const options: Options = {
host: 'services.odata.org',
path: '/V3/Northwind/Northwind.svc'
};
const xml = '';
parse(xml)
.then(entitySets => convert(entitySets, options))
.then(swagger => console.log(JSON.stringify(swagger, null, 2)))
.catch(error => console.error(error))