Converts OData metadata ($metadata / EDMX) into an OpenAPI 3 specification.
This project was split out of the Axway API-Manager CLI,
which no longer imports OData metadata directly. Convert the metadata with this tool, then import the resulting
OpenAPI file with apim api import as usual.
| OData version | Supported |
|---|---|
| V2 | yes |
| V3 | no (detected and rejected) |
| V4 | yes |
Requires Java 11+ and Maven.
mvn clean packageThis creates target/apim-cli-odata-<version>-cli.jar, a self-contained executable jar.
./apim-odata.sh convert -m <file|url> [-b <backend>] [-o <file>] [-u <user> -p <password>]
# or
java -jar target/apim-cli-odata-<version>-cli.jar convert -m <file|url> ...| Option | Description |
|---|---|
-m, --metadata |
OData metadata: a local file or an HTTP(S) URL (required) |
-b, --backendBasePath |
Backend of the OData service, used as servers entry of the OpenAPI file. If omitted and the metadata is read from an HTTP(S) URL, the URL without /$metadata is used. Otherwise the file has no server. |
-o, --output |
File to write the OpenAPI 3 specification (JSON) to. Default: standard output |
-u, --username, -p, --password |
HTTP Basic credentials to read the metadata from a URL |
-h, --help |
Print help |
Logs are written to stderr, so the specification on stdout can be piped. Set LOG_LEVEL=debug for more detail.
./apim-odata.sh convert -m examples/northwind-v2-metadata.xml \
-b https://services.odata.org/V2/Northwind/Northwind.svc -o northwind-openapi.jsonThen import the result into API-Manager:
apim api import -c my-api-config.json -s api-envwhere my-api-config.json references northwind-openapi.json as its apiSpecification.resource.
APIs based on OData V2 still need the OData-Routing policy in API-Manager.
| Code | Meaning |
|---|---|
| 0 | Success |
| 1 | Invalid command or options |
| 2 | Metadata cannot be read or converted |
byte[] metadata = Files.readAllBytes(Paths.get("metadata.xml"));
ODataSpecification spec = ODataConverter.convert(metadata, "metadata.xml", "https://host/service");
byte[] openAPI = spec.getApiSpecificationContent(); // OpenAPI 3 JSON- The
apiSpecification.filterof the API config is not applied during conversion. It still works on the converted OpenAPI file when it is imported. - There is no
ImportActionTestspecial case anymore, which only existed for the former integration tests.