Swagger NSwag生成单个客户端类

Swagger NSwag生成单个客户端类,swagger,code-generation,swashbuckle,nswag,nswagstudio,Swagger,Code Generation,Swashbuckle,Nswag,Nswagstudio,当使用NSwagStudio生成C#客户机代码(不在文件中)时,它生成的方式是,仅生成一个客户机类和相应的接口,其中包含所有控制器方法。 但是,当尝试对NSwag.MSBuild执行相同操作时,它会为每个控制器生成单独的分部类/接口 以下是nswag.json: { "openApiToCSharpClient": { "clientBaseClass": "BillingBaseClient", "configura

当使用
NSwagStudio
生成C#客户机代码(不在文件中)时,它生成的方式是,仅生成一个客户机类和相应的接口,其中包含所有控制器方法。 但是,当尝试对
NSwag.MSBuild
执行相同操作时,它会为每个控制器生成单独的分部类/接口

以下是
nswag.json

{
"openApiToCSharpClient": {
  "clientBaseClass": "BillingBaseClient",
  "configurationClass": "ConnectionOptions",
  "generateClientClasses": true,
  "generateClientInterfaces": true,
  "clientBaseInterface": null,
  "injectHttpClient": true,
  "disposeHttpClient": true,
  "protectedMethods": [
  ],
  "generateExceptionClasses": true,
  "exceptionClass": "ApiException",
  "wrapDtoExceptions": true,
  "useHttpClientCreationMethod": false,
  "httpClientType": "System.Net.Http.HttpClient",
  "useHttpRequestMessageCreationMethod": true,
  "useBaseUrl": true,
  "generateBaseUrlProperty": false,
  "generateSyncMethods": false,
  "exposeJsonSerializerSettings": false,
  "clientClassAccessModifier": "public",
  "typeAccessModifier": "public",
  "generateContractsOutput": false,
  "contractsNamespace": null,
  "contractsOutputFilePath": null,
  "parameterDateTimeFormat": "s",
  "parameterDateFormat": "yyyy-MM-dd",
  "generateUpdateJsonSerializerSettingsMethod": true,
  "useRequestAndResponseSerializationSettings": false,
  "serializeTypeInformation": false,
  "queryNullValue": "",
  "className": "BillingClient",
  "operationGenerationMode": "MultipleClientsFromOperationId",
  "additionalNamespaceUsages": [
  ],
  "additionalContractNamespaceUsages": [
  ],
  "generateOptionalParameters": true,
  "generateJsonMethods": true,
  "enforceFlagEnums": false,
  "parameterArrayType": "System.Collections.Generic.IEnumerable",
  "parameterDictionaryType": "System.Collections.Generic.IDictionary",
  "responseArrayType": "System.Collections.Generic.ICollection",
  "responseDictionaryType": "System.Collections.Generic.IDictionary",
  "wrapResponses": false,
  "wrapResponseMethods": [
  ],
  "generateResponseClasses": true,
  "responseClass": "SwaggerResponse",
  "namespace": "ServiceTitan.Billing.Api.Client",
  "requiredPropertiesMustBeDefined": true,
  "dateType": "System.DateTimeOffset",
  "jsonConverters": null,
  "anyType": "object",
  "dateTimeType": "System.DateTimeOffset",
  "timeType": "System.TimeSpan",
  "timeSpanType": "System.TimeSpan",
  "arrayType": "System.Collections.Generic.ICollection",
  "arrayInstanceType": "System.Collections.ObjectModel.Collection",
  "dictionaryType": "System.Collections.Generic.IDictionary",
  "dictionaryInstanceType": "System.Collections.Generic.Dictionary",
  "arrayBaseType": "System.Collections.ObjectModel.Collection",
  "dictionaryBaseType": "System.Collections.Generic.Dictionary",
  "classStyle": "Poco",
  "generateDefaultValues": true,
  "generateDataAnnotations": true,
  "excludedTypeNames": [
  ],
  "excludedParameterNames": [
  ],
  "handleReferences": false,
  "generateImmutableArrayProperties": false,
  "generateImmutableDictionaryProperties": false,
  "jsonSerializerSettingsTransformationMethod": null,
  "inlineNamedArrays": false,
  "inlineNamedDictionaries": false,
  "inlineNamedTuples": true,
  "inlineNamedAny": false,
  "generateDtoTypes": true,
  "generateOptionalPropertiesAsNullable": false,
  "templateDirectory": null,
  "typeNameGeneratorType": null,
  "propertyNameGeneratorType": null,
  "enumNameGeneratorType": null,
  "serviceHost": null,
  "serviceSchemes": null,
  "output": "BillingClient.g.cs"
  }
}

那么,告诉NSwag生成单个类/接口我缺少哪个选项呢?

您需要更改的选项是
operationGenerationMode
,它已经存在于NSwag.json文件中,但是如果您想要为多个控制器创建一个接口,则需要将其值更改为
SingleClientFromOperationId
MultipleClientsFromOperationId
是您当前设置的,它将为每个控制器生成一个类。

您需要更改的选项是nswag.json文件中已有的
operationGenerationMode
,但是,如果要为多个控制器提供一个接口,则需要将其值更改为
SingleClientFromOperationId
MultipleClientsFromOperationId
是您当前设置的,它将为每个控制器生成一个类