Skip to content

Commit d6c70fd

Browse files
committed
Add post
1 parent 4925f04 commit d6c70fd

1 file changed

Lines changed: 63 additions & 0 deletions

File tree

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
---
2+
layout: post
3+
title: "OpenAPI is a cheatcode for building with AI"
4+
date: "Tue Apr 14 10:31:16 -0400 2026"
5+
categories: [development]
6+
tags: [ai, api, openapi]
7+
author: Josh Priddle
8+
tagline: "Point an AI at an OpenAPI spec and get a tested API client in any language. Pair it with Prism for cheap integration testing that keeps the AI honest."
9+
---
10+
11+
Somehow, I hadn't heard of OpenAPI until about a year ago when we started
12+
adding automated documentation to our Laravel monolith with [Scribe][].
13+
Shortly later, I started adopting AI tools in my development flow. When I
14+
needed to build some integrations with 3rd party APIs, I stumbled on their
15+
OpenAPI specs and it was a game changer.
16+
17+
Let's face it: building API clients is 90% boilerplate. Most of the time, you
18+
read docs then abstract away some patterns for auth, pagination, and error
19+
handling. Then you copy paste a bunch of methods and classes, depending on
20+
your taste, and then test and fix what the docs lied about or accidentally
21+
omitted. If you're lucky, the docs include things like headers, payloads,
22+
responses, error codes. Maybe even code snippets to SDKs, if the vendor offers
23+
them. Otherwise, you better be good at testing.
24+
25+
If you want to do an API client _well_, and perhaps even open source it, you
26+
need automated tests. That means maybe mocking responses with something like
27+
Mockery, recording responses with something like [VCR][] and tweaking your
28+
HTTP client in tests to return them, or spinning up a fake API server with
29+
something like [Prism][].
30+
31+
OpenAPI specs make custom API clients trivial with AI tools. A well defined
32+
OpenAPI spec will include all your headers, request payloads, responses, and
33+
error codes, etc. With that, you can easily point your AI of choice at an
34+
`openapi.yaml` file and ask it to generate a client in your language of
35+
choice.
36+
37+
The cool part about this, is you now have a dirt cheap way to do
38+
integration testing against a "real" API. With Prism or other tools, you can
39+
spin up a fake API server that serves the exact same responses that your
40+
client was written against. The _really_ cool thing with this, is that your AI
41+
can correct itself if it starts hallucinating or making mistakes.
42+
43+
A workflow/setup I've landed on with a few Golang CLI projects I've been
44+
working on is:
45+
46+
- Download the OpenAPI spec for whatever API
47+
- Instruct an agent to make a plan to implement that as a CLI
48+
- There's a lot of back and forth to get the overall design nailed down
49+
- Include a Bats based test suite, which...
50+
- Spins up a Prism server with the OpenAPI spec
51+
- Runs the CLI against it, and tests the output
52+
- Include standard Go unit tests, etc.
53+
54+
As an API builder, I love this flow for a couple reasons. I can build great
55+
CLIs for my users, and focus my attention on the UX and design of the CLI
56+
rather than the boilerplate. I can quickly spin up SDKs in languages that I am
57+
willing to support directly. And, if I don't feel comfortable maintaining an
58+
SDK in an unknown language, a user could also trivially generate their own
59+
client with the spec.
60+
61+
[Scribe]: https://scribe.knuckles.wtf
62+
[VCR]: https://github.com/vcr/vcr
63+
[Prism]: https://stoplight.io/open-source/prism

0 commit comments

Comments
 (0)