Skip to content

Latest commit

 

History

History
 
 

lib

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

Convert OData 4.0x CSDL JSON or XML to OpenAPI 3.0.x

This script converts an OData Version 3.0, 4.0, or 4.01 CSDL XML or CSDL JSON ($metadata) document into an OpenAPI 3.0.x JSON document.

It's a pure JavaScript implementation, depending only on odata-csdl, which in turn depends on sax js.

Note: this tool does not support OData 2.0, and it does not produce Swagger 2.0. If you need any of the 2.0 versions, use the XSLT-based tool.

Installation

Clone or download this repository, go to its root folder and type

npm install

To install globally type

npm install -g

Usage

Assuming you installed the script globally, and your XML metadata file is MyMetadata.xml, then

odata-openapi3 MyMetadata.xml

will create MyMetadata.openapi.json next to it.

Just type

odata-openapi3 -h

to get usage hints

Usage: odata-openapi3 <options> <source files>
Options:
 --basePath              base path (default: /service-root)
 -d, --diagram           include YUML diagram
 -h, --help              show this info
 --host                  host (default: localhost)
 -p, --pretty            pretty-print JSON result
 --scheme                scheme (default: http)
 -t, --target            target file (default: source file base name + .openapi3.json)
 -u, --used-schemas-only produce only schemas that are actually used in

If you installed the script locally, start it via

node lib/cli.js ...

Supported Annotations

The mapping can be fine-tuned via annotations in the CSDL ($metadata) XML documents.