<?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: Janardan Joshi</title>
    <description>The latest articles on DEV Community by Janardan Joshi (@janardan_joshi_6f21026e06).</description>
    <link>https://dev.to/janardan_joshi_6f21026e06</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%2F4003327%2F9f26bd4b-a1ba-4a18-a807-dc7165b323e0.png</url>
      <title>DEV Community: Janardan Joshi</title>
      <link>https://dev.to/janardan_joshi_6f21026e06</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/janardan_joshi_6f21026e06"/>
    <language>en</language>
    <item>
      <title>The No-Panic Guide to JSON Schema Validation for REST APIs</title>
      <dc:creator>Janardan Joshi</dc:creator>
      <pubDate>Fri, 26 Jun 2026 07:38:21 +0000</pubDate>
      <link>https://dev.to/janardan_joshi_6f21026e06/the-no-panic-guide-to-json-schema-validation-for-rest-apis-3ddp</link>
      <guid>https://dev.to/janardan_joshi_6f21026e06/the-no-panic-guide-to-json-schema-validation-for-rest-apis-3ddp</guid>
      <description>&lt;p&gt;A few years ago, I shipped what looked like a textbook, harmless API update.&lt;/p&gt;

&lt;p&gt;The endpoint returned valid JSON. Every single local test passed with flying colors. We hit deploy, dusted off our hands, and went to grab coffee.&lt;/p&gt;

&lt;p&gt;Ten minutes later, Slack exploded. The frontend team was reporting errors across the entire app.&lt;/p&gt;

&lt;p&gt;The culprit? A seemingly minor refactor: I had changed a property named name to fullName, and dropped another field entirely because "surely nothing is using this anymore." (Narrator: Everything was using it.)&lt;/p&gt;

&lt;p&gt;The API wasn't throwing 500 errors. It was technically functioning perfectly—but every single client depending on that old data structure was completely broken. That’s exactly the kind of production nightmare JSON Schema is designed to kill.&lt;/p&gt;

&lt;p&gt;What is JSON Schema (and Why Should You Care)?&lt;/p&gt;

&lt;p&gt;At its core, JSON Schema is just a blueprint for your data. &lt;br&gt;
If the data doesn't fit the dress code, it doesn't get in.&lt;/p&gt;

&lt;p&gt;A quick look at a basic JSON-schema:&lt;br&gt;
{&lt;br&gt;
  "type": "object",&lt;br&gt;
  "required": ["id", "name", "email"],&lt;br&gt;
  "properties": {&lt;br&gt;
    "id": { "type": "integer" },&lt;br&gt;
    "name": { "type": "string" },&lt;br&gt;
    "email": { "type": "string", "format": "email" }&lt;br&gt;
  }&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;The Drift Dilemma&lt;/p&gt;

&lt;p&gt;Imagine your API spits out this clean response today:&lt;br&gt;
JSON&lt;/p&gt;

&lt;p&gt;{&lt;br&gt;
  "id": 1,&lt;br&gt;
  "name": "John Doe",&lt;br&gt;
  "email": "&lt;a href="mailto:john@example.com"&gt;john@example.com&lt;/a&gt;"&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;A month from now, a well-meaning developer refactors the endpoint, and it morphs into this:&lt;br&gt;
JSON&lt;/p&gt;

&lt;p&gt;{&lt;br&gt;
  "userId": 1,&lt;br&gt;
  "fullName": "John Doe"&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;To a basic uptime monitor, the API looks healthy. It’s returning a 200 OK and a valid JSON object. But your frontend applications are screaming because id became userId, name became fullName, and email vanished into the void.&lt;/p&gt;

&lt;p&gt;Without automated schema validation, you usually find out about this contract drift after your users start complaining.&lt;br&gt;
The Basics: Types, Nesting, and Strictness&lt;/p&gt;

&lt;p&gt;JSON Schema is incredibly flexible and easily maps to standard data types (string, integer, number, boolean, object, array, and null).&lt;/p&gt;

&lt;p&gt;But it’s not just about playing hide-and-seek with missing keys. Where schema validation really saves your skin is handling data integrity when things get messy under the hood.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The "Accidental String" Trap&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Type mismatches are incredibly easy to slip into a codebase during a quick refactor. For example, if someone inadvertently wraps an age in quotes—sending "25" as a string instead of a clean integer like 25—the frontend code might try to perform math on it or break entirely. A strict schema validator flags that data type shift instantly before it can wreck anything downstream.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Taming Nested Chaos&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Let's be honest: real-world APIs are almost never neat and flat. They are complex webs of nested objects and arrays. JSON Schema lets you map out these deep relationships without breaking a sweat.&lt;/p&gt;

&lt;p&gt;Take a look at how it handles a list of tags tucked inside a user profile:&lt;br&gt;
JSON&lt;/p&gt;

&lt;p&gt;{&lt;br&gt;
  "type": "object",&lt;br&gt;
  "properties": {&lt;br&gt;
    "user": {&lt;br&gt;
      "type": "object",&lt;br&gt;
      "properties": {&lt;br&gt;
        "tags": {&lt;br&gt;
          "type": "array",&lt;br&gt;
          "items": { "type": "string" }&lt;br&gt;
        }&lt;br&gt;
      }&lt;br&gt;
    }&lt;br&gt;
  }&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;If a bug in your database query suddenly returns a mixed array like ["developer", 123], the validator immediate halts the response. It knows exactly what a valid array should look like and refuses to let a rogue integer slip by.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Locking the Back Door with additionalProperties
By default, JSON Schema allows extra fields it doesn't recognize. To stop unexpected data from quietly bleeding into your responses, you can pass a secret weapon:
JSON&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;{&lt;br&gt;
  "additionalProperties": false&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;Now, if someone tries to slip unauthorized fields into the payload, the validator shuts it down. The Production Reality Check: Dynamic Data&lt;/p&gt;

&lt;p&gt;If you try to implement raw schema validation in the real world, you will immediately run into the "Dynamic Data Problem." APIs love to return things like this:&lt;br&gt;
JSON&lt;/p&gt;

&lt;p&gt;{&lt;br&gt;
  "timestamp": "2026-06-26T10:21:15Z",&lt;br&gt;
  "request_id": "7dc2c5abc123",&lt;br&gt;
  "trace_id": "abf942xyz789"&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;These values change on literally every single request. Technically the data is different, but functionally, your API isn't broken. If your validation pipeline treats every changing timestamp as a breaking change, you’ll end up with alert fatigue and a team that hates you.In practice, the trick is to validate the structure of these fields (e.g., ensuring timestamp is always a valid ISO date string) while ignoring the actual shifting value. Moving Beyond Manual Testing&lt;/p&gt;

&lt;p&gt;Manual inspection during code reviews is great, but humans are remarkably bad at noticing that a nested key changed from camelCase to snake_case at 4:30 PM on a Friday.Integrating schema validation directly into your CI/CD pipeline acts as a safety net:&lt;/p&gt;

&lt;p&gt;[Developer Commit] ➔ [Run Unit Tests] ➔ [Validate Against JSON Schema] ➔ [Safe Deployment]&lt;/p&gt;

&lt;p&gt;If a pull request accidentally breaks the data contract, the build fails before it ever touches a production server.What We Built to Solve This&lt;/p&gt;

&lt;p&gt;Wrestling with writing, maintaining, and ignoring dynamic fields across dozens of schemas is exactly why we built &lt;a href="https://fixzi.ai/" rel="noopener noreferrer"&gt;Fixzi.ai&lt;/a&gt;.Instead of forcing you to manually map out massive JSON structures or guess which fields are going to throw false positives in production, &lt;a href="https://fixzi.ai/" rel="noopener noreferrer"&gt;Fixzi&lt;/a&gt; automates the heavy lifting. It continuously monitors your live APIs, automatically maps your contracts, highlights actual breaking differences, and smartly ignores the chaotic dynamic fields (like tokens and timestamps) that you shouldn't be wasting time worrying about.It turns API validation from a tedious chore into background peace of mind.&lt;/p&gt;

</description>
      <category>json</category>
      <category>jsonschema</category>
      <category>api</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
