<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Sunghoon Jo </title>
    <description>The latest articles on DEV Community by Sunghoon Jo  (@josunghoon53).</description>
    <link>https://dev.to/josunghoon53</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4286610%2F494b3fea-c0cf-4f02-9f16-caaa502bf083.png</url>
      <title>DEV Community: Sunghoon Jo </title>
      <link>https://dev.to/josunghoon53</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/josunghoon53"/>
    <language>en</language>
    <item>
      <title>1 in 5 examples in GitHub's OpenAPI description don't match their own schema</title>
      <dc:creator>Sunghoon Jo </dc:creator>
      <pubDate>Sun, 06 Dec 2026 16:54:44 +0000</pubDate>
      <link>https://dev.to/josunghoon53/1-in-5-examples-in-githubs-openapi-description-dont-match-their-own-schema-55ab</link>
      <guid>https://dev.to/josunghoon53/1-in-5-examples-in-githubs-openapi-description-dont-match-their-own-schema-55ab</guid>
      <description>&lt;p&gt;I'm building a library that checks, in tests, whether API responses match an OpenAPI document. Before trusting my validator I wanted to run it on large real-world specs, so I took four public ones (five documents, since GitHub publishes two versions) and checked every example in each document against the schema next to it:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://github.com/github/rest-api-description/tree/b92256ce46b5b43d8b43e016c9a8158167a23b0a" rel="noopener noreferrer"&gt;GitHub REST API&lt;/a&gt;: the OpenAPI 3.0 description and the 3.1 one, 14.5 MB and 845 paths&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/stripe/openapi/tree/a247654c030daab5b5971d3a8d6deba1f44e6ff2" rel="noopener noreferrer"&gt;Stripe API&lt;/a&gt; (8.3 MB)&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/openai/openai-openapi/tree/d7c0e715ec6c6a06f9eb8d20cc3d5a0949a7096a" rel="noopener noreferrer"&gt;OpenAI API&lt;/a&gt; (3.1, 4.5 MB)&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/digitalocean/openapi/tree/c51fd947ea3bb0857607da2088d98cb4c7375b47" rel="noopener noreferrer"&gt;DigitalOcean API&lt;/a&gt; (3,877 YAML files joined by relative &lt;code&gt;$ref&lt;/code&gt;s)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I went looking for bugs in my library. I found more in the specs.&lt;/p&gt;

&lt;h2&gt;
  
  
  GitHub: 219 of 1,113 examples don't match
&lt;/h2&gt;

&lt;p&gt;219 of the 1,113 response examples in GitHub's description (19.7%) fail the schema they sit next to. Counting each example once, by its first problem:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;136 are missing a field the schema marks as required.&lt;/li&gt;
&lt;li&gt;45 are just &lt;code&gt;null&lt;/code&gt;, where the schema describes an object.&lt;/li&gt;
&lt;li&gt;13 match more than one branch of a &lt;code&gt;oneOf&lt;/code&gt;, which has to match exactly one.&lt;/li&gt;
&lt;li&gt;The other 25 have a value of the wrong type somewhere, such as a number where the schema expects a string.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Two of them come from endpoints you have probably called. &lt;code&gt;GET /orgs/{org}&lt;/code&gt; returns an &lt;code&gt;organization-full&lt;/code&gt;, whose schema lists &lt;code&gt;archived_at&lt;/code&gt; (a nullable date-time) as required. The example has 66 fields, and &lt;code&gt;archived_at&lt;/code&gt; isn't one of them.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;GET /meta&lt;/code&gt; documents &lt;code&gt;ssh_key_fingerprints&lt;/code&gt; as an object of strings. The example has numbers:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="nl"&gt;"ssh_key_fingerprints"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"SHA256_RSA"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1234567890&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"SHA256_DSA"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1234567890&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"SHA256_ECDSA"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1234567890&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"SHA256_ED25519"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1234567890&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;My first suspicion was my own validator. So I checked the same examples with an independent JSON Schema validator, &lt;a href="https://github.com/hyperjump-io/json-schema" rel="noopener noreferrer"&gt;@hyperjump/json-schema&lt;/a&gt;. It rejected 218 of the 219 as well. The remaining one has &lt;code&gt;"developer.github.com"&lt;/code&gt; in a &lt;code&gt;page_url&lt;/code&gt; field with &lt;code&gt;format: uri&lt;/code&gt;; hyperjump doesn't check formats by default, which explains the difference.&lt;/p&gt;

&lt;p&gt;I've reported the full list, with the first error for each example, in &lt;a href="https://github.com/github/rest-api-description/issues/7608" rel="noopener noreferrer"&gt;github/rest-api-description#7608&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  The 3.1 version fails 13 more
&lt;/h2&gt;

&lt;p&gt;GitHub publishes the same API as an OpenAPI 3.0 description and a 3.1 one. In the 3.1 version, 232 of the same examples fail. The extra 13 come from the conversion:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;nullable: true, allOf: [$ref]&lt;/code&gt; in 3.0 became &lt;code&gt;allOf: [$ref], type: ["null"]&lt;/code&gt; in 3.1. No value can pass that schema: &lt;code&gt;null&lt;/code&gt; fails the &lt;code&gt;$ref&lt;/code&gt;, and anything else fails the &lt;code&gt;type&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;nullable: true, oneOf: [...]&lt;/code&gt; became a type list with &lt;code&gt;"null"&lt;/code&gt; in it, but the &lt;code&gt;oneOf&lt;/code&gt; has no null branch, so &lt;code&gt;null&lt;/code&gt; is rejected.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Moving &lt;code&gt;nullable&lt;/code&gt; from 3.0 to 3.1 is trickier than it looks. If you convert your spec with a tool, it's worth validating the result.&lt;/p&gt;

&lt;h2&gt;
  
  
  Strict mode: fields the docs don't mention
&lt;/h2&gt;

&lt;p&gt;With strict mode, which fails on properties the schema doesn't document, 43 GitHub examples have undocumented fields, such as &lt;code&gt;template_repository&lt;/code&gt;. Stripe's spec has no examples, so I checked the fixtures Stripe publishes alongside it instead, and they too carry fields like &lt;code&gt;charge.source&lt;/code&gt; that the schema doesn't list. Real responses having more fields than the docs is common, which is why strict mode is an option in my library rather than the default.&lt;/p&gt;

&lt;h2&gt;
  
  
  OpenAI and DigitalOcean
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;OpenAI&lt;/strong&gt;: two path keys contain a query string, like &lt;code&gt;/responses?beta=true&lt;/code&gt;. A path template can't have a query, so a request to &lt;code&gt;/responses&lt;/code&gt; matches a different key. The four error examples (429 and 503) under those two keys can't be reached by any real request path.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;DigitalOcean&lt;/strong&gt;: all 968 operations are written as &lt;code&gt;get: { $ref: resources/....yml }&lt;/code&gt;. OpenAPI allows a &lt;code&gt;$ref&lt;/code&gt; for a Path Item, but not for an Operation. Tools like Redocly resolve it anyway, which is probably why nobody has noticed.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Why it matters
&lt;/h2&gt;

&lt;p&gt;Spec examples show up as-is on documentation sites, and mock servers and SDK generators use them as input. When an example doesn't match its schema, a client written from the docs can disagree with the real responses or with the generated types.&lt;/p&gt;

&lt;p&gt;The flip side is that this is easy to catch in a test: check each example in the spec against its schema. If you already have tests that compare responses with your spec, point the same validator at your examples too.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I used
&lt;/h2&gt;

&lt;p&gt;The library is &lt;a href="https://github.com/josunghoon53/openapi-matchers" rel="noopener noreferrer"&gt;openapi-matchers&lt;/a&gt;, Jest and Vitest matchers I wrote as a successor to jest-openapi, which is no longer maintained. Each spec is pinned to a commit and a SHA-256, and every failure is listed with its reason in &lt;a href="https://github.com/josunghoon53/openapi-matchers/blob/master/test/real-specs/known-issues.ts" rel="noopener noreferrer"&gt;&lt;code&gt;test/real-specs/known-issues.ts&lt;/code&gt;&lt;/a&gt;, so you can reproduce all of this yourself.&lt;/p&gt;

&lt;p&gt;If this is useful, a star on GitHub helps others find it.&lt;/p&gt;

</description>
      <category>openapi</category>
      <category>testing</category>
      <category>api</category>
      <category>javascript</category>
    </item>
  </channel>
</rss>
