{"id":20710419,"url":"https://github.com/mobiletelesystems/apicodegenerator","last_synced_at":"2026-02-13T12:20:12.961Z","repository":{"id":262970212,"uuid":"861740839","full_name":"MobileTeleSystems/ApiCodeGenerator","owner":"MobileTeleSystems","description":"Generate code from Swagger, OpenApi or AsyncApi documents.","archived":false,"fork":false,"pushed_at":"2025-02-06T15:08:10.000Z","size":199,"stargazers_count":24,"open_issues_count":2,"forks_count":1,"subscribers_count":5,"default_branch":"dev","last_synced_at":"2025-04-23T05:59:06.768Z","etag":null,"topics":[],"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/MobileTeleSystems.png","metadata":{"files":{"readme":"README.MD","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","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":"2024-09-23T12:44:10.000Z","updated_at":"2025-03-26T00:19:00.000Z","dependencies_parsed_at":"2024-11-15T10:39:10.560Z","dependency_job_id":"ee68c6d6-a340-48dc-9a15-2ee7e4978679","html_url":"https://github.com/MobileTeleSystems/ApiCodeGenerator","commit_stats":null,"previous_names":["mobiletelesystems/apicodegenerator"],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MobileTeleSystems%2FApiCodeGenerator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MobileTeleSystems%2FApiCodeGenerator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MobileTeleSystems%2FApiCodeGenerator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MobileTeleSystems%2FApiCodeGenerator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MobileTeleSystems","download_url":"https://codeload.github.com/MobileTeleSystems/ApiCodeGenerator/tar.gz/refs/heads/dev","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250379787,"owners_count":21420841,"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-11-17T02:11:54.415Z","updated_at":"2025-10-07T22:24:57.442Z","avatar_url":"https://github.com/MobileTeleSystems.png","language":"C#","readme":"[Read in Russian](README_RU.MD)\n\n[![NuGet Version](https://img.shields.io/nuget/vpre/ApiCodeGenerator.MSBuild?style=flat-square)](https://www.nuget.org/packages/ApiCodeGenerator.MSBuild)\n[![GitHub License](https://img.shields.io/github/license/MobileTeleSystems/ApiCodeGenerator?style=flat-square)](https://github.com/MobileTeleSystems/ApiCodeGenerator/blob/dev/LICENSE)\n[![Codacy Badge](https://app.codacy.com/project/badge/Coverage/bcf93c4065c3442b92e5e95671b8cfcf)](https://app.codacy.com/gh/MobileTeleSystems/ApiCodeGenerator/dashboard?utm_source=gh\u0026utm_medium=referral\u0026utm_content=\u0026utm_campaign=Badge_coverage)\n\n# How to install\n\n1. Add the `ApiCodeGenerator.MSBuild` package in your project.\n2. Add a file describing the API in formats like: Swagger 2.0, OpenApi 3.0, JsonSchema, AsyncApi 2.0 to your project.\n3. Add a file with the same name but with the `.nswag` extension to your project and fill it out.\n4. Rebuild the project.\n\n# NSwag File Format\n\u003e To use hints while editing the file, set schema https://raw.githubusercontent.com/MobileTeleSystems/ApiCodeGenerator/refs/heads/dev/schemas/nswag.json .\n\nThe NSwag format consists of files that store settings for the [NSwagStudio](https://github.com/RicoSuter/NSwag/wiki/NSwagStudio) application, which can be used to configure standard NSwag generators.\nThe file has the following structure:\n```json\n{\n  \"documentGenerator\": {\n    \"fromDocument\": {\n      \"json\": \"$(InputJson)\",\n      \"url\": \"http://basketService/swagger/v1/swagger.json\"\n    }\n  },\n  \"codeGenerators\": {\n    \"openApiToCSharpClient\": {}\n  }\n}\n```\nSince the settings for various APIs mostly overlap, to reduce duplication, you can move the settings for preprocessors and generators to a `base.nswag` file (the file name can be changed via settings). The file has the same structure, and the `codeGenerators` block can specify several generators (the settings for the selected generator will be applied to the target file). The file is searched in all higher-level directories starting from the NSwag file being generated.\n\n## Document Generation\nThe `documentGenerator` block specifies the rules for obtaining the document based on which the code will be generated. For generation from documents in `Swagger 2.0`, `OpenApi 3.0`, or `AsyncApi 3.0` formats, you need to fill in the `fromDocument` property. For generation from a JsonSchema document, use the `jsonSchemaToOpenApi` property.\n\nIn `fromDocument`, the `json` property specifies the path to the file or a string containing the document itself (the example uses a variable containing the file path). The `url` property specifies the address from which the file can be downloaded. If the `json` property is not filled, the document will be downloaded from this address. Both properties can accept paths to YAML files.\n\n\u003e If paths are not specified in `fromDocument` or the block itself is absent, the `json` property will be set to the path from `OpenApiReference`.\n\nAdditionally, `fromDocument` can have a `preprocessors` property to connect handlers that preprocess the document before passing it to the code generator.\n\n## Code Generation\nThe `codeGenerators` block specifies the generator that will be used to generate the code. The property name is the generator's name, and the value is the settings for the selected generator.\n\nAvailable generators:\n* `asyncApiToCSharpAmqpService` - C# client for the [RabbitMQ.Client 5](https://www.nuget.org/packages/RabbitMQ.Client/5.2.0) library.\n* `openApiToCSharpClient` - generates a C# client for accessing the API.\n\u003c!-- * `openApiToTypeScriptClient` - generates a TypeScript client for accessing the API. --\u003e\n* `openApiToCSharpController` - generates a controller and service interface for implementing the controller's logic.\n* `openApiToRefitClient` - generates an interface for accessing the API using the [Refit](https://github.com/reactiveui/refit) library. Requires the [ApiCodeGenerator.OpenApi.Refit](https://github.com/MobileTeleSystems/ApiCodeGenerator.OpenApi.Refit) package.\n\n\u003c!-- \u003e ⚠ If you use the `openApiToTypeScriptClient` generator, you need to replace the generator in the project for the corresponding OpenApiReference.\n\u003e ```xml\n\u003e  \u003cOpenApiReference Update=\"@(OpenApiReference)\"\u003e\n\u003e         \u003cCodeGenerator\u003eOacgTypeScript\u003c/CodeGenerator\u003e\n\u003e       \u003c/OpenApiReference\u003e\n\u003e  ``` --\u003e\n\nRead about generator options:\n - [for all listed generators](https://github.com/RicoSuter/NSwag/wiki/NSwag-Configuration-Document).\n - [for C# code generators](https://github.com/RicoSuter/NSwag/wiki/CSharpGeneratorBaseSettings)\n - [for `openApiToCSharpClient`](https://github.com/RicoSuter/NSwag/wiki/CSharpClientGeneratorSettings)\n \u003c!-- - [for `openApiToTypescriptClient`](https://github.com/RicoSuter/NSwag/wiki/TypeScriptClientGeneratorSettings) --\u003e\n\nAdditionally, for all generators, the library adds the `replaceNameCollection` setting for replacing characters in property names.\n```json\n\"replaceNameCollection\": {\n  \"@\": \"_\" // Replace @ with _ in names\n}\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmobiletelesystems%2Fapicodegenerator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmobiletelesystems%2Fapicodegenerator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmobiletelesystems%2Fapicodegenerator/lists"}