Happy New Year, dear readers!
The first 2021 release of the SAP Cloud SDK is here!
Both Java and JavaScript SDKs have seen important updates with supporting OpenAPI out of the box in addition to OData services and many minor fixes and improvements. We'll guide you through them in this post and help you upgrade the SAP Cloud SDK to the latest version.
Documentation
We used the quiet Christmas time to start work and release a first version of the SAP Cloud SDK
Feature Matrix. This is a convenient way to quickly find out:
- What's the difference between Java and JavaScript SDKs
- What other valuable features to leverage
- See the status of a feature
- Quick reference links and links to the documentation section to learn more
Take a look for yourself!
The SAP Cloud SDK Feature Matrix
SAP Cloud SDK for Java 3.36.0
Quick links
Support for string-based filter functions for OData v2 type-safe client
We implemented the most popular OData filtering functions for strings in OData v2.
// Filter down a BusinessPartner having "alf" in the Fist Name
// Or having it ending with "ko"
// And Last Name starting with "Mi"
service.getAllBusinessPartner()
.filter(BusinessPartner.FIRST_NAME.substringOf("alf")
.and(BusinessPartner.LAST_NAME.startsWith("Mi"))
.or(BusinessPartner.FIRST_NAME.endsWith("ko"))
)
.executeRequest(destination);
For compatibility notes, fixed issues, and improvements check
detailed release notes in the documentation portal.
For those who missed it, we now have experimental support for OpenAPI
Late in 2020, we released experimental support for the OpenAPI code generator and type-safe client. It has been already test-driven by some of our customers during 2020 SAP TechEd where we showed it for the first time in action together with OData and bound it to a simple web-shop front-end.
The following resources will help you get started with OpenAPI:
How to update?
Navigate to a root folder of your project and find a
pom.xml
file. Bump the version of
com.sap.cloud.sdk
dependency to
3.36.0
similar to the XML code snippet below and you're done! Mind, because Maven Central relying on CDN it takes a bit of time for the new
maven module to be distributed.
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.sap.cloud.sdk</groupId>
<artifactId>sdk-bom</artifactId>
<version>3.36.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
<!-- possibly further managed dependencies ... -->
</dependencyManagement>
If for some reason your IDE hasn't fetched an updated dependency version, run
mvn clean install
from the command line in the root directory of your project.
SAP Cloud SDK for JavaScript
Quick links
We released an experimental OpenAPI code generator and type-safe client
To complement our OData offering we release an
OpenAPI type-safe client and code generator. This allows covering up to 80% of modern APIs published by SAP products and services. Another great news is that this feature is 100% Open Source.
Despite not yet ready for production use, you can give it a try with PoCs and test projects.
Generating your OpenAPI type-safe client
Run this command to install the OpenAPI generator globally:
npm i @sap-cloud-sdk/openapi-generator -g
Then you can generate an OpenAPI client via:
generate-openapi-client -i directoryWithOpenApiFiles -o outputDirectory
You can also invoke code-generator programmatically like this:
import { generateClients } from '@sap-cloud-sdk/openapi-generator'
const generatorOptions = {
inputDir: 'directoryWithOpenApiFiles';
outputDir: 'myOutputDirectory';
}
generateClients(generatorOptions)
Here's how you make calls to OpenAPI services via a type-safe client
GET all entities:
import { TestServiceApi } from './outputDirectory/test-service';
const allTestEntities = await TestServiceApi.getAllEntities().execute(
myDestination
);
GET entity by id:
import { TestServiceApi } from './outputDirectory/test-service';
const myEntity = await TestServiceApi.getEntityByKey('myId').execute(
myDestination
);
POST request looks like this:
import { TestServiceApi, TestEntity } from './outputDirectory/test-service';
const testEntity: TestEntity = {
keyProperty: 'some-id-in-uuid-format',
stringProperty: 'myProperty'
};
const createResponse = await TestServiceApi.createEntity(testEntity).execute(
restDestination
);
Give it a test-drive with your favorite service from the SAP API Business Hub.
Check more details in the
documentation on the OpenAPI type-safe client and give us feedback.
How to update?
To update the version of the SAP Cloud SDK for JavaScript used in an existing project, use the command
npm update
in the root folder of your module. Note that this will also update other modules unless you explicitly specify which packages to update. If you want to check beforehand what will change, use
npm outdated
.
Additionally, you can consult
NPM for more information on version history and update path.
Feedback
We hope you enjoy developing with
SAP Cloud SDK! To help us further improve give your ideas and suggestions in the comments to this blog or create an issue in our
GitHub repository.
All the best,
SAP Cloud SDK Team