Last week I was working on on-boarding a few SAP Odata APIs to API Management gateway. The APIM tool used by my organization supports JSON or YAMAL specification file to on-board an API.
So, I have reached out to OpenAPI team and they informed me that Odata will soon be part of OpenAPI and mean while the below mentioned tools/process can be used to convert Odata specification to OpenAPI specification
- Odata to Open API conversion tools are available at https://github.com/oasis-tcs/odata-openapi/tree/master/tools
- Download or clone tools folder
- Create a folder and name examples at the same level as of “tools” folder. This folder is used to keep Odata Edmx files.
- If you have node installed, install the following npm packages (for windows machine)
- $ npm install -g node-gyp
- npm install --global --production windows-build-tools
- Once the above packages are installed, then open command window at the tools folder location and run npm install –g. This will install a few packages based on the package.json located at tools folder
- Once the packages are installed, to convert Odata to Open API, run the command odata2openapi -drp <<MyMetadata.xml>> (The file MUST be inside examples folder)
- By default the tool converts to Open API 3.0 specification. To convert to 2.0 (swagger) specification, use the below options
Options:
--basePath
base path (default: /service-root)
-d,
--diagram include
YUML diagram
-h,
--help
show this info
--host
host (default: localhost)
-o, --openapi-version 3.0.0
or 2.0 (default: 3.0.0)
-p,
--pretty
pretty-print JSON result
-r,
--references include references to
other files
--scheme
scheme (default: http)
-u,
--swagger-ui URL of Swagger UI for
cross-service references
- . Once the file is converted, I used swagger editor and modified a few values and finally on-boarded it to APIM