{"id":18889765,"url":"https://github.com/scottlogic/openapi-forge-csharp","last_synced_at":"2025-04-14T23:30:57.145Z","repository":{"id":39571529,"uuid":"507065213","full_name":"ScottLogic/openapi-forge-csharp","owner":"ScottLogic","description":"🛠 OpenAPI Forge generator for C#","archived":false,"fork":false,"pushed_at":"2023-03-29T10:02:38.000Z","size":386,"stargazers_count":0,"open_issues_count":4,"forks_count":4,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-28T11:39:03.455Z","etag":null,"topics":["csharp","openapi","openapi-forge"],"latest_commit_sha":null,"homepage":"","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/ScottLogic.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}},"created_at":"2022-06-24T15:49:30.000Z","updated_at":"2023-03-29T14:19:07.000Z","dependencies_parsed_at":"2023-07-14T00:48:36.885Z","dependency_job_id":null,"html_url":"https://github.com/ScottLogic/openapi-forge-csharp","commit_stats":{"total_commits":89,"total_committers":6,"mean_commits":"14.833333333333334","dds":0.5280898876404494,"last_synced_commit":"f5f852bbfa3b04fe98d9f6220988e69cffc485c6"},"previous_names":["murcikan-scottlogic/openapi-forge-csharp"],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ScottLogic%2Fopenapi-forge-csharp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ScottLogic%2Fopenapi-forge-csharp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ScottLogic%2Fopenapi-forge-csharp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ScottLogic%2Fopenapi-forge-csharp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ScottLogic","download_url":"https://codeload.github.com/ScottLogic/openapi-forge-csharp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248978472,"owners_count":21192796,"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":["csharp","openapi","openapi-forge"],"created_at":"2024-11-08T07:50:49.336Z","updated_at":"2025-04-14T23:30:56.803Z","avatar_url":"https://github.com/ScottLogic.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"## OpenAPI Forge - C#\n\nThis repository is the C# generator for the [OpenAPI Forge](https://github.com/ScottLogic/openapi-forge), see that repository for usage instructions:\n\nhttps://github.com/ScottLogic/openapi-forge\n\n## Example\n\nYou should consult the [OpenAPI Forge](https://github.com/ScottLogic/openapi-forge) repository for a complete user guide. The following is a very brief example that quickly gets you up-and-running with this generator.\n\nRun the `forge` command to generate a client API using this generator as follows:\n\n```\n$ openapi-forge forge \\\n                https://petstore3.swagger.io/api/v3/openapi.json \\\n                openapi-forge-csharp \\\n                -o ApiTest\n```\n\nThis will generate various files in the `api` folder.\n\n### Running the example output\n\nThe following provides a brief set of instructions for running the pet store example using the dotnet CLI.\n\nFirst generate a new console application:\n\n```shell\n$ dotnet new console -o ApiTest -f net7.0\n```\n\nGenerate the pet store API client within the same folder:\n\n```shell\n$ openapi-forge forge \\\n                https://petstore3.swagger.io/api/v3/openapi.json \\\n                openapi-forge-csharp \\\n                -o ApiTest\n```\n\nWithin the `ApiTest` folder you'll find a generated `ApiTest.csproj` file. Add the following assembly references:\n\n```xml\n\u003cItemGroup\u003e\n  \u003cPackageReference Include=\"Microsoft.Extensions.DependencyInjection\" Version=\"7.0.0\" /\u003e\n  \u003cPackageReference Include=\"Microsoft.Extensions.Http\" Version=\"7.0.0\" /\u003e\n\u003c/ItemGroup\u003e\n```\n\nFinally update `Programe.cs` to the following:\n\n```csharp\nusing Microsoft.Extensions.DependencyInjection;\nusing Microsoft.Extensions.DependencyInjection.Extensions;\nusing OpenApiForge;\n\n// perform any required configuration for accessing the API here\nvar config = new Configuration() {\n  BasePath = \"https://petstore3.swagger.io\"\n};\n\n// register the API client with the DI container\nvar services = new ServiceCollection();\nservices.Add(new ServiceDescriptor(typeof(Configuration), config));\nStartup.RegisterApiClient(services, config);\n\n// get the API client from the DI container\nvar serviceProvider = services.BuildServiceProvider();\nvar api = serviceProvider.GetRequiredService\u003cIApiClientPet\u003e();\n\n// add a pet\nawait api.addPet(new Pet() {\n  id = 1,\n  name = \"Fido\",\n  photoUrls= new string[0],\n});\n\n// fetch the pet\nvar result = await api.getPetById(1);\nConsole.WriteLine(result.Data.name);\n```\n\nRun from the terminal as follows:\n\n```shell\n$ dotnet run\nFido\n```\n\n### Testing\n\nThe standard test script is used to execute the BDD-style tests against this generator.\n\n```\nnpm run test\n```\n\nThe script expects that the openapi-forge project (which is where the BDD feature files are located) is checked out at the same folder-level as this project. You also need to have the .NET CLI installed globally, you can confirm this by running `dotnet` in your terminal window.\n\n### Linting\n\nTwo scripts are available to help you find linting errors:\n\n```\nnpm run lint:check:all\n```\n\nThis runs eslint in check mode which will raise errors found but not try and fix them. This is also ran on a PR and a push to main. It will fail if any errors were found.\n\n```\nnpm run lint:write:all\n```\n\nThis runs eslint in write mode which will raise errors found and try to fix them.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscottlogic%2Fopenapi-forge-csharp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fscottlogic%2Fopenapi-forge-csharp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscottlogic%2Fopenapi-forge-csharp/lists"}