{"id":13629356,"url":"https://github.com/Melchy/Ridge","last_synced_at":"2025-04-17T09:33:24.081Z","repository":{"id":65420142,"uuid":"335033176","full_name":"Melchy/Ridge","owner":"Melchy","description":null,"archived":false,"fork":false,"pushed_at":"2023-11-27T11:04:57.000Z","size":5630,"stargazers_count":51,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-05-16T06:28:27.508Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Melchy.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2021-02-01T17:43:32.000Z","updated_at":"2024-04-18T10:48:27.000Z","dependencies_parsed_at":"2024-01-06T02:10:47.823Z","dependency_job_id":"6b89f1b2-78e5-42ed-aca7-69100052fdc0","html_url":"https://github.com/Melchy/Ridge","commit_stats":{"total_commits":67,"total_committers":3,"mean_commits":"22.333333333333332","dds":"0.11940298507462688","last_synced_commit":"459f63fe7a8eb081016cc924f5857b7a3f21fe5a"},"previous_names":[],"tags_count":92,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Melchy%2FRidge","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Melchy%2FRidge/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Melchy%2FRidge/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Melchy%2FRidge/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Melchy","download_url":"https://codeload.github.com/Melchy/Ridge/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249331615,"owners_count":21252618,"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":[],"created_at":"2024-08-01T22:01:08.395Z","updated_at":"2025-04-17T09:33:22.190Z","avatar_url":"https://github.com/Melchy.png","language":"C#","readme":"[![build](https://github.com/melchy/ridge/actions/workflows/release.yml/badge.svg)](https://github.com/Melchy/Ridge/actions)\n[![](https://img.shields.io/nuget/v/ridgedotnet)](https://www.nuget.org/packages/RidgeDotNet/)\n[![](https://img.shields.io/github/v/release/melchy/ridge?label=latest%20release)](https://github.com/Melchy/Ridge/releases)\n\n# Ridge\n\nRidge is a **source generator** that creates strongly typed HTTP clients for integration tests. HTTP clients generated by Ridge require the\n[WebApplicationFactory](https://learn.microsoft.com/en-us/aspnet/core/test/integration-tests?view=aspnetcore-7.0#basic-tests-with-the-default-webapplicationfactory).\nThe use of the `WebApplicationFactory` allows Ridge to access internal components of ASP.NET and analyze them. \nThis significantly improves route generation and allows implicit support of areas, routing without attributes, and so on.\n\n\u003e Ridge supports .NET 6 and newer.\n\n## Quick links\n\n* [NuGet package](https://www.nuget.org/packages/RidgeDotNet/)\n* [Documentation](https://github.com/Melchy/Ridge/wiki)\n\n## Example\n\n```csharp\n// --------------------------------------------ExampleController.cs-------------------------------------------------\n[GenerateClient] // Notice the attribute\npublic class ExamplesController : Controller\n{\n    [HttpGet(\"ReturnGivenNumber\")]\n    public ActionResult\u003cint\u003e ReturnGivenNumber(\n        [FromQuery] int input)\n    {\n        return input;\n    }\n}\n\n\n// ------------------------------------------Test.cs----------------------------------------------------------------\n[Test]\npublic async Task CallControllerUsingRidge()\n{\n    using var webApplicationFactory = \n        new WebApplicationFactory\u003cProgram\u003e()\n            .WithRidge(); // add ridge dependencies to WebApplicationFactory\n    var client = webApplicationFactory.CreateClient();\n    // create instance of client generated by source generator\n    var examplesControllerClient = new ExamplesControllerClient(client, webApplicationFactory.Services); \n\n    var response = await examplesControllerClient.ReturnGivenNumber(10);\n    \n    Assert.True(response.IsSuccessStatusCode);\n    Assert.AreEqual(10, response.Result);\n}\n```\n\n## Setup\n\n* Mark controller with the `[GenerateClient]` attribute. This attribute tells the source generator to generate\n  class `*YourControllerName*Client` in the assembly which contains the controller.\n* Call `WithRidge()` extension method on `WebApplicationFactory`.\n* Create instance of `*YourControllerName*Client`.\n* Create requests using `*YourControllerName*Client` instance.\n\n\n\u003e Hint: Use package [`RidgeDotNet.AspNetCore`](https://www.nuget.org/packages/RidgeDotNet.AspNetCore) in your `AspNetCore` project instead of [`RidgeDotNet`](https://www.nuget.org/packages/RidgeDotNet). `RidgeDotNet.AspNetCore` has minimal dependencies, preventing unnecessary test code in your project.\n\n## Best practices\n\n* Use `ActionResult\u003cT\u003e` when possible to enable strongly typed response generation.\n* Use `[FromRoute]`, `[FromQuery]`, `[FromBody]`, and similar attributes when possible to ensure correct parameter\n  mapping.\n* Add a logger to check generated requests and responses when\n  necessary. More information [here](https://github.com/Melchy/Ridge/wiki/4.-Request-response-logging).\n* Use [`RethrowExceptionInsteadOfReturningHttpResponse`](https://github.com/Melchy/Ridge/wiki/3.-rethrow-exceptions-instead-of-http-response)\n  for improved test experience.\n\n\n## Wiki\n\nFull documentation can be found [in the wiki](https://github.com/Melchy/Ridge/wiki).\n\n## Features that are not currently supported\n\n\u003e Note that you can always fall back to `WebApplicationFactory` when you need to test something that is not supported by\n\u003e Ridge.\n\n* Minimal API\n* Custom request types. JSON is the only request type currently supported.\n* Single action parameter transformations (add parameter to single action or transform parameter in single action)\n* `[FromForm]` attributes\n* Actions returning custom implementation of `IActionResult`.\n\n### Mappings that are not supported by default\n\nRidge supports a wide range of parameter mappings, but some special cases are currently not supported by default. \nKnown unsupported mappings are the following:\n\n* `[FromQuery]` with an array of complex arguments\n* Complex types with `[FromXXX]` attributes on properties\n\nExample of `[FromQuery]` with an array of complex arguments:\n\n```csharp\npublic virtual ActionResult NotSupported([FromQuery] IEnumerable\u003cComplexArgument\u003e complexArguments)\n{\n   //..\n}\n```\n\nExample of complex types with `[FromXXX]` attributes on properties:\n\n```csharp\npublic virtual ActionResult NotSupported(Mixed mixed)\n{\n   //..\n}\n\n\npublic class Mixed\n{\n    [FromBody]\n    public string BodyName { get; set; }\n    [FromHeader]\n    public string HeaderName { get; set; }\n}\n```\n\nIf you need to use this feature then consider writing\n[custom `HttpRequestFactoryMiddleware`](https://github.com/Melchy/Ridge/wiki/2.-Request-creation#custom-middlewares)\nor creating an issue.\n\n## Contributions\n\nIcon made by [Freepik](https://www.freepik.com) from [www.flaticon.com](https://www.flaticon.com/).","funding_links":[],"categories":["Content","Source Generators"],"sub_categories":["50. [Ridge](https://ignatandrei.github.io/RSCG_Examples/v2/docs/Ridge) , in the [Tests](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#tests) category","Webprogramming"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FMelchy%2FRidge","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FMelchy%2FRidge","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FMelchy%2FRidge/lists"}