{"id":20709478,"url":"https://github.com/beezup/dotnet-codegen","last_synced_at":"2025-07-11T16:02:50.600Z","repository":{"id":34916219,"uuid":"183206567","full_name":"BeezUP/dotnet-codegen","owner":"BeezUP","description":"Code Generator as a dotnet global tool","archived":false,"fork":false,"pushed_at":"2024-07-07T14:14:20.000Z","size":316,"stargazers_count":8,"open_issues_count":2,"forks_count":5,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-11T00:42:12.301Z","etag":null,"topics":["codegen","codegenerator","dotnet","handlebars","openapi","swagger"],"latest_commit_sha":null,"homepage":null,"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/BeezUP.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-04-24T10:30:51.000Z","updated_at":"2024-07-07T14:13:25.000Z","dependencies_parsed_at":"2023-01-15T10:21:01.610Z","dependency_job_id":null,"html_url":"https://github.com/BeezUP/dotnet-codegen","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BeezUP%2Fdotnet-codegen","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BeezUP%2Fdotnet-codegen/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BeezUP%2Fdotnet-codegen/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BeezUP%2Fdotnet-codegen/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BeezUP","download_url":"https://codeload.github.com/BeezUP/dotnet-codegen/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250372938,"owners_count":21419722,"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":["codegen","codegenerator","dotnet","handlebars","openapi","swagger"],"created_at":"2024-11-17T02:06:33.791Z","updated_at":"2025-04-23T04:47:11.131Z","avatar_url":"https://github.com/BeezUP.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CodegenUP\r\n\r\n[![Nuget CodegenUP](https://img.shields.io/nuget/v/CodegenUP?label=Nuget%20CodegenUP)](https://www.nuget.org/packages/CodegenUP)\r\n[![Nuget CodegenUP.Engine](https://img.shields.io/nuget/v/CodegenUP.Engine?label=Nuget%20CodegenUP.Engine)](https://www.nuget.org/packages/CodegenUP.Engine)\r\n[![Nuget CodegenUP.DocumentRefLoader](https://img.shields.io/nuget/v/CodegenUP.DocumentRefLoader?label=Nuget%20CodegenUP.DocumentRefLoader)](https://www.nuget.org/packages/CodegenUP.DocumentRefLoader)\r\n\r\nA global tool to execute handlebars templates in order to generate code (think about swagger/openapi/graphql ...)\r\n\r\n## Installation\r\n\r\nInstallation is very easy. Just run this command and the tool will be installed. \r\n\r\n`dotnet tool install --global CodegenUP`\r\n\r\n## Usage\r\n\r\n```\r\ncodegenup -h\r\n\r\nUsage:  [options]\r\n\r\nOptions:\r\n  -?|-h|--help          Show help information\r\n  -l|--loader           Enter a schema loader type between those values [RawJson | Swagger | OpenApi | GraphQl | RawXml]\r\n  -d|--duplicates       Enter a template duplication handling strategy between those values [Throw | KeepLast | KeepFirst]\r\n  -s|--source           Enter a path (relative or absolute) to an source document.\r\n  -a|--auth             Enter an authorization token to access source documents\r\n  -o|--output           Enter the path (relative or absolute) to the output path (content will be overritten)\r\n  -t|--template         Enter a path (relative or absolute / file or folder) to a template.\r\n  -i|--intermediate     Enter a path (relative or absolute) to a file for intermediate 'all refs merged' output of the json document\r\n  -c|--customhelpers    Enter a path (relative or absolute) to a folder with a custom helpers project (.csproj)\r\n  --artifacts           Enter a path (relative or absolute) where the custom helpers builds process can output artifacts (default ./temp)\r\n  -g|--globalparameter  Enter a global parameter value on the form key=value, it'll be available throught the global_parameterhelper\r\n\r\n```\r\n```bash\r\ncodegenup -s \u003cOpen_Api_File_Uri1\u003e -o \u003cOutput_Folder\u003e -t \u003cTemplate_Folder1\u003e [-s \u003cOpen_Api_File_Uri2\u003e] [-t Template_Folder2] [-t Template_Folder3] [...]\r\n````\r\n\r\nexample :\r\n\r\n```bash\r\ncodegenup -s \"https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/examples/v2.0/json/petstore-minimal.json\" -o \"output/folder\" -t \"my_template_folder\"\r\n```\r\n## Handlebars helper\r\n\r\nYou can find additional custom helper in this folder : https://github.com/BeezUP/dotnet-codegen/tree/master/src/CodegenUP.Engine/CustomHandlebars/Helpers\r\nUse cases are documented (and tested) thought `HandlebarsHelperSpecification` attributes \r\n\r\n### each_with_sort\r\n| Input document | Handlebars template | Result |\r\n|----------------|---------------------|--------|\r\n| `[{t: 'c'}, {t: 'a'}, {t: 'b'}]` | `{{#each .}}{{t}}{{/each}}` | `cab` |\r\n| `[{t: 'c'}, {t: 'a'}, {t: 'b'}]` | `{{#each_with_sort . 't'}}{{#each .}}{{t}}{{/each}}{{/each_with_sort}}` | `abc` |\r\n| `[]` | `{{#each_with_sort . .}}{{/each_with_sort}}` | `` |\r\n| `{ a : {}, b : {} }` | `{{#each_with_sort .}}{{#each .}}{{@key}}{{/each}}{{/each_with_sort}}` | `ab` |\r\n| `{ b : {}, a : {} }` | `{{#each_with_sort .}}{{#each .}}{{@key}}{{/each}}{{/each_with_sort}}` | `ab` |\r\n| `\\r\\n{\\r\\n  \"swagger\": \"2.0\",\\r\\n    \"info\": {\\r\\n        \"title\": \"Marketplace Gateway API - Feeds\",\\r\\n      ...` | `{{#each_with_sort parameters}}{{#each .}}{{@key}},{{/each}}{{/each_with_sort}}` | `accountIdParameter,credentialParameter,feedTypeParameter,marketplaceBusinessCodeParameter,publicationIdParameter,` |\r\n### each_with_sort_inv\r\n| Input document | Handlebars template | Result |\r\n|----------------|---------------------|--------|\r\n| `[{t: 'c'}, {t: 'a'}, {t: 'b'}]` | `{{#each .}}{{t}}{{/each}}` | `cab` |\r\n| `[{t: 'c'}, {t: 'a'}, {t: 'b'}]` | `{{#each_with_sort_inv . 't'}}{{#each .}}{{t}}{{/each}}{{/each_with_sort_inv}}` | `cba` |\r\n| `[]` | `{{#each_with_sort_inv . .}}{{/each_with_sort_inv}}` | `` |\r\n| `{ a : {}, b : {} }` | `{{#each_with_sort_inv .}}{{#each .}}{{@key}}{{/each}}{{/each_with_sort_inv}}` | `ba` |\r\n| `{ b : {}, a : {} }` | `{{#each_with_sort_inv .}}{{#each .}}{{@key}}{{/each}}{{/each_with_sort_inv}}` | `ba` |\r\n| `\\r\\n{\\r\\n  \"swagger\": \"2.0\",\\r\\n    \"info\": {\\r\\n        \"title\": \"Marketplace Gateway API - Feeds\",\\r\\n      ...` | `{{#each_with_sort_inv parameters}}{{#each .}}{{@key}},{{/each}}{{/each_with_sort_inv}}` | `publicationIdParameter,marketplaceBusinessCodeParameter,feedTypeParameter,credentialParameter,accountIdParameter,` |\r\n### get/set\r\n| Input document | Handlebars template | Result |\r\n|----------------|---------------------|--------|\r\n| `{}` | `{{set 'key', 'value'}}{{get 'key'}}` | `value` |\r\n| `{ key: 'value' }` | `{{set 'k', . }}{{#with_get 'k'}}{{key}}{{/with_get}}` | `value` |\r\n| `{ key: 'value' }` | `{{#with_set 'key', .key }}{{get 'key'}}{{/with_set}}{{get 'key'}}` | `value` |\r\n| `{}` | `{{set 'key', '42' }}{{get 'key'}}{{clear 'key'}}{{get 'key'}}` | `42` |\r\n### if_array_contains\r\n| Input document | Handlebars template | Result |\r\n|----------------|---------------------|--------|\r\n| `\\r\\n        {\\r\\n            'type' : 'object',\\r\\n            'required' : [ 'errorMeSSage', 'test' ],\\r\\n ...` | `{{#if_array_contains required 'errorMessage'}}OK{{else}}NOK{{/if_array_contains}}` | `OK` |\r\n| `\\r\\n        {\\r\\n            'type' : 'object',\\r\\n            'required' : [ 'errorMeSSage', 'test' ],\\r\\n ...` | `{{#if_array_contains required 'test'}}OK{{else}}NOK{{/if_array_contains}}` | `OK` |\r\n| `\\r\\n        {\\r\\n            'type' : 'object',\\r\\n            'required' : [ 'errorMeSSage', 'test' ],\\r\\n ...` | `{{#if_array_contains required 'notFound'}}OK{{else}}NOK{{/if_array_contains}}` | `NOK` |\r\n| `\\r\\n        {\\r\\n            'type' : 'object',\\r\\n            'required' : [ 'errorMeSSage', 'test' ],\\r\\n ...` | `{{#each properties}}{{#if_array_contains ../required @key}}{{type}}{{else}}{{/if_array_contains}}{{/each}}` | `string` |\r\n### if_empty\r\n| Input document | Handlebars template | Result |\r\n|----------------|---------------------|--------|\r\n| `{}` | `{{#if_empty ''}}OK{{else}}{{/if_empty}}` | `OK` |\r\n| `{}` | `{{#if_empty 'test'}}OK{{else}}NOK{{/if_empty}}` | `NOK` |\r\n### if_equals\r\n| Input document | Handlebars template | Result |\r\n|----------------|---------------------|--------|\r\n| `{}` | `{{#if_equals 'test' 'teSt'}}OK{{else}}{{/if_equals}}` | `OK` |\r\n| `{ a: '42', b: 42 }` | `{{#if_equals a ./b }}OK{{else}}{{/if_equals}}` | `OK` |\r\n| `{}` | `{{#if_equals 'test' 'NO'}}OK{{else}}NOK{{/if_equals}}` | `NOK` |\r\n### if_not_empty\r\n| Input document | Handlebars template | Result |\r\n|----------------|---------------------|--------|\r\n| `{}` | `{{#if_not_empty ''}}{{else}}OK{{/if_not_empty}}` | `OK` |\r\n| `{}` | `{{#if_not_empty 'test'}}NOK{{else}}OK{{/if_not_empty}}` | `NOK` |\r\n### if_not_equals\r\n| Input document | Handlebars template | Result |\r\n|----------------|---------------------|--------|\r\n| `{}` | `{{#if_not_equals 'test' 'teSt'}}{{else}}NOK{{/if_not_equals}}` | `NOK` |\r\n| `{ a: '42', b: 42 }` | `{{#if_not_equals a ./b }}{{else}}NOK{{/if_not_equals}}` | `NOK` |\r\n| `{}` | `{{#if_not_equals 'test' 'NO'}}OK{{else}}NOK{{/if_not_equals}}` | `OK` |\r\n### one_line\r\n| Input document | Handlebars template | Result |\r\n|----------------|---------------------|--------|\r\n| `{}` | `{{#one_line 5}}test{{/one_line}}` | `     test` |\r\n### ref_resolve\r\n| Input document | Handlebars template | Result |\r\n|----------------|---------------------|--------|\r\n| `\\r\\n{\\r\\n  \"swagger\": \"2.0\",\\r\\n    \"info\": {\\r\\n        \"title\": \"Marketplace Gateway API - Feeds\",\\r\\n      ...` | `{{#each paths}}{{#each this}}{{#each parameters}}{{#ref_resolve}}{{ name }},{{/ref_resolve}}{{/each}}{{/each}}{{/each}}` | `marketplaceBusinessCode,marketplaceBusinessCode,marketplaceBusinessCode,accountId,publicationId,x-BeezUP-Credential,request,marketplaceBusinessCode,accountId,publicationId,x-BeezUP-Credential,request,marketplaceBusinessCode,accountId,publicationId,x-BeezUP-Credential,request,marketplaceBusinessCode,accountId,publicationId,x-BeezUP-Credential,marketplaceBusinessCode,accountId,publicationId,x-BeezUP-Credential,` |\r\n### split_get_first\r\n| Input document | Handlebars template | Result |\r\n|----------------|---------------------|--------|\r\n| `{ '$ref' : '/myDataType/parameters/'}` | `{{split_get_first ./$ref '/' }}` | `myDataType` |\r\n### split_get_last\r\n| Input document | Handlebars template | Result |\r\n|----------------|---------------------|--------|\r\n| `{ '$ref' : '#/parameters/myDataType'}` | `{{split_get_last ./$ref '/' }}` | `myDataType` |\r\n### start_with\r\n| Input document | Handlebars template | Result |\r\n|----------------|---------------------|--------|\r\n| `{}` | `{{#start_with 'test' 'test-one'}}OK{{else}}{{/start_with}}` | `OK` |\r\n| `{}` | `{{#start_with 'test' 'one-test'}}OK{{else}}NOK{{/start_with}}` | `NOK` |\r\n| `{one: 'test-one', two: 'one-test'}` | `{{#start_with 'test' one}}OK{{else}}{{/start_with}}` | `OK` |\r\n| `{one: 'test-one', two: 'one-test'}` | `{{#start_with 'test' two}}OK{{else}}NOK{{/start_with}}` | `NOK` |\r\n### trim\r\n| Input document | Handlebars template | Result |\r\n|----------------|---------------------|--------|\r\n| `{ test: 42 }` | `{{trim test}}` | `42` |\r\n| `{ test: ' 42 ' }` | `{{trim test}}` | `42` |\r\n| `{ test: '- aa -' }` | `{{trim test '-'}}` | ` aa ` |\r\n| `{ test: 'AA' }` | `{{trim test 'A'}}` | `` |\r\n| `{ test: ' test ' }` | `{{trim test ' t'}}` | `es` |\r\n### trim_block\r\n| Input document | Handlebars template | Result |\r\n|----------------|---------------------|--------|\r\n| `{}` | `{{#trim_block ' '}} 1,2,3,4 {{/trim_block}}` | `1,2,3,4` |\r\n| `{}` | `{{#trim_block ','}}1,2,3,4{{/trim_block}}` | `1,2,3,4` |\r\n| `{}` | `{{#trim_block ','}}1,2,3,4,{{/trim_block}}` | `1,2,3,4` |\r\n| `{}` | `{{#trim_block ','}},1,2,3,4,{{/trim_block}}` | `1,2,3,4` |\r\n| `{}` | `{{#trim_block ','}},,1,2,3,4,,{{/trim_block}}` | `1,2,3,4` |\r\n| `{ a: '42', b: 42, c: 42 }` | `{{#trim_block ','}}{{#each this}}{{@key}},{{/each}}{{/trim_block}}` | `a,b,c` |\r\n### trim_block_end\r\n| Input document | Handlebars template | Result |\r\n|----------------|---------------------|--------|\r\n| `{}` | `{{#trim_block_end}} 1,2,3,4 {{/trim_block_end}}` | ` 1,2,3,4` |\r\n| `{}` | `{{#trim_block_end ','}}1,2,3,4{{/trim_block_end}}` | `1,2,3,4` |\r\n| `{}` | `{{#trim_block_end ','}}1,2,3,4,{{/trim_block_end}}` | `1,2,3,4` |\r\n| `{}` | `{{#trim_block_end ','}},1,2,3,4,{{/trim_block_end}}` | `,1,2,3,4` |\r\n| `{}` | `{{#trim_block_end ','}},,1,2,3,4,,{{/trim_block_end}}` | `,,1,2,3,4` |\r\n| `{ a: '42', b: 42, c: 42 }` | `{{#trim_block_end ','}}{{#each this}}{{@key}},{{/each}}{{/trim_block_end}}` | `a,b,c` |\r\n### trim_block_start\r\n| Input document | Handlebars template | Result |\r\n|----------------|---------------------|--------|\r\n| `{}` | `{{#trim_block_start}} 1,2,3,4 {{/trim_block_start}}` | `1,2,3,4 ` |\r\n| `{}` | `{{#trim_block_start ','}}1,2,3,4{{/trim_block_start}}` | `1,2,3,4` |\r\n| `{}` | `{{#trim_block_start ','}}1,2,3,4,{{/trim_block_start}}` | `1,2,3,4,` |\r\n| `{}` | `{{#trim_block_start ','}},1,2,3,4,{{/trim_block_start}}` | `1,2,3,4,` |\r\n| `{}` | `{{#trim_block_start ','}},,1,2,3,4,,{{/trim_block_start}}` | `1,2,3,4,,` |\r\n| `{ a: '42', b: 42, c: 42 }` | `{{#trim_block_start ','}}{{#each this}}{{@key}},{{/each}}{{/trim_block_start}}` | `a,b,c,` |\r\n### trim_end\r\n| Input document | Handlebars template | Result |\r\n|----------------|---------------------|--------|\r\n| `{ test: 42 }` | `{{trim_end test}}` | `42` |\r\n| `{ test: '42 ' }` | `{{trim_end test}}` | `42` |\r\n| `{ test: 'aa -' }` | `{{trim_end test '-'}}` | `aa ` |\r\n| `{ test: 'AA' }` | `{{trim_end test 'A'}}` | `` |\r\n| `{ test: ' test ' }` | `{{trim_end test ' t'}}` | ` tes` |\r\n### trim_start\r\n| Input document | Handlebars template | Result |\r\n|----------------|---------------------|--------|\r\n| `{ test: 42 }` | `{{trim_start test}}` | `42` |\r\n| `{ test: ' 42' }` | `{{trim_start test}}` | `42` |\r\n| `{ test: '- aa' }` | `{{trim_start test '-'}}` | ` aa` |\r\n| `{ test: 'AA' }` | `{{trim_start test 'A'}}` | `` |\r\n| `{ test: ' test ' }` | `{{trim_start test ' t'}}` | `est ` |\r\n### uppercase_first_letter\r\n| Input document | Handlebars template | Result |\r\n|----------------|---------------------|--------|\r\n| `{}` | `{{uppercase_first_letter .}}` | `{}` |\r\n| `{ test: 42 }` | `{{uppercase_first_letter test}}` | `42` |\r\n| `{ test: '42' }` | `{{uppercase_first_letter test}}` | `42` |\r\n| `{ test: 'aa' }` | `{{uppercase_first_letter test}}` | `Aa` |\r\n| `{ test: 'AA' }` | `{{uppercase_first_letter test}}` | `AA` |\r\n| `{ test: 'AA' }` | `test{{uppercase_first_letter test}}` | `testAA` |\r\n### with_matching\r\n| Input document | Handlebars template | Result |\r\n|----------------|---------------------|--------|\r\n| `{}` | `{{#with_matching 'test' '1' '1', '2', '2'}}{{else}}NOT FOUND{{/with_matching}}` | `NOT FOUND` |\r\n| `{}` | `{{#with_matching 'value1' 'value1' 'context1', '2', '2'}}{{.}}{{else}}NOT FOUND{{/with_matching}}` | `context1` |\r\n| `{ value: '42' }` | `{{#with_matching value '42' . }}{{value}}{{else}}NOT FOUND{{/with_matching}}` | `42` |\r\n\r\n\r\n## Custom Handlebars Helpers\r\n\r\nTo create custom local dotnet handlebars helpers, copy the [CustomHelpers](https://github.com/BeezUP/dotnet-codegen/tree/master/src/CodegenUP.CustomHelpers) project in any folder you'd like.\r\n\r\nThen use the `-c` command line option to enable the dynamic compiling \u0026 loading of the helpers you created.\r\nThe project is, in itself, a unit test project with what you need to simply create unit test case by attributes placed on your custom helpers.\r\n\r\n## Add global parameters from the command line \r\n\r\nThrough a special helper named `global_parameter`, it's possible to pass global available parameters to your template. From the command line add a as many `-g key=value` global values and use them in your templates. \r\n```\r\n{{global_parameter key}}\r\n```\r\nwill output\r\n```\r\nvalue\r\n```\r\n\r\n## Update\r\n\r\n`dotnet tool update -g CodegenUP`\r\n\r\n### Uninstall\r\n\r\n`dotnet tool uninstall -g CodegenUP`\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbeezup%2Fdotnet-codegen","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbeezup%2Fdotnet-codegen","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbeezup%2Fdotnet-codegen/lists"}