WritingDigitalOcean (GradientAI)DigitalOcean (GradientAI)published Dec 5, 2025seen 5d

DoTs SDK Development: Automating TypeScript Client Generation

Open original ↗

Captured source

source ↗

DoTs SDK Development: Automating TypeScript Client Generation | DigitalOcean

© 2026 DigitalOcean, LLC. Sitemap .

Dark mode is coming soon. Engineering DoTs SDK Development: Automating TypeScript Client Generation

By mchittupolu

Published: December 5, 2025 7 min read

| undefined

) : Promise {

request . headers . add ( "Authorization" , Bearer ${ this . apiKey } ) ;

return Promise . resolve ( ) ;

}

}

This provider adds an Authorization header with the API key to each request, enabling secure communication with the API.

Setting Up the Client

Once the authentication provider is implemented, it can be passed to the Kiota-generated client during initialization. For example:

import { FetchRequestAdapter } from "@microsoft/kiota-http-fetchlibrary" ;

import { createDigitalOceanClient } from "../src/dots/digitalOceanClient.js" ;

import { DigitalOceanApiKeyAuthenticationProvider } from '../src/dots/DigitalOceanApiKeyAuthenticationProvider.js' ;

const token = 'api-key' ;

if ( ! token ) {

throw new Error ( "DIGITALOCEAN_TOKEN not set" ) ;

}

const authProvider = new DigitalOceanApiKeyAuthenticationProvider ( token ! ) ;

const adapter = new FetchRequestAdapter ( authProvider ) ;

const client = createDigitalOceanClient ( adapter ) ;

const resp = await client . v2 . droplets . post ( clientRequest ) ;

This code configures a Kiota client with API key authentication and makes a secure POST request to create a Droplet via the /v2/droplets endpoint.

Creating a DigitalOcean Droplet and Attaching a Volume:

import { FetchRequestAdapter } from "@microsoft/kiota-http-fetchlibrary" ;

import { createDigitalOceanClient } from "../src/dots/digitalOceanClient.js" ;

import { DigitalOceanApiKeyAuthenticationProvider } from '../src/dots/DigitalOceanApiKeyAuthenticationProvider.js' ;

import { Volume_action_post_attach , Volumes_ext4 } from "../src/dots/models/index.js" ;

import { v4 as uuidv4 } from 'uuid' ;

const token = process . env . DIGITALOCEAN_TOKEN ;

const sshKeyName = process . env . SSH_KEY_NAME ;

const REGION = "nyc3" ;

const authProvider = new DigitalOceanApiKeyAuthenticationProvider ( token ! ) ;

const adapter = new FetchRequestAdapter ( authProvider ) ;

const client = createDigitalOceanClient ( adapter ) ;

async function main ( ) {

// Find SSH key fingerprint

const sshKeys = await client . v2 . account . keys . get ( ) ;

const sshKey = sshKeys . sshKeys ?. find ( k => k . name === sshKeyName ) ;

// Create Droplet

const dropletReq = {

name : test- ${ uuidv4 ( ) } ,

region : REGION ,

size : "s-1vcpu-1gb" ,

image : "ubuntu-22-04-x64" ,

ssh_keys : [ sshKey ?. fingerprint ] ,

} ;

const dropletResp = await client . v2 . droplets . post ( dropletReq ) ;

const dropletId = dropletResp . droplet ?. id ;

// Create Volume

const volumeReq : Volumes_ext4 = {

sizeGigabytes : 10 ,

name : test- ${ uuidv4 ( ) } ,

description : "Block storage testing" ,

region : REGION ,

filesystemType : "ext4" ,

} ;

const volumeResp = await client . v2 . volumes . post ( volumeReq ) ;

const volumeId = volumeResp . volume ?. id ;

// Attach Volume to Droplet

const attachReq : Volume_action_post_attach = { dropletId , type : "attach" } ;

await client . v2 . volumes . byVolume_id ( volumeId ! ) . actions . post ( attachReq ) ;

console . log ( "Droplet and volume created and attached!" ) ;

}

main ( ) ;

Automated Testing

Every commit to the Dots repository, whether manually created or automatically generated, follows Continuous Integration (CI) workflows to ensure no errors are introduced. The process involves running code linters for style validation. Mocked and Integration tests are implemented and executed using Jest to ensure the reliability and stability of the client.

Mocked Tests

Mocked tests ensure that the generated client contains all the expected classes and methods for the corresponding API resources and operations. These tests focus on individual operations using mocked responses, making them fast and efficient to run as they do not require a valid token or access to actual resources. We chose Jest for this purpose because it’s fast and developer-friendly

Integration Tests

Integration tests replicate real-world scenarios where a customer interacts with the API through the client. These tests require a valid API token and create actual resources on the associated DigitalOcean account, ensuring the client behaves as expected in production-like environments.

Automated Documentation

One of the key benefits of generating a client from a single source of truth, such as the OpenAPI 3.0 specification, is the ability to produce documentation that is always aligned with the generated client. For Dots, we leveraged TypeDoc , which works seamlessly with Kiota-generated code to create up-to-date documentation, then we have incorporated this to readthedocs which hosts the documentation on every release. This ensures that developers have access to accurate and comprehensive references for the client without requiring manual updates.

CI/CD Integration: Keeping the Client Up-to-Date

Generating code is the first step of the process, automating the code generation when openAPI spec generates ensures it stays up-to-date. Using GitHub Actions, changes in the OpenAPI repository automatically initiate dots to generate libraries and push them to the Dots repository.

Kiota Behavior

Kiota applies several transformations to API responses:

Parameter Case Conversion:

Kiota automatically converts parameters from snake_case to camelCase when generating API requests. This ensures consistency with TypeScript’s camelCase conventions and helps avoid naming mismatches.

Reserved Keyword Handling:

To prevent conflicts with reserved keywords, Kiota modifies them during code generation. For example, a property like default: true is transformed to defaultEscaped: true.

Known Issues

Kiota currently generates nested value fields for nested arrays, which is a Kiota issue by design, you can find more information about the issue here

Conclusion

We are thrilled to launch Dots and provide developers with a streamlined, efficient way to interact with their APIs. By leveraging Kiota for client generation, automated workflows, and robust testing, we’ve built a solution that prioritizes reliability, scalability, and ease of use. We’re excited for users to explore Dots and see how it simplifies their development workflows. As always, we welcome feedback and look…

Excerpt shown — open the source for the full document.

Notability

notability 3.0/10

Routine technical blog post from non-AI lab