Skip to content

An easy way to model resources in C# for use with ASP.NET Web Api without having to worry about how resources will be serialized into representations, like HAL, Collection+JSON and others.

License

Notifications You must be signed in to change notification settings

aleksandro83/PointW.WebApi.ResourceModel

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PointW.WebApi.ResourceModel

** PLEASE NOTE: support for HAL is stable, but support for Collection+JSON is about 60% complete **

The goal of this project is to provide a simple abstraction for modelling resources, decoupled from formatting concerns. Your Web API application can model resources and not worry about representations or media types.

Through configuration your application will be able to support multiple media types, mixing and matching as you wish, without impacting the resource model. Through content negotiation your clients can pick supported media types they prefer.

In other words, you write this...

public class Person : Resource
{
  public string Name { get; set; }
  public string Address { get; set; }
  public string Phone { get; set; }
}  

...and your clients see this (application/hal+json)...

{
  "name": "John Doe",
  "address": "123 Main St.",
  "_links": {
    "self": {
      "href": "http://example.org/api/person/1"
    },
    "car": {
      "href": "http://example.org/api/car/1"
    }
  }
}

...or this (application/vnd.collection+json)...

{
  "collection": {
    "href" : "http://example.org/api/person"
    "items": [
      {
        "data": [
          { "name": "name", "value": "John Doe" },
          { "name": "address", "value": "123 Main St." },
        ],
        "href": "http://example.org/api/person/1",
        "links": [
          { "rel": "car", "href": "http://example.org/api/car/1" }
        ]
      }
    ]
  }
}

...or other representations.

Please see the wiki for more details.

About

An easy way to model resources in C# for use with ASP.NET Web Api without having to worry about how resources will be serialized into representations, like HAL, Collection+JSON and others.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 99.5%
  • Batchfile 0.5%