{"id":28916890,"url":"https://github.com/mrahhal/mr.augmenter","last_synced_at":"2025-08-09T23:35:37.405Z","repository":{"id":83656641,"uuid":"78273478","full_name":"mrahhal/MR.Augmenter","owner":"mrahhal","description":"Take control of the data your API returns.","archived":false,"fork":false,"pushed_at":"2018-07-21T13:41:49.000Z","size":162,"stargazers_count":7,"open_issues_count":2,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-01T09:15:40.083Z","etag":null,"topics":["api","aspnetcore","augmenter","csharp","middleware","mvc"],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mrahhal.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2017-01-07T10:48:06.000Z","updated_at":"2024-01-27T22:04:08.000Z","dependencies_parsed_at":"2023-03-12T19:06:48.813Z","dependency_job_id":null,"html_url":"https://github.com/mrahhal/MR.Augmenter","commit_stats":null,"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"purl":"pkg:github/mrahhal/MR.Augmenter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrahhal%2FMR.Augmenter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrahhal%2FMR.Augmenter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrahhal%2FMR.Augmenter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrahhal%2FMR.Augmenter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mrahhal","download_url":"https://codeload.github.com/mrahhal/MR.Augmenter/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrahhal%2FMR.Augmenter/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269654009,"owners_count":24454317,"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","status":"online","status_checked_at":"2025-08-09T02:00:10.424Z","response_time":111,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["api","aspnetcore","augmenter","csharp","middleware","mvc"],"created_at":"2025-06-22T00:08:58.428Z","updated_at":"2025-08-09T23:35:37.395Z","avatar_url":"https://github.com/mrahhal.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MR.Augmenter\n\nAppVeyor | Travis\n---------|-------\n[![Build status](https://img.shields.io/appveyor/ci/mrahhal/mr-augmenter/master.svg)](https://ci.appveyor.com/project/mrahhal/mr-augmenter) | [![Travis](https://img.shields.io/travis/mrahhal/MR.Augmenter.svg)](https://travis-ci.org/mrahhal/MR.Augmenter)\n\n[![NuGet version](https://img.shields.io/nuget/v/MR.Augmenter.svg)](https://www.nuget.org/packages/MR.Augmenter)\n[![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/licenses/MIT)\n\nTake control of the data your API returns.\n\n[CHANGELOG](CHANGELOG.md)\n\n## What and Why\n- We have some changes (add props, remove props) we want to apply to our models centrally (and conditionally).\n- We want this to play nice with inheritance, nesting, enumerables, ...\n- We want all of this to happen preferably automatically. We should be able to just write:\n\n```cs\nreturn Ok(Service.GetModel());\n```\n\n## Example\nThis is what we'll be able to do after we configure Augmenter:\n\n```cs\nclass Model\n{\n    public int Id { get; set; }\n\n    public string Hash { get; set; }\n\n    // Suppose we need this in our action, but we want to hide it in our response.\n    public string Secret { get; set; }\n\n    // Also, we want to add computed \"Image\" and \"ImageThumb\" properties.\n}\n```\n\n```cs\npublic IActionResult Get()\n{\n    var model = Service.GetModel();\n    return Ok(model);\n}\n```\n\nReturned json:\n```json\n{\n  \"Id\": 42,\n  \"Hash\": \"80f0aa63b234498a88fe5f9d2522c2a7\",\n  \"Image\": \"/images/80f0aa63b234498a88fe5f9d2522c2a7.jpg\",\n  \"ImageThumb\": \"/images/thumbs/80f0aa63b234498a88fe5f9d2522c2a7.jpg\"\n}\n```\n\n## Getting started\n\nYou'll want to add the `MR.Augmenter.AspNetCore` package to your dependencies (which depends on `MR.Augmenter`).\n\nAdd Augmenter and configure global options:\n\n```cs\nservices\n    .AddAugmenter(config =\u003e { ... })\n    .ForMvc(); // This will add a global filter that will handle augmenting models you return from actions.\n```\n\nFrom here on out, simply do what you always do. Augmenter will start working automatically with the models you return.\n\nInheritance, nested types, anonymous objects containing configured models, lists and arrays... Those are all accounted for.\n\n## Configuration\n\n```cs\nservices.AddAugmenter(config =\u003e\n{\n    // Start configuring the type \"Model1\".\n    config.Configure\u003cModel1\u003e(c =\u003e\n    {\n        // Use Remove to configure a \"Remove\" agumentation.\n        // From now on, the \"Secret\" property will always be removed from the response.\n        c.Remove(nameof(Model1.Secret));\n\n        // Use Add to configure an \"Add\" augmentation.\n        // From now on, the \"Image\" property will always be added to the response.\n        c.Add(\"Image\", (x, state) =\u003e $\"/{x.Hash}/some/path\");\n    });\n});\n```\n\nYou can also extend `TypeConfiguration\u003c\u003e`. Augmenter will automatically scan for such types on startup, but you'll have to add your assembly first:\n\n```cs\nservices.AddAugmenter(config =\u003e\n{\n    // Add the assemblies that you want us to scan for type configuration classes.\n    config.AddAssembly(typeof(Startup).Assembly);\n});\n```\n\nAnd somewhere else:\n\n```cs\n// You should have a public default ctor and call configuration methods from it.\npublic class Model1Configuration : TypeConfiguration\u003cModel1\u003e\n{\n    public Model1Configuration()\n    {\n        Remove(nameof(Model1.Secret));\n    }\n}\n```\n\nFor a lot more options checkout the samples.\n\n## Advanced\n\n[TODO]\n\n## Samples\nCheck out the [`samples`](samples) under \"samples/\" for more practical use cases.\n\n#### [`Basic`](samples/Basic)\nShows how to configure Augmenter in an Asp.Net core app with some practical examples.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrahhal%2Fmr.augmenter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmrahhal%2Fmr.augmenter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrahhal%2Fmr.augmenter/lists"}