0% found this document useful (0 votes)
73 views

Versioning Your API: Shawn Wildermuth

This document discusses API versioning and provides examples of different versioning schemes. It notes that APIs need to evolve over time without breaking existing clients. Common versioning methods include using the URI path or query string, headers, or content type. The document demonstrates versioning an API with .NET using attributes or conventions to configure versions in controllers or payloads. It also mentions that the .NET Versioning Library supports additional approaches like versioning by namespaces.

Uploaded by

Ren
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
73 views

Versioning Your API: Shawn Wildermuth

This document discusses API versioning and provides examples of different versioning schemes. It notes that APIs need to evolve over time without breaking existing clients. Common versioning methods include using the URI path or query string, headers, or content type. The document demonstrates versioning an API with .NET using attributes or conventions to configure versions in controllers or payloads. It also mentions that the .NET Versioning Library supports additional approaches like versioning by namespaces.

Uploaded by

Ren
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

Versioning Your API

Shawn Wildermuth
MICROSOFT MVP, INSTRUCTOR, AND FILMMAKER

@shawnwildermuth wildermuth.com
Once you publish an API, it's set in stone
- Users/Customers rely on the API
- But requirements will change
What Is API - Need a way to evolve the API
Versioning? • Don’t break clients
- API Versioning isn't Product Versioning
• Don't tie them together
In .NET
- Is done with ‘package’ versions

The Problem • E.g. Assemblies

with API API versioning is harder


Versioning - Needs to support new and old users
- Side-by-side deployment isn't feasible
- Code base to support both versions
There are lots of ways to version an API
- Not all of them are recommended
API Versioning - Find a mechanism that works for you

Schemes - But remember:


• You’re serving your clients
• …not yourselves
Versioning in the URI

// URI Path
https://foo.org/api/v2/Customers

// Query String
https://foo.org/api/Customers?v=2.0
Versioning with Headers

GET /api/camps HTTP/1.1


Host: localhost:44388
Content-Type: application/json
X-Version: 2.0
Versioning with Accept Header

GET /api/camps HTTP/1.1


Host: localhost:44388
Content-Type: application/json
Accept: application/json;version=2.0
Versioning with Content Type

GET /api/camps HTTP/1.1


Host: localhost:44388
Content-Type: application/vnd.yourapp.camp.v1+json
Accept: application/vnd.yourapp.camp.v1+json
Demo

Introducing Versioning
Demo

Versioning Actions
Demo

Versioning Controllers
Demo

Versioning with Headers


Demo

Using Multiple Versioning Methods


Demo

URL Versioning
Demo

Versioning Conventions
The Versioning Library supports:
Other - Versioning by Namespaces

Versioning - Versioning with Content Type


- Writing your own Readers
Methods
- Writing your own Resolvers
What We’ve Learned

API Versioning is supported by Microsoft

You can version your URLs and your payloads

You can choose attribute or conventions for versioning configuration

You might also like