Background image
Featured blog post image

API Change Detection & Open Enums

New features to the Speakeasy Platform - May 29, 2024

Two exciting new features are coming to Speakeasy this week: API Change Detection and Open Enum support.

Letโ€™s get into it ๐Ÿ‘‡

API Change Detection

For as long as there have been APIs, the dreaded โ€œunintended breaking changeโ€ has tortured API developers everywhere. Countless hours spent debugging, untold numbers of damage control meetings with unhappy customers, the inevitable โ€œwho broke the API?โ€ finger-pointing; itโ€™s not pretty.

And yet decades later, it still feels like itโ€™s needlessly difficult for organizations to get good observability into how their API is changing. This is why weโ€™re so excited to be tackling this problem head-on. Todayโ€™s release of API change detection is just the beginning.

Whenever thereโ€™s a change to your OpenAPI document, Speakeasy will automatically detect it and notify you. The changes will be summarized directly in your pull request, with a callout for when changes are breaking. If you want to dive into the details, head to our dashboard for the full breakdown.


import { SDK } from "@acme/cms";
import { Unrecognized } from "@acme/cms/types";
const cms = new SDK();
const post = await cms.posts.get('open-enums');
let icon: "๐Ÿ“ธ" | "๐ŸŽจ" | "๐Ÿˆ" | "โ“";
switch (post.category) {
case "lifestyle":
icon = "๐ŸŽจ";
break;
case "photography":
icon = "๐Ÿ“ธ";
break;
case "sports":
icon = "๐Ÿˆ";
break;
default:
post.category satisfies Unrecognized<string>;
icon = "โ“";
break;
}

Open Enum Support

Both the power and the pain of enums come from their rigidity. Defining a fixed scope helps guide users towards intended use cases and makes enhanced type-safety possible. But the time will come when you need to alter the accepted values of an enum in your API, and it will be painful. How do you alter the set of accepted values without breaking existing code?

To soften the pain, some languages have native support for the concept of โ€œopenโ€ enums (other languages donโ€™t, but you can achieve the same results with custom classes). Open enums allow for unknown values to be passed through without erroring. For APIs that are rapidly evolving, this can help prevent some of the typical pain associated with making changes.

And now for TypeScript, Python and Go, Speakeasy supports open enums. You can use our new extension: x-speakeasy-unknown-values: allow and your SDK will generate a type that includes the enum values and a catch-all type that represents any unrecognized value. This allows you to handle unknown values gracefully in your code.

For the deep dive, read our release post


๐Ÿšข Improvements and Bug Fixes ๐Ÿ›

Info Icon

NOTE

Based on the most recent CLI version: Speakeasy v1.297.0 (opens in a new tab)

The Platform

๐Ÿšข Standardize publishing secret names created by configure publishing command
๐Ÿ› Circular reference handling within unions
๐Ÿ› Donโ€™t panic on bad validation lineNums
๐Ÿ› ClientCredentials hooks incorrect import
๐Ÿ› Mitigations for Github rate limiting
๐Ÿ› Nested namespaces in usage snippets

Typescript

๐Ÿ› Jest compatibility fixes and leaner error models for Typescript
๐Ÿšข Safer weakly typed unions

Go

๐Ÿšข Support Open Enums in Golang
๐Ÿšข Safer weakly typed unions
๐Ÿšข Support pointer request objects

Terraform

๐Ÿšข Improve terraform diff suppression by instantiating arrays to []
๐Ÿ› Fix Set datatype in Terraform

Java

๐Ÿšข Sandbox (Dev Containers) support for Java
๐Ÿšข Support for Server Sent Events
๐Ÿ› Correct logic when retries and pagination are used together

C#

๐Ÿšข .NET8 LTS support for C#
๐Ÿšข Simplify SpeakeasyHttpClient configuration
๐Ÿ› General Usage snippet reliability improvemenets
๐Ÿ› Flattened security field sanitizing in usage snippets C#

Python

๐Ÿšข Support Open Enums in Python