Connector Development Kit (CDK) - DSL Library Update (Version 2.1.0)
What’s New in CDK v2.1.0?
We have made an update to our Connector Development Kit (CDK) Domain Specific Language (DSL) library, now available in version 2.1.0.
If you’re an active user of the CDK, we strongly recommend you carefully read this update in its entirety as it contains important information on breaking changes.
This update introduces some key enhancements that streamline the handling of HTTP operations and improve overall functionality.
- Mandatory Body Specification: You now need to explicitly specify request bodies in the DSL, even if they are empty.
- Content-Type Specification: When specifying the body, the content type for both requests and responses is set, allowing the runtime to serialise or deserialise the body accordingly.
User-Facing Changes
- Request Body Specification: All request bodies must now be explicitly declared, even when empty. This is achieved using the
withoutBody()function. - Enhanced Error Handling for Responses: The
handleResponsemethod includes an additionalwithErrorHandlingmethod, allowing for custom handling of non-2xx responses. This is optional, with the default behaviour being failure on any non-2xx response. - Callback in
**parseBodyAs<Type>**Methods: This update mandates callbacks in these methods, except for JSON (and potentially files in the future), enhancing the DSL's type safety. - **Context and Input Access in
**handleResponse**: **handleResponsemethods now have access to the context and input, similar to thehandleRequestmethods. This allows for more comprehensive handling and processing of responses.
To ensure uninterrupted service and compatibility, you are required to:
- Update to the CDK-DSL library version 2.1.0.
- Make necessary changes in the
handleRequestandhandleResponsemethods as outlined above.
Breaking Changes
With this release, previous versions of the CLI will no longer be supported for deployments. Please update to version 2.1.0 and review the below Before and *After *examples to better understand the changes you need to make in your code.
-
Changes in handleRequest and handleResponse Methods:
- Before (handleRequest):
.handleRequest((ctx, input, request) => request.addPathParameter('id', input.id.toString()) - After (handleRequest):
.handleRequest((ctx, input, request) => request.addPathParameter('id', input.id.toString()).withoutBody() --> notice thewithoutBody() function - Before (handleResponse):
.handleResponse((response) => response.parseWithBodyAsJson()) - After (handleResponse):
.handleResponse((ctx, input, response) => response.parseWithBodyAsJson() )) -> notice the extra arguments and the change in position
- Before (handleRequest):