Skip to content
| Marketplace
Sign in
Visual Studio Code>Snippets>CDS API ToolsNew to Visual Studio Code? Get it now.
CDS API Tools

CDS API Tools

ROBOT

|
423 installs
| (0) | Free
VS Code extension of CDS API Tools
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

CDS API Tools Vscode Extension

Description

VS Code extension for CDS API Tools, which help to parse CDS openAPI files and generate Odata API in JS/Mocha/Cucumber code and chai-http request code. Also support common RESTful API now.

Installation

From vscode marketplace(recommand):

  1. Search CDS API Tools in the marketplace, click 'install'.

From vsix file:

  1. Download cds-api-tools
  2. Open Visual Studio Code, click Settings icon and choose Extensions, click 'Views and More Actions' button, select 'Install from VSIX...', then choose vsix file, and install. You will see extension installed successfully in activity bar.

Usage

CDS API

  1. Install @sap/cds-dk module globally
    npm i -g @sap/cds-dk
    
  2. Add git repo which includes cds files. Such as:
    # please make sure you have the access to clone the git repo
    git@github.com:SAP-samples/odata-basics-handsonsapdev.git
    
  3. Select a service interface, choose method, and click 'Generate' button, you will see a parameters panel.
  4. You can change path, headers and other params, click 'Send' button, an Odata request will be sent.
  5. Click 'Cucumber Snippert', 'JavaScript Snippet', 'Mocha OData' or 'Mocha Chai' button, responding code snippet will be generated.

RESTful API

  1. Click 'airplane' icon, open REST Request home page.
  2. You can change url, headers and other params, click 'Send' button, an RESTful API request will be sent.
  3. Click 'Cucumber Snippet' button, 'JavaScript Snippet' button, 'Mocha OData' button, 'Mocha Chai' button, generate API request in JS/Mocha/Cucumber/Chai code.

Sample Scenario

Background

odata-basics-handsonsapdev contains a simple OData service to accompany the "Back to basics: OData" series on the Hands-on SAP Dev live stream show. Below we use this project as the target project to implement some API tests and automation scripts on testing project(you need provide one). Thus btp-showcase-actuals-cap project will be used as a local server to handle API requests during API test-automation. Server will listening on { url: 'http://localhost:4004' } after started(command: cds run).

Deploy and start local cds server

cds server will listening on { url: 'http://localhost:4004' } after follow:

  1. git clone git@github.com:SAP-samples/odata-basics-handsonsapdev.git
  2. npm i -g @sap/cds-dk
  3. npm install
  4. cds deploy --to sqlite
  5. cds run

Add project into cds-api-tool

To help generate API request, we need an input of the target project git repo at the beginning, in this scenario is:

    git@github.com:SAP-samples/odata-basics-handsonsapdev.git

Then you can choose service, api, method you want, input params, send request to verify results, and generate your code!

Sample Data

  • Get Products List
    service: NorthwindModel
    api: /Products
    method: GET
    /** optional query **/
    $top: 10
    $count: true
    $orderby: ["ProductID desc"]
    $select: ["ProductID", "ProductName", "QuantityPerUnit","UnitPrice","Category_CategoryID","Supplier_SupplierID","UnitsInStock","UnitsOnOrder","ReorderLevel", "Discontinued"]
    $expand: ["*","Category","Supplier"]
  • Create Product
    service: NorthwindModel
    api: /Products
    method: POST
    body:{
	    "ProductID": 111,
	    "ProductName": "car",
	    "QuantityPerUnit": "100",
	    "UnitPrice": "20.0"
    }

FAQ

1.Why didn't I generate openAPI files after I add git repo?

A: Please confirm your local @sap/cds-dk module is installed and up to date. Command: npm i -g @sap/cds-dk If it's done and still not work, please try to execute below commands temporarily, and contact our team.

cd ./.vscode/api-vsix/repo
git clone [your-repo]
cd [your-repo] && cds compile srv --to openapi -s all -o ../../openapi/[your-repo] --openapi:diagram

Then toggle to API List view and click refresh button.

2.Send request error as follow:

Error: connect ECONNREFUSED 127.0.0.1:4004

A: Please confirm cds server is deployed and started.

3.Why is there no 'Cucumber snippet' button in the panel?

A: Please confirm the x4-uat-frw module is listed in your project package.json dependencies.

4.Run 'npm start' error as follow:

SyntaxError: Unexpected token '.'

A: Please upgrade Node.js version later than 14.

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft