Skip to content

Latest commit

 

History

History

lib

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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

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

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

Installation

To install globally type

npm install -g odata-openapi

Usage

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

odata-openapi3 MyMetadata.xml

will create MyMetadata.openapi3.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)
 --description           default description if none is annotated
 -d, --diagram           include YUML diagram
 -h, --help              show this info
 --host                  host (default: localhost)
 -k, --keep              root resource to keep (can be specified multiple times with one name each)
 --levels                maximum number of path segments
 -o, --openapi-version   3.0.0 to 3.0.3 or 3.1.0 (default: 3.0.2)
 -p, --pretty            pretty-print JSON result
 --scheme                scheme (default: http)
 --skipBatchPath         skips the generation of the $batch path, (default: false)
 -t, --target            target file (default: source file basename + .openapi3.json)
 --title                 default title if none is annotated

Supported Annotations

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