Git Product home page Git Product logo

Comments (5)

commonsensesoftware avatar commonsensesoftware commented on June 4, 2024 1

Ah ... I see. You may be right. Getting the behavior right for could match and could never match is tricky. In retrospect, I believe this should be 400 since it's possible to match the route, but no route is matched. The cause in this case is that the client didn't provide a version. Basically, it should be the same behavior as specifying 2.0, which is also possible, but is unmatched because there's no such implemented version.

I'll investigate further and promote this to bug after I've triaged it.

from aspnet-api-versioning.

commonsensesoftware avatar commonsensesoftware commented on June 4, 2024

Once you opt into API versioning, all API routes are explicitly versioned. This means a client cannot request a resource without explicitly providing an API version. This is why you receive a 404 when no version is specified. Unless you have existing services that didn't require versioning, I always recommend that explicit versioning be specified by clients. That provides the most reliable behavior for clients (IMHO).

In order to make your scenario work, you need to allow matching a default API version when a client doesn't specify anything. This is achieved in the setup with:

service.AddApiVersioning( options => options.AssumeDefaultVersionWhenUnspecified = true );

The choice of the default version can also be configured and is up to you. The default configured value is 1.0. There are several topics in the wiki that can guide you through some of these more advanced behaviors. I hope that helps.

from aspnet-api-versioning.

colemickens avatar colemickens commented on June 4, 2024

I understand that. I want the api-version to be required. But returning a 404 when it's absent is inconsistent, and per my last reading of the doc, not in alignment with the MS Rest API Guidelines.

from aspnet-api-versioning.

colemickens avatar colemickens commented on June 4, 2024

Well, the doc I read was fairly different and had a lot more verbiage about specific versioning behavior. Not sure if the internal one is significantly different or if it's evolved that much since I read it last.

Anyway, when I'd implemented something like this internally, we failed requests missing the header/query-param as 400s as well. I prefer that behavior. It seems more semantically consistent and less confusing to callers.

from aspnet-api-versioning.

commonsensesoftware avatar commonsensesoftware commented on June 4, 2024

Confirmed. This is a bug. It's a little surprising that I missed such an obvious case, but so is the way of software. I'm tracking the issue with a detailed explanation in #62. I should have the fix published soon. Thanks for reporting this.

from aspnet-api-versioning.

Related Issues (20)

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.