Mid-level Track Roadmap

API: schema versioning

This course covers versioning a JSON API in Rails. It starts with why a response shape is a promise to external clients, such as partner integrations. It then compares versioning in the URL path with namespaced routes against versioning in an Accept header with a registered MIME type and a routing constraint. It sets out which changes break clients and which are safe. It shows how to share Jbuilder partials and Ruby modules across versions, and how to deprecate a version with Deprecation and Sunset headers.

What you'll learn

  • ✓Why a correct change to a JSON response can still break external clients
  • ✓URL-path versioning with nested Rails namespaces and version-specific controllers
  • ✓Header-based versioning with Mime::Type.register and a routing constraint object
  • ✓Which changes are additive and safe, and which removals, renames or narrowed inputs break clients
  • ✓Sharing partials and Ruby modules across versions, and deprecating a version with Deprecation and Sunset headers
Free preview · Lesson 1 3 min read

Why an API needs a version at all

An internal HTML page can change shape overnight. Every visitor gets the new markup on the next request, because nothing outside your own deploy reads that HTML as data. A JSON API response is different as soon as one outside client parses it. Change the shape, and every client still expecting the…

Read the full lesson free →

Curriculum

7 lessons
Type to start searching...