Giter Site home page Giter Site logo

jsakkie / versioned-rest-api Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ridgidsoftwaresolutions/versioned-rest-api

0.0 1.0 0.0 572 KB

Provides annotations to use in your .NET Web API 2+ controllers to help with versioning

License: Other

C# 88.30% CSS 1.25% ASP 0.06% JavaScript 10.38%

versioned-rest-api's Introduction

Build status NuGet version Nuget downloads

What is versioned-rest-api?

versioned-rest-api is a tiny library which provides a single attribute for handling versioning of your Web API via the URI. This is useful if you have a public-facing API and need to maintain versions for backward compatibility.

Why would I version my API using the URI?

Versioning your API via the URI is actually a very simple and explicit approach to versioning. A URI like /api/v3/Chickens/ is clearly using version 3 of the API.

How does it work?

When you add a NuGet reference to versioned-rest-api it will add a new appSetting called currentApiVersion, which will start off with a value of "1". This represents the most recent version of your API. You can then annotate your Web API actions with the [ApiRoute] attribute to indicate that the action is versioned. See examples below:

NuGet

Check out the NuGet page for this package

Examples

This annotation will make the action respond to any versioned request for this resource. Any API action that has never had a breaking change could use this attribute.

  [ApiRoute("Chickens/")]
  public IList<Chickens> GetAllChickens()
  {
    //query for and then return all chickens
  }

Assuming currentApiVersion in the config is set to "3", then the above action will be invoked for requests to:

  /api/v1/Chickens/
  --OR--
  /api/v2/Chickens/
  --OR--
  /api/v3/Chickens/

For check out this code for more examples. You can also fire up the VersionedRestApi.Examples.cs project to see some ajax requests to an example API in action.

versioned-rest-api's People

Contributors

jakejgordon avatar dseymour avatar jsakkie avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.