Git Product home page Git Product logo

Comments (4)

captainsafia avatar captainsafia commented on June 20, 2024 1

@commonsensesoftware Hopefully, yes! Trying to dust of some prototypes and figure out a plan, ATM.

from aspnet-api-versioning.

commonsensesoftware avatar commonsensesoftware commented on June 20, 2024

Unfortunately, depending on what you are doing and what you expect, some things will not work as expected. Ultimately, this is a design flaw (IMHO) with how WithOpenApi works. I've had conversations with ASP.NET team about this, but I don't believe any changes made it into .NET 8. I'm not sure if it will be tackled in .NET 9 - yet.

The problem is that WithOpenApi adds a new OpenApiOperation as metadata directly to Endpoint.Metadata. Some OpenAPI tooling, like Swashbuckle, then look directly for this metadata without consulting the API Explorer. That is a problem. API Versioning does not directly care about Swashbuckle or OpenAPI. It does explore and provide all of the metadata via the API Explorer extensions, which is directly part of ASP.NET Core. Essentially, when you call WithOpenApi, all of the other goodness is being ignored, but it's not API Versioning doing it.

That is only the tip of the iceberg. API Versioning supports interleaving multiple versions on the same endpoint. That is not supported by WithOpenApi because it will only ever create a single OpenApiOperation. This can be quite problematic. Image you had 0.9 (deprecated) and 1.0. What you'll likely see happen is 0.9 will report deprecated, but so will 1.0 because there is only a single instance.

You can set a lot of other metadata as long as you don't do it through WithOpenApi. I've seen issues like this in the past. The two can technically be used together, but you might not get the results you expect. I have not seen media type come up before, but that might have been because people were not versioning by media type and an empty content type was expected to be application/json. If you can get around not using WithOpenApi, I would recommend it.

Opening or commenting on issues in the ASP.NET Core repo is likely to get better traction than what I do on my own. Here's a few existing issues related to this area:

from aspnet-api-versioning.

commonsensesoftware avatar commonsensesoftware commented on June 20, 2024

@captainsafia it doesn't seems the OpenAPI improvements made the .NET 8 cut line. Is there an epic or plan to improve this area for .NET 9 - yet?

from aspnet-api-versioning.

victor-priceputu-tb avatar victor-priceputu-tb commented on June 20, 2024

I was using exactly this and did not understand why the documentation does not get generated properly. I removed WithOpenApi and now it generates properly. thank you for raising 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.