Skip to content

CSharpClientGeneratorSettings

Milan Jaroš edited this page Feb 3, 2020 · 5 revisions

Inherits CSharpGeneratorBaseSettings

Properties:

  • ClientBaseClass: Full name of the base class (empty for no base class).
  • ConfigurationClass: Specifies the name of the configuration class (see below, requires setting the ClientBaseClass)
  • GenerateClientClasses: Specifies whether generate client classes.
  • GenerateClientInterfaces: Specifies whether generate interfaces for the client classes.
  • GenerateExceptionClasses: Specifies whether to generate exception classes (default: true).
  • ExceptionClass: The name of the generated exception classes (default 'SwaggerException', may use {controller} placeholder).
  • InjectHttpClient: Inject the HttpClient via constructor so that its lifetime can be handled externally (default: true).
  • DisposeHttpClient: Specifies whether to dispose the HttpClient (injected HttpClient is never disposed).
  • ProtectedMethods: List of methods with a protected access modifier (classname.methodname).
  • UseHttpClientCreationMethod: Indicates whether to call CreateHttpClientAsync on the base class to create a new HttpClient instance (ClientBaseClass must be defined).
  • UseHttpRequestMessageCreationMethod: Indicates whether to call CreateHttpRequestMessageAsync on the base class to create a new HttpRequestMessage (ClientBaseClass must be defined).
  • WrapDtoExceptions: Specifies whether DTO exceptions are wrapped in a SwaggerException instance (default: true).
  • HttpClientType: Specifies the HttpClient type. By default the 'System.Net.Http.HttpClient' is used.
  • UseBaseUrl: Specifies whether to use and expose the base URL (default: true).
  • GenerateBaseUrlProperty: Specifies whether to generate the BaseUrl property, must be defined on the base class otherwise (default: true).
  • GenerateSyncMethods: Specifies whether to generate synchronous methods (not recommended, default: false).
  • ExposeJsonSerializerSettings: Specifies whether to expose the JsonSerializerSettings property (default: false).
  • ClientClassAccessModifier: The client class access modifier (default: public).
  • TypeAccessModifier: The DTO class/enum access modifier (default: public).
  • GenerateContractsOutput: Specifies whether to generate contracts output (interface and models in a separate file set with the ContractsOutput parameter).
  • ContractsNamespace: The contracts .NET namespace.
  • ContractsOutput: The contracts output file path (optional, if no path is set then a single file with the implementation and contracts is generated).
  • ParameterDateTimeFormat: Specifies the format for DateTime type method parameters (default: s).
  • GenerateUpdateJsonSerializerSettingsMethod: Generate the UpdateJsonSerializerSettings method (must be implemented in the base class otherwise, default: true)
  • SerializeTypeInformation: Indicates whether the generated client will automatically use TypeNameHandling.Auto property of the Newtonsoft.Json serializer. Furthermore, this option will update the generated client code for the correct use of the property. For more information about the property see: Newtonsoft.Json documentation
  • QueryNullValue: The null value used for query parameters which are null (default: '').
  • ClassName: The class name of the generated client.
  • OperationGenerationMode: The operation generation mode ('SingleClientFromOperationId' or 'MultipleClientsFromPathSegments').
  • AdditionalNamespaceUsages: The additional namespace usages.
  • AdditionalContractNamespaceUsages: The additional contract namespace usages.
  • GenerateOptionalParameters: Specifies whether to reorder parameters (required first, optional at the end) and generate optional parameters (default: false).
  • GenerateJsonMethods: Specifies whether to render ToJson() and FromJson() methods for DTOs (default: true).
  • EnforceFlagEnums: Specifies whether enums should be always generated as bit flags (default: false).
  • ParameterArrayType: The generic array .NET type of operation parameters (default: 'IEnumerable').
  • ParameterDictionaryType: The generic dictionary .NET type of operation parameters (default: 'IDictionary').
  • ResponseArrayType: The generic array .NET type of operation responses (default: 'ICollection').
  • ResponseDictionaryType: The generic dictionary .NET type of operation responses (default: 'IDictionary').
  • WrapResponses: Specifies whether to wrap success responses to allow full response access.
  • WrapResponseMethods: List of methods where responses are wrapped ('ControllerName.MethodName', WrapResponses must be true).
  • GenerateResponseClasses: Specifies whether to generate response classes (default: true).
  • ResponseClass: The response class (default 'SwaggerResponse', may use '{controller}' placeholder).
  • Namespace: The namespace of the generated classes.
  • RequiredPropertiesMustBeDefined: Specifies whether a required property must be defined in JSON (sets Required.Always when the property is required).
  • DateType: The date .NET type (default: 'DateTimeOffset').
  • JsonConverters: Specifies the custom Json.NET converter types (optional, comma separated).
  • AnyType: The any .NET type (default: 'object').
  • DateTimeType: The date time .NET type (default: 'DateTimeOffset').
  • TimeType: The time .NET type (default: 'TimeSpan').
  • TimeSpanType: The time span .NET type (default: 'TimeSpan').
  • ArrayType: The generic array .NET type (default: 'ICollection').
  • ArrayInstanceType: The generic array .NET instance type (default: empty = ArrayType).
  • DictionaryType: The generic dictionary .NET type (default: 'IDictionary').
  • DictionaryInstanceType: The generic dictionary .NET instance type (default: empty = DictionaryType).
  • ArrayBaseType: The generic array .NET type (default: 'Collection').
  • DictionaryBaseType: The generic dictionary .NET type (default: 'Dictionary').
  • ClassStyle: The CSharp class style, 'Poco' or 'Inpc' (default: 'Poco').
  • GenerateDefaultValues: Specifies whether to generate default values for properties (may generate CSharp 6 code, default: true).
  • GenerateDataAnnotations: Specifies whether to generate data annotation attributes on DTO classes (default: true).
  • ExcludedTypeNames: The excluded DTO type names (must be defined in an import or other namespace).
  • ExcludedParameterNames: The globally excluded parameter names.
  • HandleReferences: Use preserve references handling (All) in the JSON serializer (default: false).
  • GenerateImmutableArrayProperties: Specifies whether to remove the setter for non-nullable array properties (default: false).
  • GenerateImmutableDictionaryProperties: Specifies whether to remove the setter for non-nullable dictionary properties (default: false).
  • JsonSerializerSettingsTransformationMethod: The name of a static method which is called to transform the JsonSerializerSettings used in the generated ToJson()/FromJson() methods (default: none).
  • InlineNamedArrays: Inline named arrays (default: false).
  • InlineNamedDictionaries: Inline named dictionaries (default: false).
  • InlineNamedTuples: Inline named tuples (default: true).
  • InlineNamedAny: Inline named any types (default: false).
  • GenerateDtoTypes: Specifies whether to generate DTO classes.
  • TemplateDirectory: The Liquid template directory (experimental).
  • TypeNameGenerator: The custom ITypeNameGenerator implementation type in the form 'assemblyName:fullTypeName' or 'fullTypeName').
  • PropertyNameGeneratorType: The custom IPropertyNameGenerator implementation type in the form 'assemblyName:fullTypeName' or 'fullTypeName').
  • EnumNameGeneratorType: The custom IEnumNameGenerator implementation type in the form 'assemblyName:fullTypeName' or 'fullTypeName').
  • Input: A file path or URL to the data or the JSON data itself.
  • ServiceHost: Overrides the service host of the web document (optional, use '.' to remove the hostname).
  • ServiceSchemes: Overrides the allowed schemes of the web service (optional, comma separated, 'http', 'https', 'ws', 'wss').
  • Output: The output file path (optional).