I'm confused regarding OData + ApiExplorer #841
-
It has always been a pain to integrate Swagger with OData. A few years ago, you'd need to manually ignore OData controllers, modify input and output formatters, etc. The situation seems to have improved slightly, but is still far from ideal. When using latest versions of OData and Swashbuckle, you still get zero docs regarding My understanding is that this library here fixes some of those problems, including allowing one to describe the query options per action/controller which then shows up properly in ApiExplorer and thus Swagger (at least that's what I'm seeing in the code examples). However, this is a versioning library mainly, and not an ApiExplorer/Swagger one.... I'm currently a bit confused about how I'd go to get "proper" swagger docs for OData without using versioning at all. My impression is that this library here is conflating both things, making it a requirement to have versioning in place before the various ApiExplorer OData enhancements can be used. What if I don't care about versioning, but I want a consistent swagger doc? Am I missing something here? Is it possible to get proper My quick attempt at "converting" a standard OData v8 test project here to use the 6.0.3 preview of Api.Versioning has now been very smooth... lots of things have changed dramatically between standard OData and the "API Versioning version of OData" (if you could even call it that), in particular how the EDM is generated and provided to the framework (this library seems to have completely shifted how that works by forcing one to implement configuration interfaces on a per-entity basis, kinda like EFCore config classes?). I apologize if I'm missing something obvious. I've been keeping track of this not so much for the versioning aspects but for the whole OData swagger compliance aspect. I had not used the library for versioning before so a ton of the concepts escape me. I was hoping I'd be able to tap into the ApiExplorer OData enhancements here without paying much attention to the versioning parts but it appears I was wrong: even the "simple" samples using the preview version actually seem quite complex to me even if only due to the dramatic change in how EDM is configured. Any help or clarification is appreciated. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
You are correct that is there is some overlap and conflation. There's a long history of that with the team. For years, I've tried to convince them to support the API Explorer across the board. This would make integration with OpenAPI generators and many other scenarios seamless. They hear me, but they aren't listening. Enough people have complained or asked about it that there have been incremental improvements to OpenAPI support, but it's still One of the many areas that is a problem in is what happens when you have OData mixed with non-OData APIs? The I was involved in early discussions for You are absolutely not forced to use configuration interfaces at all; that is purely a convenience. In fact, you don't even have to use the provided The
The one thing I didn't want to do is recreate the var builder = new VersionedODataModelBuilder()
{
DefaultModelConfiguration = (builder, version, prefix) => { },
}; If you didn't want to use var versions = new ApiVersion[]{ new(1.0), new(2.0), new(3.0) };
var models = new List<IEdmModel>();
for (var i = 0; i < versions.Length; i++)
{
var version = versions[i];
var builder = new ConventionsODataModelBuilder();
// TODO: use builder normally
var model = builder.GetEdmModel();
model.SetAnnotationValue(model, new ApiVersionAnnotation(version));
models.Add(model);
} Ultimately, you are right, it would be nice and should be the case that there is comprehensive support for these things in OData without API Versioning, but it doesn't exist. I've been a big fan of the OData protocol for a long, long time. That's probably the only reason it is supported at all. I'm sure someone would have asked for it eventually, but most others probably would not have supported it. My priority and goals are to API Versioning customers first. I am not opposed to a generic implementation that doesn't require API Versioning, but it's not my goal. I publicly stated in OData #332 that I would support the effort, but the response even from Sam and Mike was 🦗🦗🦗; they know me (I see that you ❤️ 'd it though 😉 ). Despite claims of being open source and accepting PRs, there is a history (still evident today) of long-running PRs that don't get reviewed or merged. That's why the Fortunately, this work could be peeled off into a new repo and library. If there are some collaborators, I could get behind that. I've been hesitant to own OData stuff because it seems to fluctuate significant since each major release. I don't have that much extra capacity to adapt to all of that. I don't want to own it. The product team should own it. Another issue is that I continue to support and have parity between ASP.NET Core and ASP.NET Web API where others seems to be content with leaving the Web API users behind. Any solution should support both. Perhaps I can consider revisiting this for the |
Beta Was this translation helpful? Give feedback.
You are correct that is there is some overlap and conflation. There's a long history of that with the team. For years, I've tried to convince them to support the API Explorer across the board. This would make integration with OpenAPI generators and many other scenarios seamless. They hear me, but they aren't listening. Enough people have complained or asked about it that there have been incremental improvements to OpenAPI support, but it's still
OData (via EDM) → OpenAPI
. There is an experimental library/repo highlighting the latest developments on that: OpenAPI.NET.OData.One of the many areas that is a problem in is what happens when you have OData mixed with non-OData APIs? The
EDM → O…