The generator allows you to generate custom OData client libraries for OData services. You can then easily access these services via the client libraries.
The SAP Cloud SDK generator can both be used as a command-line interface (CLI) and programmatically.
All you need to use it is a service metadata specification in the
EDMX format (file ending can be
Run this command in your project's terminal to install the generator globally.
The generator is included in the SAP Cloud SDK CLI. If you installed the CLI, you don't need to install the generator separately.
The SAP Cloud SDK generator is primarily intended to be used on the command line.
path/to/your/service-specifications to the directory containing your service specifications in
EDMX format, for example
service-specifications/. Also adapt
path/to/store/generated/modules to your OData client directory for example
This will generate OData clients for all your service specifications and create a
serviceMapping.json in your input directory. This file is used for generation and contains a mapping from the original file name to the following information:
directoryName- the name of the subdirectory the client code will be generated to.
servicePath- the URL path to be prepended before every request. This is read from the EDMX file if available, otherwise, the value here will be
VALUE_IS_UNDEFINED. In that case, it should be adjusted manually.
npmPackageName- the name of the npm package, if a
package.jsonis generated. This information is optional.
This information can be adjusted manually and ensure that every run of the generator produces the same names for the generation.
By default, the generated module contains the following sources:
- TypeScript code
- Type definition files
- Source map files
Depending on which of those files you need, you can skip the generation of most of those - see the options below.
generate-odata-client --help for further options.
|-||This directory will be recursively searched for .edmx/.xml files.|
|-||Directory to save the generated code in.|
|Configuration file to ensure consistent names between multiple generation runs with updated / changed metadata files. Will be generated if not existent.|
|-||Exit when encountering a file that already exists. When set to true, it will be overwritten instead. Please note that compared to the --clearOutputDir option, this will not delete outdated files.|
|-||Deletes EVERYTHING in the specified output directory before generating code.|
|-||Generate a .npmrc file specifying a registry for @sap scoped dependencies.|
|-||Generates a typedoc.json file for each package, used for the corresponding "doc" npm script.|
|-||Generate a package.json file, specifying dependencies and scripts for compiling and generating documentation.|
|-|| By default, when generating |
|-||Generates transpiled .js, .js.map, .d.ts and .d.ts.map files. When set to false, the generator will only generate .ts files.|
|-||A CSN file will be generated for each service definition in the output directory.|
You can also use the generator programmatically. You will have to provide the options.