How to configure a named resource stream using OData in ASP.NET Web API - asp.net-web-api

I am creating OData endpoints using ASP.NET Web API using v5.8.0 of this NuGet package. I have everything working and I can retrieve simple data such as strings and ints without an issue. However I would now like to extend one of the endpoints so that one of the items that can be retrieved is a binary image file. Having read up on OData I have decided to use named resource streams to achieve this.
The problem I have is that I can find very little information on how to implement this using the ODataController. The closest I can find is this blog post but it is using an older version of Web API and the code does not compile when I use it in my project.
So can somebody please supply a working example of how this should be implemented please.

Named streams (aka stream properties) are not currently supported in Web API OData (for OData v4). See the following issues:
Clarify the situation for streams
Document for Stream Support in OData V4

Related

Using Java functional API with Spring Cloud Data Flow and Polled Consumers

I am working on a project that is trying to use the polled consumer API. However, existing documentation, blog posts and sample code seems to use deprecated annotations (such as org.springframework.cloud.stream.annotation.Input). This seems to be because they are relying on the older style of Spring Cloud stream applications rather than using Java functional api (e.g., java.util.function.Function), as shown in other examples such as this one, given in the same repo.
Is there a way to use functional style with polled consumers in Spring Cloud Stream?
You are using outdated documentation. The most current is available from the project site - https://spring.io/projects/spring-cloud-stream#learn.
The section you are looking for is - https://docs.spring.io/spring-cloud-stream/docs/3.1.5/reference/html/spring-cloud-stream.html#spring-cloud-streams-overview-using-polled-consumers

Is there any way to create API documentation for graphql end points in a spring boot project

I have a springboot microservice project and I am using graphql. For REST api end points I am aware that we can document using swagger etc.. Graphiql also provides dynamic documentation but is there any other way to create API documentation for the customers who are not so aware of how graphql or Graphiql works.
aaah that might help: You can get (and print) the generated schema programatically:
How to get the generated scheme file .graphqls using SPQR?

Is it possible to create Swagger documentation in separate project for Asp Web Api?

Is it possible to generate a Swagger documentation for my ASP.Net Web API in a separate project?
I created an empty project where the Swagger documentation should go. In the API project the Swagger project is referenced, but didn't work.
Than API project is load like an external assembly. The controllers was reachable, but documentation wasn't generated.
Then tried with the automatically generated XML documenatation, just to see if it will create anything, but there is no result.
After this try like to have multiple API in one Swagger documentation, Multiple API documentation in one Swagger file, wasn't work.
I also tried this:
ApiExplorer for WebAPI controllers in external assembly
https://github.com/Microsoft/aspnet-api-versioning/issues/271
On the Swagger official documentation I didn't find something that could help me with this. Neither did I find any information elsewhere if this is possible and how it needs to be done.
I use Swashbuckle 5.6.0 and ASP.Net Web API.
Yes, it is possible to generate Swagger documentation for a Web API in a separate project.
Here I have the code showing how I did it:
https://github.com/heldersepu/csharp-proj/tree/master/Swashbuckle.Sample
And here is how the swagger-ui looks like:
http://swashbucklesample.azurewebsites.net/swagger/ui/index
To be honest Nothing special about that code, it worked on the first try for me ...
But I do have some experience with Swashbuckle
If you can provide a minimal project reproducing your issue, we can help you get to the bottom of it together.

Spring MongoDB REST API without HAL?

This Guide shows how to easily create a RESTful interface to a Mongo Database. It produces Json-data in HAL format(Hypertext Application Language), but unfortunately I am unable to find a working Android Client that supports HAL.
Is there any way to disable this HAL format an just GET the documents from the DB without any extra? So that it can be directly parsed into my datatype classes?
It would be really nice to use this approach to somehow automatically generate the REST interface, I cannot go back to manually writing all the methods in controllers after seeing this very short code.
This post seems to deal with the same topic, but I do not understand how to do this configuration.
The guide you are linking to is specifically aimed at using Spring Data REST + Spring Data MongoDB, so to disable the hypermedia for a project designed to generate hypermedia, i.e. a RESTful interface, sounds very strange.
On a mobile platform like Android, the question is what are you trying to do? Are you trying to query for a single, small piece of JSON from MongoDB? The risk of not having any type of hypermedia layer in the middle is that you could query for a giant (i.e. humongous data set) and cripple both the server and mobile device.
For more details about hypermedia and Spring Data REST, check out Oliver Gierke's answer at Disable Hypertext Application Language (HAL) in JSON?.
Regarding the ability to communicate between Android and a HAL backend, of course it's possible. You may wish to look at Roy Clarkson's sample Android app used to talk to a HAL backend that was used at SpringOne 2014 at https://github.com/SpringOne2GX-2014/spring-a-gram-android.
The slides from that presentations are at https://speakerdeck.com/gregturn/springone2gx-2014-spring-data-rest-data-meets-hypermedia.

Queryable Web API 2 OData serialization

I have a lighweight setup where I am using Web API 2 with OData but do not create an "/odata" endpoint with its accompanying "/odata/$metadata" but instead just use standard ApiController's with attribute routing and Get methods marked with an override of [Queryable]: [InlineCountQueryable] detailed here Web API, OData, $inlinecount and testing.
It all works very well except that I can only expose dedicated model classes without any collections or object properties because the JSON serializer serializes the whole object graph. My ideal behavior would be to just have all collections ignored completely and object properties only included on $expand.
I believe this can be made to work because an OData Web Api 2 scaffold VS 2013 creates over an entity framework context has similar behavior, but I would like to keep this as lean as possible and avoid going that route as I found it to be a bit brittle and this service does not need to expose a $metadata description.
Update
I did some digging in the aspnet samples and found the "CustomODataFormatter" sample which seems to expose the machinery I would need to modify.. however the ODataSerializerProvider/ODataSerializer setup outlined there does not work with with attribute routing at all (any method defined with [Route("Some/Url")]).
Given that this seems to be what I need, does anyone know if attribute routing and the odata serializer provider mechanism should work together?
[JsonIgnore] or [DataMember] can be used to ignore properties for json.net serializer. webapi.odata 5.2 supports ODataRouteAttribute, an example is here.

Resources