{"id":14986534,"url":"https://github.com/romfir/openapilinqpaddriver","last_synced_at":"2025-04-11T21:31:22.437Z","repository":{"id":193385811,"uuid":"688696774","full_name":"romfir/OpenApiLINQPadDriver","owner":"romfir","description":"LINQPad 7/8 dynamic context driver for generating C# Api clients using Open Api/Swagger spec","archived":false,"fork":false,"pushed_at":"2024-08-16T04:41:29.000Z","size":120,"stargazers_count":3,"open_issues_count":6,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-25T18:45:34.668Z","etag":null,"topics":["linqpad","linqpad-driver","linqpad-dynamic-driver","linqpad-plugin","linqpad7","linqpaddriver","net6","net7","net8","open-api","swagger","windows","windows-desktop"],"latest_commit_sha":null,"homepage":"","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/romfir.png","metadata":{"files":{"readme":"README.md","changelog":null,"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}},"created_at":"2023-09-07T23:05:29.000Z","updated_at":"2024-10-25T18:47:25.000Z","dependencies_parsed_at":"2023-09-08T00:59:03.991Z","dependency_job_id":"3f96ee3c-921f-4f2d-81db-1835d7bcb2cb","html_url":"https://github.com/romfir/OpenApiLINQPadDriver","commit_stats":{"total_commits":31,"total_committers":4,"mean_commits":7.75,"dds":0.5806451612903225,"last_synced_commit":"3ef042dc6fddedb15260bd9c9a04a1364af49d7f"},"previous_names":["romfir/openapilinqpaddriver"],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/romfir%2FOpenApiLINQPadDriver","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/romfir%2FOpenApiLINQPadDriver/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/romfir%2FOpenApiLINQPadDriver/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/romfir%2FOpenApiLINQPadDriver/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/romfir","download_url":"https://codeload.github.com/romfir/OpenApiLINQPadDriver/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248482938,"owners_count":21111403,"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":["linqpad","linqpad-driver","linqpad-dynamic-driver","linqpad-plugin","linqpad7","linqpaddriver","net6","net7","net8","open-api","swagger","windows","windows-desktop"],"created_at":"2024-09-24T14:13:05.967Z","updated_at":"2025-04-11T21:31:22.059Z","avatar_url":"https://github.com/romfir.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# OpenApiLINQPadDriver for LINQPad 7/8\n[![Latest build](https://github.com/romfir/OpenApiLINQPadDriver/workflows/Build/badge.svg)](https://github.com/romfir/OpenApiLINQPadDriver/actions)\n[![NuGet](https://img.shields.io/nuget/v/OpenApiLINQPadDriver)](https://www.nuget.org/packages/OpenApiLINQPadDriver)\n[![Downloads](https://img.shields.io/nuget/dt/OpenApiLINQPadDriver)](https://www.nuget.org/packages/OpenApiLINQPadDriver)\n[![License](https://img.shields.io/badge/license-MIT-yellow)](https://opensource.org/licenses/MIT)\n\n## Description ##\n\nOpenApiLINQPadDriver is LINQPad 7/8 dynamic data context driver for creating C# clients based on [Open API](https://www.openapis.org)/[Swagger](https://swagger.io/specification/) specifications\n\n* Specification is read using [NJsonSchema](https://github.com/RicoSuter/NJsonSchema) and clients are generated using [NSwag](https://github.com/RicoSuter/NSwag)\n\n## Websites ##\n\n* [This project](https://github.com/romfir/OpenApiLINQPadDriver)\n* [Original project for LINQPad 5](https://github.com/seba76/SwaggerContextDriver)\n* UI is heavily inspired by [CsvLINQPadDriver](https://github.com/i2van/CsvLINQPadDriver)\n\n## Downloads ##\ngeneration of lpx6 files is on the roadmap, for now we only support instalation via nuget\n\n## Prerequisites ##\n\n* [LINQPad 8](https://www.linqpad.net/LINQPad7.aspx): [.NET 8](https://dotnet.microsoft.com/download/dotnet/8.0)\n* [LINQPad 7](https://www.linqpad.net/LINQPad7.aspx): [.NET 7](https://dotnet.microsoft.com/download/dotnet/7.0)/[.NET 6](https://dotnet.microsoft.com/download/dotnet/6.0)\n\n## Installation ##\n\n### LINQPad 7/8 ###\n\n#### NuGet ####\n\n[![NuGet](https://img.shields.io/nuget/v/OpenApiLINQPadDriver)](https://www.nuget.org/packages/OpenApiLINQPadDriver)\n\n* Open LINQPad 7/8.\n* Click `Add connection` link.\n* Click button `View more drivers...`\n* Click radio button `Show all drivers` and type `OpenApiLINQPadDriver` (for now it is also required to check `Include Prerelease` checkbox)\n* Install.\n* In case of working in environments without internet access it is possible to manually download nuget package and configure `Package Source` to point to a folder where it is located\n\n## Usage ##\n\nOpen API Connection can be added the same way as any other connection.\n\n* Click `Add Connection`\n* Select `OpenApi Driver`\n* Enter `Open Api/Swagger Uri` or click `Get from disk` and pick it from file\n* Manually enter `API Uri` or click `Get from Open Api document`, if servers are found in the specification then uri of the first one will be picked\n* Set settings\n* Click `OK`\n* Client should start generation, you can use it by right clicking on it and choosing `Use in Current Query` or by picking it from `Connection` select\n* It is possible to drag method name from the tree view on the left to the query\n* Example code using [PetStore API](https://petstore.swagger.io/v2/swagger.json)\n```csharp\nasync Task Main() \n{\n  var newPetId = System.Random.Shared.NextInt64();\n  await PetClient.AddPetAsync(new Pet() \n  {\n    Id = newPetId,\n    Name = \"Dino\",\n    Category = new Category \n    {\n        Id = 123,\n        Name = \"Dog\"\n    }\n  });\n\n  await PetClient.GetPetByIdAsync(newPetId).Dump();\n}\n```\n### Refreshing client ###\n* Right click on the connection and click `Refresh`\n* Or use shortcut `Shift+Alt+D`\n\n## Configuration Options ##\n\n### Client Generation ###\n\n* Endpoint grouping - how methods will be grouped in generated client\n  * `Multiple clients from first tag and operationName` - usually first tag corresponds to ASP.NET controller, so this will group methods by controller\n  * `Single client from OperationId and OperationName` - this will put all endpoints in one class\n* Json library - library used in generated client for serialization/deserialization, for specification reading [NJsonSchema](https://github.com/RicoSuter/NJsonSchema) uses `Newstonsoft.Json`\n    * `System.Text.Json`\n    * `Newstonsoft.Json`\n* Class style\n    * `POCOs (Plain Old C# Objects)`\n    * `Classes implementing the INotifyPropertyChanged interface`\n    * `Classes implementing the Prism base class`\n    * `Records - read only POCOs (Plain Old C# Objects)`\n* Generate sync methods - by default sync methods will not be generated\n* Build in Release - Build generated code in Release, default: `false`\n\n### Misc ###\n\n* Debug info: show additional driver debug info, e.g. generated data context sources, add `Execution Times` explorer item with execution times of parts of the generation pipeline and will add warnings from the compilation if any were present\n* Remember this connection: connection will be available on next run.\n* Contains production data: files contain production data.\n\n### PrepareRequestFunction ###\n* Each generated client has `PrepareRequestFunction` Func, for  `Multiple clients from first tag and operationName` mode, helper set only Func is also generted to set them all at once\n* This Func will be run on each method exectuion before making a http request, it is run in `PrepareRequest` partial methods generated by [NSwag](https://github.com/RicoSuter/NSwag)\n* It can be used to set additional headers or other http client settings\n* Example usage\n```csharp\nasync Task Main() \n{\n  PrepareRequestFunction = (httpClient, requestMessage, url) =\u003e \n  {\n    requestMessage.Headers.Add(\"UserId\", \"9\");\n    requestMessage.Headers.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue(\"Bearer\", \"\u003ctoken\u003e\");\n  };\n}\n```\n```csharp\nasync Task Main() \n{\n  PrepareRequestFunction = PrepareRequest;\n}\n\nprivate void PrepareRequest(HttpClient httpClient, HttpRequestMessage requestMessage, string url) \n{\n  requestMessage.Headers.Add(\"UserId\", \"9\");\n  requestMessage.Headers.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue(\"Bearer\", \"\u003ctoken\u003e\");\n}\n```\n## Credits ##\n\n### Tools ###\n\n* [LINQPad 7](https://www.linqpad.net/LINQPad7.aspx)\n* [LINQPad 8](https://www.linqpad.net/LINQPad8.aspx)\n* [LINQPad Command-Line and Scripting (LPRun)](https://www.linqpad.net/lprun.aspx)\n\n### Libraries ###\n\n* [NJsonSchema](https://github.com/RicoSuter/NJsonSchema)\n* [NSwag](https://github.com/RicoSuter/NSwag)\n* [Newtonsoft.Json](https://github.com/JamesNK/Newtonsoft.Json) - required by NSwag, included to bump version\n\n### Development ###\n* [OpenApiLINQPadDriver.csproj](https://github.com/romfir/OpenApiLINQPadDriver/blob/master/OpenApiLINQPadDriver/OpenApiLINQPadDriver.csproj) contains special `Debug_Publish_To_LINQPad_Folder` debug build configuration, if it is chosen, code will be build only targeting `net8.0-windows` with [additional properties](https://github.com/romfir/OpenApiLINQPadDriver/blob/master/OpenApiLINQPadDriver/OpenApiLINQPadDriver.csproj?plain=1#L52-L57)\n* LINQPad can pick drivers from `\\LINQPad\\Drivers\\DataContext\\NetCore` folder\n* [Additionaly when exceptions will be thrown it will be possible to attach a debugger](https://github.com/romfir/OpenApiLINQPadDriver/blob/master/OpenApiLINQPadDriver/OpenApiContextDriver.cs?plain=1#L12-L21)\n\n### Roadmap ###\n* Allow injection of own httpClient\n* Unit tests\n* `PrepareRequest` with string builder overload\n* `ProcessResponse`\n* `PrepareRequest` and `ProcessResponse` async overload that could be set via a setting\n* Methods parameters and responses in tree view\n* Auto dump response\n* Auth helper methods eg. `SetBearerToken`\n* When multiple servers are found allow selection\n* LINQPad 5 support\n* Examples (include in the nuget) - possibly the same ones could be used in testing\n* Expose JsonSerializerSettings setter on multi client setup\n* Expose ReadResponseAsString on multi client setup\n* Treat warnings as errors in generated code (`generalDiagnosticOption: ReportDiagnostic.Error`)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fromfir%2Fopenapilinqpaddriver","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fromfir%2Fopenapilinqpaddriver","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fromfir%2Fopenapilinqpaddriver/lists"}