Giter VIP home page Giter VIP logo

aspnet-url-versioning's Introduction

Build status

ASP.net API Versioning - URL segment extensions

This library is an extension to the ASP.NET API versioning library of Microsoft addressing missing features on URL segment based versioning.

Be aware that this framework performs some initialization steps that might already be present in your startup sequence. Please ensure the following criterion are met:

  • No AddApiVersioning call is made if you use AddApiVersioningWithUrlSupport. AddApiVersioningWithUrlSupport will internally call the AddApiVersioning
  • No MapHttpAttributeRoutecall is made if you use AddApiVersioningWithUrlSupport. AddApiVersioningWithUrlSupport will internally call the MapHttpAttributeRoute with a custom route provider.
  • No custom controller selector is registered. ASP.net API versioning comes with a special controller selector handling all neccessary versioning rules.

It adds support for the following features.

Default API version in URL segments

Currently ASP.net API versioning cannot handle default version numbers for routes that have the API version in the URL segment. If you define a route like /api/v{version}/Controller/Action the AssumeDefaultVersionWhenUnspecified option will not ensure that /api/Controller/Action will point to the action implementing the default version.

configuration.AddApiVersioningWithUrlSupport(o =>
{
    o.VersioningOptions.DefaultApiVersion = new ApiVersion(3, 0);
    o.VersioningOptions.AssumeDefaultVersionWhenUnspecified = true;
});

This extension is related to dotnet/aspnet-api-versioning#73

ApiExplorer implementation for SwashBuckle compatibility.

The default ApiExplorer implementation that comes with ASP.net Web API struggles generating the API descriptions for all versions. By providing a custom ApiExplorer implementation this library ensures that components using the ApiExplorer can access the individual versions. Note that also this extension focuses on URL segments and will not generate individual entries for Query String or Header based versioning.

configuration.AddApiVersioningAwareApiExplorer(o => {
    // in combination with the "Default API version in URL segments" extension you might want to prevent the default version routes
    // to be excluded from the API schema. 
    o.IncludeDefaultVersion = false; 
    // ASP.net API versioning supports /v3/ and /v3.0/ if you set this option to true
    // the API schema will try to shorten the versions by omitting the minor version part. 
    o.PreferShortHandVersion = true;
});

This extension focuses on the compatibility with SwashBuckle and is related to dotnet/aspnet-api-versioning#60

aspnet-url-versioning's People

Contributors

danielku15 avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

uuace

aspnet-url-versioning's Issues

Version parameter is still part of the ApiDescription

Even though the Route Template does not contain the API version anymore, there is still a version parameter in the ApiDescription. This will cause Swashbuckle to generate a body-parameter named version. The version parameter needs to be filtered.

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.