有什么方法可以在命令行上使用带有NSWAG的自定义生成器?

发布于 2025-02-11 15:43:23 字数 1838 浏览 1 评论 0原文

我们正在使用NSWAG生成Web客户端。

我们有一些用于打字名称和操作名称的自定义发电机。

当前,我们使用NSWAG类库,并在控制台应用程序中写下自定义代码。

这是我们的csharpClientGeneratorSettings。如您所见,我们有一个自定义类,用于typenamegeneratoroperationNameGenerator

        var cSharpClientGeneratorSettings = new CSharpClientGeneratorSettings
        {
            ClassName = "{controller}Client",
            CSharpGeneratorSettings =
            {
                Namespace = this._clientNamespace,
                ClassStyle = CSharpClassStyle.Inpc,
                DateTimeType = "System.DateTime",
                DateType = "System.DataTime",
                TypeNameGenerator = new CustomTypeNameGenerator(),
                JsonLibrary = CSharpJsonLibrary.SystemTextJson
            },
            GenerateClientInterfaces = true,
            GenerateClientClasses = true,
            OperationNameGenerator = new TClientGenerator(),
            ExceptionClass = "YadaYada.Library.Client.SwaggerException",
            InjectHttpClient = true,
            SerializeTypeInformation = true,
            DisposeHttpClient = true,
            WrapDtoExceptions = false,
            GenerateOptionalParameters = true,
            ExposeJsonSerializerSettings = false,
            ParameterArrayType = "System.Collections.Generic.IList",
            ResponseArrayType = "System.Collections.Generic.IList",
            GenerateExceptionClasses = false,
            UseBaseUrl = false,
            GenerateDtoTypes = false,
            AdditionalNamespaceUsages = this._additionalNamespaces
        };

我想作为MSBUILD任务运行此代码生成并部署我们的控制台应用程序。有什么方法可以将我们的自定义名称运算符“注入” NSWAG的命令行版本? (nswag.exe)?

We are using NSwag to generate web clients.

We have some custom generators for TypeName and OperationName.

Currently we use the NSwag class library and have custom code written to call in a console application.

Here is our CSharpClientGeneratorSettings. As you can see we have a custom class for TypeNameGenerator and OperationNameGenerator.

        var cSharpClientGeneratorSettings = new CSharpClientGeneratorSettings
        {
            ClassName = "{controller}Client",
            CSharpGeneratorSettings =
            {
                Namespace = this._clientNamespace,
                ClassStyle = CSharpClassStyle.Inpc,
                DateTimeType = "System.DateTime",
                DateType = "System.DataTime",
                TypeNameGenerator = new CustomTypeNameGenerator(),
                JsonLibrary = CSharpJsonLibrary.SystemTextJson
            },
            GenerateClientInterfaces = true,
            GenerateClientClasses = true,
            OperationNameGenerator = new TClientGenerator(),
            ExceptionClass = "YadaYada.Library.Client.SwaggerException",
            InjectHttpClient = true,
            SerializeTypeInformation = true,
            DisposeHttpClient = true,
            WrapDtoExceptions = false,
            GenerateOptionalParameters = true,
            ExposeJsonSerializerSettings = false,
            ParameterArrayType = "System.Collections.Generic.IList",
            ResponseArrayType = "System.Collections.Generic.IList",
            GenerateExceptionClasses = false,
            UseBaseUrl = false,
            GenerateDtoTypes = false,
            AdditionalNamespaceUsages = this._additionalNamespaces
        };

I would like to run this code generation as an MSBuild task without have to build and deploy our console application. Is there any way to 'inject' our custom name operators into the command line version of NSwag? (nswag.exe)?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文