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 ๐
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