Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/elasticio/odata2openapi
OData to OpenAPI Converter
https://github.com/elasticio/odata2openapi
Last synced: 3 days ago
JSON representation
OData to OpenAPI Converter
- Host: GitHub
- URL: https://github.com/elasticio/odata2openapi
- Owner: elasticio
- License: mit
- Created: 2016-07-26T10:29:14.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2021-03-23T11:49:41.000Z (over 3 years ago)
- Last Synced: 2024-10-16T04:32:45.959Z (about 1 month ago)
- Language: TypeScript
- Homepage: https://www.elastic.io
- Size: 76.2 KB
- Stars: 33
- Watchers: 13
- Forks: 23
- Open Issues: 14
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# OData to OpenAPI converter
This node module converts an existing OData metadata to OpenAPI format.
## Install
Run `npm install --save odata2openapi`
## Usage
### Converting existing XML string
Use the `parse` and `convert` methods if you have the metadata as XML.
#### JavaScript
```js
const { parse, convert } = require('odata2openapi');// Get the OData metadata as a string.
const xml = '';const options = {
host: 'services.odata.org',
path: '/V4/Northwind/Northwind.svc'
};parse(xml)
.then(service => convert(service.entitySets, options, service.version))
.then(swagger => console.log(JSON.stringify(swagger, null, 2)))
.catch(error => console.error(error))
```#### TypeScript
```TypeScript
import { parse, convert, Options } from 'odata2openapi';const options: Options = {
host: 'services.odata.org',
path: '/V4/Northwind/Northwind.svc'
};// Get the OData metadata as a string.
const xml = '';parse(xml)
.then(service => convert(service.entitySets, options, service.version))
.then(swagger => console.log(JSON.stringify(swagger, null, 2)))
.catch(error => console.error(error))
```