Which WebApi OData namespace - odata

Which namespace should I be using for the latest Microsoft Web API OData:
System.Web.Http.Odata or System.Web.Odata?
The same classes appear in both namespaces, but I have not found anything directly stating which one to use.
I did find this article where the code examples are using System.Web.OData:
http://www.asp.net/web-api/overview/odata-support-in-aspnet-web-api/odata-v4/create-an-odata-v4-endpoint
I just want to be sure.

There exist two namespaces and assemblies because the two versions of OData are incompatible, though they can be used side-by-side.
Use System.Web.Http.OData for OData v3 and use System.Web.OData for OData v4.
You can read more about this on this blog post: http://blogs.msdn.com/b/webdev/archive/2014/03/13/getting-started-with-asp-net-web-api-2-2-for-odata-v4-0.aspx
You can find samples for Web API OData v3 and OData v4 here: https://github.com/OData/ODataSamples/tree/master/WebApi

Related

How to document OData endpoints (swagger, swashbuckle, other)?

What is the best way of documenting OData endpoints?
Is there a way to use Swashbuckle for it?
Yes, try Swashbuckle.OData. It adds Swashbuckle support for ODataControllers.
See it in action here: http://swashbuckleodata.azurewebsites.net/swagger
Yes, we are trying to support it like yaml -> Swagger, yaml -> csdl ..
But it will need time to implementation, you can see a prototype and track there https://github.com/OData/model-first
I actually got something working for this using the IDocumentFilter function within Swashbuckle. I answered a similar question on the GitHub repo for Swashbuckle. Check out my response here (it's either at bottom or toward bottom):
https://github.com/domaindrivendev/Swashbuckle/issues/149
I've posted an example of a working IDocumentFilter implementation that you could leverage to get your OData endpoint set up in the Swagger ui.
Asp NET and Asp NET Core Api Versioning
You can use Api Versioning (as it extends ApiExplorer with Odata information) for both WebApi and AspNetCore.
There are samples available for both:
WebApi
Asp Net Core
This sample how it integrates well with Swashbuckle/Swagger ui.
The easiest way to do that I found is to convert OData definition to Open API spec using https://github.com/oasis-tcs/odata-openapi
Then import the spec document into swagger is very easy.

Will OData Service implement both metadata document and service document definitely?

I'm new to the OData protocol.
I saw that it seems like there are 2 types of well-defined resources that describe the OData Service Data Model, which are Service Document and Metadata Document.
But I want to know that if both of these two resources can be found at the OData Service definitely / for sure?
Since I did not see any restriction from the OData specifications that OData Service must fulfil these 2 resources together during implementation, I guess that there is only one type of Service Data Model that can be found from service.
I really appreciate if any one can help to clarify it.
Thanks!
It depends on which libraries is used to implement the OData service. For example, if the service is implemented using ASP.NET Web API for OData or RESTier, the two documents will both exist for sure.

OpenUI5 Support for OData v4?

I was trying to use OpenUI5 with a .NET OData v4 Web API service. It looks like the client embeds the "Max OData Service Version" header with the HTTP request by default and my service doesn't like that. Additionally, documentation notes support for v2 experimental v3.
Does anyone know when support for v4 is expected?
Thanks so much!
There are people working on the v4 support, but don't expect it to be available in the next few months.
Currently a new version of the v2 model is being implemented that has performance optimizations and better batch support, after that one is finished I guess the v4 support will be an important part of the agenda.
OData V4 finaly just got released.
https://sapui5.netweaver.ondemand.com/sdk#docs/api/symbols/sap.ui.model.odata.v4.ODataModel.html
But keep in mind what Jens Ittel said:
[...] Due to its limited feature scope, we will not recommend to use
the first of these releases of the model implementation for productive
usage. [...]

Different Between OData And GData

What is different between OData and GData?
Does OData has more advantages in .NET technologies vs GData or not?
In my WCF project I want to create IQueryable models and REST platform for client,I used to OData before but I'm excited to know more about GData and it's features.
GData is obsolate and doesn't have such a wide support as OData - "Warning: Most newer Google APIs are not Google Data APIs." - Google Data Protocol Page

creating OData like services using RESTlet

I am trying to build a OData interface for Java application.
From what I have seen, one can create fully compliant OData services using microsoft technologies (aka visual studio) using their WCF services. Am I of the right impression?
I am trying to simulate OData services (it is also RESTful) using RESTlet + ROME(for atom feeds) + ROME Propono (for atompub service document). OData specification says that I canm access individual objects of a collection like http://mysite/service.svc/products(1)
Is there a way to represent this in RESTlet?
router.attach("products(id)") will not work
router.attach("products/get/{id}") is not really OData like.
Do you have any suggestions? Am I even doing it right?
Regards,
D
Have you tried this URI template?
router.attach("products({id})")

Resources