From fd359291a3a3410c6df7883fd8319314e0f2f65c Mon Sep 17 00:00:00 2001 From: Colin Eberhardt Date: Sun, 5 Mar 2023 20:52:10 +0000 Subject: [PATCH] feat: allow the specification of a namespace via the generator options (#47) --- config.json | 6 ++++++ partials/namespace.handlebars | 2 +- template/ApiClient.cs.handlebars | 2 +- template/ApiModel.cs.handlebars | 2 +- template/Configuration.cs.handlebars | 2 +- template/IApiClient.cs.handlebars | 2 +- template/Info.cs.handlebars | 2 +- template/Startup.cs.handlebars | 2 +- 8 files changed, 13 insertions(+), 7 deletions(-) create mode 100644 config.json diff --git a/config.json b/config.json new file mode 100644 index 0000000..95ea006 --- /dev/null +++ b/config.json @@ -0,0 +1,6 @@ +{ + "namespace": { + "default": "OpenApiForge", + "description": "The namespace for the generated classes." + } +} diff --git a/partials/namespace.handlebars b/partials/namespace.handlebars index 31723ba..459e293 100644 --- a/partials/namespace.handlebars +++ b/partials/namespace.handlebars @@ -1 +1 @@ -{{#if infoTitle}}namespace {{toClassName infoTitle}}{{else}}namespace OpenApiForge{{/if}} \ No newline at end of file +namespace {{_options.[generator.namespace]}} \ No newline at end of file diff --git a/template/ApiClient.cs.handlebars b/template/ApiClient.cs.handlebars index f4be51d..eea61a1 100644 --- a/template/ApiClient.cs.handlebars +++ b/template/ApiClient.cs.handlebars @@ -15,7 +15,7 @@ using System.Web; /// {{#if info.description}}{{docComment info.description}}{{/if}} {{#if info.version}}/// {{info.version}}{{/if}} -{{>namespace info.title}} { +{{>namespace}} { public class ApiClient{{_tag.name}} : IApiClient{{_tag.name}} { diff --git a/template/ApiModel.cs.handlebars b/template/ApiModel.cs.handlebars index 4b24e7e..ec2dd36 100644 --- a/template/ApiModel.cs.handlebars +++ b/template/ApiModel.cs.handlebars @@ -1,7 +1,7 @@ using System; using System.Collections.Generic; -{{>namespace info.title}} { +{{>namespace}} { {{#each components.schemas}} {{> model}} diff --git a/template/Configuration.cs.handlebars b/template/Configuration.cs.handlebars index 23851fd..eae0bc7 100644 --- a/template/Configuration.cs.handlebars +++ b/template/Configuration.cs.handlebars @@ -2,7 +2,7 @@ using System; using System.Collections.Generic; using System.Text; -{{>namespace info.title}} { +{{>namespace}} { public class Configuration { diff --git a/template/IApiClient.cs.handlebars b/template/IApiClient.cs.handlebars index 870eea1..f250144 100644 --- a/template/IApiClient.cs.handlebars +++ b/template/IApiClient.cs.handlebars @@ -7,7 +7,7 @@ using System.Threading.Tasks; /// {{#if info.description}}{{docComment info.description}}{{/if}} {{#if info.version}}/// {{info.version}}{{/if}} -{{>namespace info.title}} { +{{>namespace}} { public interface IApiClient{{_tag.name}} { diff --git a/template/Info.cs.handlebars b/template/Info.cs.handlebars index 8d1b096..d833250 100644 --- a/template/Info.cs.handlebars +++ b/template/Info.cs.handlebars @@ -2,7 +2,7 @@ using System; using System.Collections.Generic; using System.Text; -{{>namespace info.title}} { +{{>namespace}} { public static class Info { diff --git a/template/Startup.cs.handlebars b/template/Startup.cs.handlebars index faa042d..b06aef7 100644 --- a/template/Startup.cs.handlebars +++ b/template/Startup.cs.handlebars @@ -3,7 +3,7 @@ using System.Linq; using System.Net.Http; using Microsoft.Extensions.DependencyInjection; -{{>namespace info.title}} { +{{>namespace}} { public static class Startup {