{"id":19991377,"url":"https://github.com/sciensoft/hateoas","last_synced_at":"2026-02-13T16:16:06.390Z","repository":{"id":38026199,"uuid":"174415725","full_name":"sciensoft/hateoas","owner":"sciensoft","description":"A library to help you achieve HATEOAS using a fluent language and lambda expression for configuring your ASP.NET Core RESTful/Web APIs. Based on the REST application architecture style, Uniform Interface, constraint Hypermedia As The Engine Of Application State (HATEOAS).","archived":false,"fork":false,"pushed_at":"2023-11-20T18:02:14.000Z","size":786,"stargazers_count":19,"open_issues_count":6,"forks_count":6,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-04T04:47:11.708Z","etag":null,"topics":["aspnetcore","csharp","dotnetcore","hateoas","restful","restful-api","webapi"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sciensoft.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE-OF-CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-03-07T20:31:59.000Z","updated_at":"2025-02-06T22:47:47.000Z","dependencies_parsed_at":"2023-01-24T15:45:44.356Z","dependency_job_id":null,"html_url":"https://github.com/sciensoft/hateoas","commit_stats":null,"previous_names":["higtrollers/sciensoft.hateoas"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sciensoft%2Fhateoas","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sciensoft%2Fhateoas/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sciensoft%2Fhateoas/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sciensoft%2Fhateoas/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sciensoft","download_url":"https://codeload.github.com/sciensoft/hateoas/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252320290,"owners_count":21729101,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aspnetcore","csharp","dotnetcore","hateoas","restful","restful-api","webapi"],"created_at":"2024-11-13T04:51:43.749Z","updated_at":"2026-01-17T14:43:21.044Z","avatar_url":"https://github.com/sciensoft.png","language":"C#","funding_links":[],"categories":["C\\#"],"sub_categories":[],"readme":"# Sciensoft.Hateoas\r\n\r\n![Sciensoft.Hateoas Build Status](https://dev.azure.com/Sciensoft/Sciensoft/_apis/build/status/Sciensoft.Hateoas?branchName=master)\r\n[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=Sciensoft.Hateoas\u0026metric=alert_status)](https://sonarcloud.io/dashboard?id=Sciensoft.Hateoas)\r\n[![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=Sciensoft.Hateoas\u0026metric=security_rating)](https://sonarcloud.io/dashboard?id=Sciensoft.Hateoas)\r\n[![Vulnerabilities](https://sonarcloud.io/api/project_badges/measure?project=Sciensoft.Hateoas\u0026metric=vulnerabilities)](https://sonarcloud.io/dashboard?id=Sciensoft.Hateoas)\r\n\r\nA library to help you achieve HATEOAS using a fluent language and lambda expression for configuring your ASP.NET Core RESTful/Web APIs. Based on the REST application architecture style, Uniform Interface, constraint **Hypermedia As The Engine Of Application State (HATEOAS)**.\r\n\r\n**The good thing is, there is no need to inheritance or additional code in your models or addition of extra result filters to support its functionality. They all come beautifully out of the box with `Sciensoft.Hateoas`**.\r\n\r\nSciensoft.Hateoas threats lambda as a first-class citizen, so your configuration starts with a lambda expression. This library DO NOT enforce \u003ca href=\"https://rebrand.ly/restful-explained\" target=\"_blank\"\u003eREST constraints\u003c/a\u003e or \u003ca href=\"https://rebrand.ly/richardson-maturity-model\" target=\"_blank\"\u003eRichardson Maturity Level\u003c/a\u003e, and this has to be done by you, Sciensoft.Hateoas helps you only with the implementation of HATEOAS in your resource.\r\n\r\nLearn more about RESTful API \u003ca href=\"https://restfulapi.net/\" target=\"_blank\"\u003ehere\u003c/a\u003e and Lambda Expressions \u003ca href=\"https://rebrand.ly/dotnet-lambda-expressions\" target=\"_blank\"\u003ehere\u003c/a\u003e.\r\n\r\n## Get Started\r\n\r\nSciensoft.Hateoas gets installed using \u003ca href=\"https://www.nuget.org/packages/Sciensoft.Hateoas/\" target=\"_blank\"\u003eNuget\u003c/a\u003e package manager.\r\n\r\n```bash\r\nInstall-Package Sciensoft.Hateoas\r\n```\r\n\r\nOr dotnet CLI `dotnet add package Sciensoft.Hateoas`.\r\n\r\n### Configuration\r\n\r\nUsing a fluent language, allows you to easily configure by adding the service to .NET Core dependency injection pipeline.\r\n\r\n```csharp\r\npublic void ConfigureServices(IServiceCollection services)\r\n{\r\n  services\r\n    .AddMvc()\r\n    .AddLinks(policy =\u003e\r\n    {\r\n      policy\r\n        .AddPolicy\u003cBookViewModel\u003e(model =\u003e\r\n        {\r\n          model\r\n            .AddSelf(m =\u003e m.Id, \"This is a GET self link.\")\r\n            .AddRoute(m =\u003e m.Id, BookController.UpdateBookById)\r\n            .AddRoute(m =\u003e m.Id, BookController.DeleteBookById)\r\n            .AddCustomPath(m =\u003e m.Id, \"Edit\", method: HttpMethods.Post, message: \"Edits resource\")\r\n            .AddCustomPath(m =\u003e $\"/change/resource/state/?id={m.Id}\", \"ChangeResourceState\", method: HttpMethods.Post, message: \"Any operation in your resource.\")\r\n            .AddExternalUri(m =\u003e m.Id, \"https://my-domain.com/api/books/\", \"Custom Domain External Link\")\r\n            .AddExternalUri(m =\u003e $\"/search?q={m.Title}\", \"https://google.com\", \"Google Search External Links\", message: \"This will do a search on Google engine.\");\r\n        });\r\n    });\r\n}\r\n```\r\n\r\nHere is how your controller looks like, no additional injection or attribute decoration is required. Please check our [Sample Project](./samples/Sciensoft.Hateoas.WebSample) out!\r\n\r\n```csharp\r\n[Route(\"api/books\")]\r\npublic class BookController : ControllerBase\r\n{\r\n    public const string UpdateBookById = nameof(UpdateBookById);\r\n    public const string DeleteBookById = nameof(DeleteBookById);\r\n\r\n    [HttpGet]\r\n    public ActionResult\u003cIEnumerable\u003cBookViewModel\u003e\u003e Get()\r\n    { /* Code omitted for simplicity */ }\r\n\r\n    [HttpGet(\"{id:guid}\")]\r\n    public ActionResult\u003cBookViewModel\u003e Get(Guid id)\r\n    { /* Code omitted for simplicity */ }\r\n\r\n    [HttpPost]\r\n    public IActionResult Post([FromBody] BookViewModel book)\r\n    { /* Code omitted for simplicity */ }\r\n\r\n    [HttpPut(\"{id:guid}\", Name = UpdateBookById)]\r\n    public IActionResult Put(Guid id, [FromBody] BookViewModel book)\r\n    { /* Code omitted for simplicity */ }\r\n\r\n    [HttpDelete(\"{id:guid}\", Name = DeleteBookById)]\r\n    public IActionResult Delte(Guid id)\r\n    { /* Code omitted for simplicity */ }\r\n}\r\n```\r\n\r\n**JSON Result:**\r\n\r\n```json\r\n{\r\n    \"Id\": \"8f46d29e-6c0d-4511-85e7-b1d7ae42934a\",\r\n    \"Title\": \"The Girl Who Lived: A Thrilling Suspense Novel\",\r\n    \"Author\": \"Christopher Greyson\",\r\n    \"Tags\": [\r\n        \"Fiction\",\r\n        \"Crime\",\r\n        \"Murder\",\r\n        \"Thriller\"\r\n    ],\r\n    \"links\": [\r\n        {\r\n            \"method\": \"GET\",\r\n            \"uri\": \"http://localhost:6080/api/books/83389205-b1c9-4523-a3bb-85d7255546f9\",\r\n            \"relation\": \"Self\",\r\n            \"message\": \"This is a GET self link.\"\r\n        },\r\n        {\r\n            \"method\": \"PUT\",\r\n            \"uri\": \"http://localhost:6080/api/books/83389205-b1c9-4523-a3bb-85d7255546f9\",\r\n            \"relation\": \"UpdateBookById\"\r\n        },\r\n        {\r\n            \"method\": \"DELETE\",\r\n            \"uri\": \"http://localhost:6080/api/books/83389205-b1c9-4523-a3bb-85d7255546f9\",\r\n            \"relation\": \"DeleteBookById\"\r\n        },\r\n        {\r\n            \"method\": \"POST\",\r\n            \"uri\": \"http://localhost:6080/api/books/83389205-b1c9-4523-a3bb-85d7255546f9\",\r\n            \"relation\": \"Edit\",\r\n            \"message\": \"Edits resource\"\r\n        },\r\n        {\r\n            \"method\": \"POST\",\r\n            \"uri\": \"http://localhost:6080/change/resource/state/?id=83389205-b1c9-4523-a3bb-85d7255546f9\",\r\n            \"relation\": \"ChangeResourceState\",\r\n            \"message\": \"Any operation in your resource.\"\r\n        },\r\n        {\r\n            \"method\": \"GET\",\r\n            \"uri\": \"https://my-domain.com/api/books/83389205-b1c9-4523-a3bb-85d7255546f9\",\r\n            \"relation\": \"Custom Domain External Link\"\r\n        },\r\n        {\r\n            \"method\": \"GET\",\r\n            \"uri\": \"https://google.com/search?q=The Girl Beneath the Sea (Underwater Investigation Unit Book 1)\",\r\n            \"relation\": \"Google Search External Links\",\r\n            \"message\": \"This will do a search on Google engine.\"\r\n        }\r\n    ]\r\n}\r\n```\r\n\r\n## Features\r\n\r\n- Collections result with links,\r\n- Json.NET and System.Text.Json settings support,\r\n- Self-link generation,\r\n- Named Route link generation,\r\n- Custom link generation with support to path override,\r\n- External links configuration,\r\n- Configuration with Lambda Expression,\r\n- Attribute Routing support, and\r\n- Conventional Routing support.\r\n\r\n### Roadmap\r\n\r\n- Add support for extending link generation.\r\n- Add support to bypass model link generation.\r\n- Add support to .NET Authorization.\r\n- Add support to Content Negotiation type in the read-model.\r\n\r\n## Contributions\r\n\r\nBefore start contributing, check our [CONTRIBUTING] guideline out, also, before doing any significant change, have a look at the existing Issues and Pull Requests, one of them may be tackling the same thing.\r\n\r\n## Issues\r\n\r\nTo open an issue or even suggest a new feature, please use the [Issues] tab.\r\n\r\n## License\r\n\r\nCopyright 2019 Sciensoft\r\n\r\nLicensed under the Apache License, Version 2.0 (the \"License\");\r\nyou may not use this file except in compliance with the License.\r\nYou may obtain a copy of the License at [http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0).\r\n\r\n[## LINKS ##]: ----------------------------------------------------------\r\n\r\n[Learn-RestfulApi]:https://restfulapi.net/\r\n[Lambda-Expressions]:https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/statements-expressions-operators/lambda-expressions\r\n[Richardson-Maturity-Level]:https://martinfowler.com/articles/richardsonMaturityModel.html\r\n[REST-Constraints]:https://medium.com/extend/what-is-rest-a-simple-explanation-for-beginners-part-2-rest-constraints-129a4b69a582\r\n[CONTRIBUTING]: ./CONTRIBUTING.md\r\n[Issues]: ./../../../issues\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsciensoft%2Fhateoas","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsciensoft%2Fhateoas","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsciensoft%2Fhateoas/lists"}