OData / OData/AspNetCoreOData

Envelope Odata-responses

Open
#176 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
505
Forks
186
PR merge metrics
No merged PRs in 30d

Description

I added Odata to my project so I can use the url-query-parameters like $filter. With the .net Web-API demo-class/controller, the output now looks like this:

{
  "@odata.context": "https://localhost:5001/api/v1/$metadata#WeatherForecast",
  "value": [
    {
      "Id": 1,
      "Date": "2021-05-22T14:00:18.9513586+02:00",
      "TemperatureC": 36,
      "Summary": "Sweltering"
    },
    {
      "Id": 2,
      "Date": "2021-05-23T14:00:21.6231763+02:00",
      "TemperatureC": 44,
      "Summary": "Chilly"
    }
  ]
}

So far, so good, that works.

Our frontend-team that consumes my API now wants something like an envelope.. They want to get the result like this:

{
    "data": {
        "type": "WeatherForecast",
        "count": 2,
        "items" : [
            {
              "Id": 1,
              "Date": "2021-05-22T14:00:18.9513586+02:00",
              "TemperatureC": 36,
              "Summary": "Sweltering"
            },
            {
              "Id": 2,
              "Date": "2021-05-23T14:00:21.6231763+02:00",
              "TemperatureC": 44,
              "Summary": "Chilly"
            }
        ]
    },
    "error": null
}

Is there a possibility on how I can do this using OData? I found the ODataEntityTypeSerializer-class but it doesnt exist in v8. Any idea? Or even an example? :)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the .NET Web API demo controller and the ODataEntityTypeSerializer reference in the issue, then inspect how response serialization works in v8. Determine whether the requested data/error envelope is supported and what extension point would be needed; done means a documented example or a clearly confirmed limitation.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
api, backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.