diff --git a/src/Refitter.Core/Settings/CodeGenerationConfig.cs b/src/Refitter.Core/Settings/CodeGenerationConfig.cs
deleted file mode 100644
index fe1f95bf6..000000000
--- a/src/Refitter.Core/Settings/CodeGenerationConfig.cs
+++ /dev/null
@@ -1,141 +0,0 @@
-using System.ComponentModel;
-using System.Diagnostics.CodeAnalysis;
-using System.Text.Json.Serialization;
-
-namespace Refitter.Core;
-
-///
-/// Configuration for what code generation features are enabled.
-///
-[ExcludeFromCodeCoverage]
-public class CodeGenerationConfig
-{
- ///
- /// Gets or sets a value indicating whether contracts should be generated.
- ///
- [Description("Generate contracts. Default is true.")]
- public bool GenerateContracts { get; set; } = true;
-
- ///
- /// Gets or sets a value indicating whether clients should be generated.
- ///
- [Description("Generate clients. Default is true.")]
- public bool GenerateClients { get; set; } = true;
-
- ///
- /// Gets or sets a value indicating whether clients should implement IDisposable.
- ///
- [Description("Generate clients that implement IDisposable.")]
- public bool GenerateDisposableClients { get; set; }
-
- ///
- /// Gets or sets a value indicating whether XML doc comments should be generated.
- ///
- [Description("Generate XML doc comments. Default is true.")]
- public bool GenerateXmlDocCodeComments { get; set; } = true;
-
- ///
- /// Gets or sets a value indicating whether ApiException and IApiResponse should be documented with
- /// the relevant status codes specified in the OpenAPI document.
- ///
- [Description(
- """
- Indicating whether ApiException and IApiResponse should be documented with
- the relevant status codes specified in the OpenAPI document.
- """
- )]
- public bool GenerateStatusCodeComments { get; set; } = true;
-
- ///
- /// Gets or sets a value indicating whether to add auto-generated header.
- ///
- [Description("Add auto-generated header. Default is true.")]
- public bool AddAutoGeneratedHeader { get; set; } = true;
-
- ///
- /// Gets or sets a value indicating whether to add accept headers [Headers("Accept: application/json")].
- ///
- [Description("Add accept headers [Headers(\"Accept: application/json\")]. Default is true.")]
- public bool AddAcceptHeaders { get; set; } = true;
-
- ///
- /// Gets or sets a value indicating whether to add content-type headers [Headers("Content-Type: application/json")].
- ///
- [Description("Add content-type headers [Headers(\"Content-Type: application/json\")]. Default is true.")]
- public bool AddContentTypeHeaders { get; set; } = true;
-
- ///
- /// Gets or sets a value indicating whether to return IApiResponse objects.
- ///
- [Description("Return IApiResponse objects.")]
- public bool ReturnIApiResponse { get; set; }
-
- ///
- /// Gets or sets a value indicating whether to return IObservable or Task
- ///
- [Description("Return IObservable or Task.")]
- public bool ReturnIObservable { get; set; }
-
- ///
- /// Gets or sets a dictionary of operation ids and a specific response type that they should use. The type is
- /// wrapped in a task, but otherwise unmodified (so make sure that the namespaces are imported or specified).
- ///
- [Description(
- """
- A dictionary of operation ids and a specific response type that they should use.
- The type is wrapped in a task, but otherwise unmodified (so make sure that the namespaces are imported or specified).
- """
- )]
- public Dictionary ResponseTypeOverride { get; set; } = new();
-
- ///
- /// Gets or sets a value indicating whether to generate operation headers.
- ///
- [Description("Generate operation headers. Default is true.")]
- public bool GenerateOperationHeaders { get; set; } = true;
-
- ///
- /// Gets or sets a value indicating whether to generate deprecated operations, otherwise false
- ///
- [Description("Generate deprecated operations. Default is true.")]
- public bool GenerateDeprecatedOperations { get; set; } = true;
-
- ///
- /// Set to true to Generate a Refit interface for each endpoint
- ///
- [Description("Generate a Refit interface for each endpoint.")]
- [JsonConverter(typeof(JsonStringEnumConverter))]
- public MultipleInterfaces MultipleInterfaces { get; set; }
-
- ///
- /// Generate operation names using pattern.
- /// When using , this is name of the Execute() method in the interface.
- ///
- [Description(
- """
- Generate operation names using pattern. When using --multiple-interfaces ByEndpoint,
- this is name of the Execute() method in the interface.
- """
- )]
- public string? OperationNameTemplate { get; set; }
-
- ///
- /// The NSwag IOperationNameGenerator implementation to use
- ///
- [Description("The NSwag IOperationNameGenerator implementation to use.")]
- [JsonConverter(typeof(JsonStringEnumConverter))]
- public OperationNameGeneratorTypes OperationNameGenerator { get; set; }
-
- ///
- /// Set to false to skip default additional properties. Default is true
- ///
- [Description("Skip default additional properties. Default is true.")]
- public bool GenerateDefaultAdditionalProperties { get; set; } = true;
-
- ///
- /// Gets or sets a directory path which contains liquid templates for NSwag. If null or empty, uses default
- /// templates.
- ///
- [Description("Custom directory with NSwag fluid templates for code generation. Default is null which uses the default NSwag templates. See https://github.com/RicoSuter/NSwag/wiki/Templates")]
- public string? CustomTemplateDirectory { get; set; }
-}
diff --git a/src/Refitter.Core/Settings/FeatureConfig.cs b/src/Refitter.Core/Settings/FeatureConfig.cs
deleted file mode 100644
index 0a5945f05..000000000
--- a/src/Refitter.Core/Settings/FeatureConfig.cs
+++ /dev/null
@@ -1,59 +0,0 @@
-using System.ComponentModel;
-using System.Diagnostics.CodeAnalysis;
-using System.Text.Json.Serialization;
-
-namespace Refitter.Core;
-
-///
-/// Configuration for optional features including Apizr, polymorphic serialization,
-/// authentication headers, and AOT compilation support.
-///
-[ExcludeFromCodeCoverage]
-public class FeatureConfig
-{
- ///
- /// Get ot set the settings describing how to configure Apizr
- ///
- [Description("The settings describing how to configure Apizr.")]
- public ApizrSettings? ApizrSettings { get; set; }
-
- ///
- /// Set to true to use System.Text.Json polymorphic serialization. Default is false
- /// Gets a value indicating whether to use System.Text.Json polymorphic serialization
- /// Replaces NSwag JsonInheritanceConverter attributes with System.Text.Json JsonPolymorphicAttributes.
- /// To have the native support of inheritance (de)serialization and fallback to base types when
- /// payloads with (yet) unknown types are offered by newer versions of an API
- /// See https://learn.microsoft.com/en-us/dotnet/standard/serialization/system-text-json/polymorphism for more information
- ///
- [Description(
- """
- Use System.Text.Json polymorphic serialization. Default is false.
- Replace NSwag JsonInheritanceConverter attributes with System.Text.Json JsonPolymorphicAttributes.
- To have the native support of inheritance (de)serialization and fallback to base types when
- payloads with (yet) unknown types are offered by newer versions of an API
- See https://learn.microsoft.com/en-us/dotnet/standard/serialization/system-text-json/polymorphism for more information
- """
- )]
- public bool UsePolymorphicSerialization { get; set; }
-
- ///
- /// Gets or sets a value indicating whether to generate JsonSerializerContext for AOT compilation support.
- /// The context is emitted into the contracts namespace and only when contracts are generated.
- ///
- [Description("Generate JsonSerializerContext for AOT compilation support in the contracts namespace when contracts are generated.")]
- public bool GenerateJsonSerializerContext { get; set; }
-
- ///
- /// Gets or sets a value indicating whether to generate Security Schema Authentication headers.
- ///
- [Description("Generate Security Schema Authentication headers")]
- [JsonConverter(typeof(JsonStringEnumConverter))]
- public AuthenticationHeaderStyle AuthenticationHeaderStyle { get; set; }
-
- ///
- /// Gets or sets the security scheme name for which to generate authentication headers.
- /// When specified, only endpoints using this security scheme will have authentication headers generated.
- ///
- [Description("Security scheme for which to generate authentication headers.")]
- public string? SecurityScheme { get; set; }
-}
diff --git a/src/Refitter.Core/Settings/FilterConfig.cs b/src/Refitter.Core/Settings/FilterConfig.cs
deleted file mode 100644
index a2c7d309d..000000000
--- a/src/Refitter.Core/Settings/FilterConfig.cs
+++ /dev/null
@@ -1,43 +0,0 @@
-using System.ComponentModel;
-using System.Diagnostics.CodeAnalysis;
-
-namespace Refitter.Core;
-
-///
-/// Configuration for filtering which endpoints and schemas to include in generated code.
-///
-[ExcludeFromCodeCoverage]
-public class FilterConfig
-{
- ///
- /// Set to true to only include Endpoints that contain this tag.
- /// May be set multiple times and result in OR'ed evaluation.
- ///
- [Description("Generate a Refit interface for each endpoint.")]
- public string[] IncludeTags { get; set; } = [];
-
- ///
- /// Set to true to only include Paths that match the provided regular expression.
- /// May be set multiple times
- ///
- [Description("Only include Paths that match the provided regular expression. May be set multiple times.")]
- public string[] IncludePathMatches { get; set; } = [];
-
- ///
- /// Gets or sets a collection of headers to omit from operation signatures. (default: [])
- ///
- [Description("A collection of headers to omit from operation signatures.")]
- public string[] IgnoredOperationHeaders { get; set; } = [];
-
- ///
- /// Exclude namespaces on generated types
- ///
- [Description("Exclude namespaces on generated types.")]
- public string[] ExcludeNamespaces { get; set; } = [];
-
- ///
- /// Add additional namespace to generated types
- ///
- [Description("Add additional namespace to generated types.")]
- public string[] AdditionalNamespaces { get; set; } = [];
-}
diff --git a/src/Refitter.Core/Settings/OpenApiSourceConfig.cs b/src/Refitter.Core/Settings/OpenApiSourceConfig.cs
deleted file mode 100644
index e7047e51a..000000000
--- a/src/Refitter.Core/Settings/OpenApiSourceConfig.cs
+++ /dev/null
@@ -1,28 +0,0 @@
-using System.ComponentModel;
-using System.Diagnostics.CodeAnalysis;
-using System.Text.Json.Serialization;
-
-namespace Refitter.Core;
-
-///
-/// Configuration for the OpenAPI document source paths.
-///
-[ExcludeFromCodeCoverage]
-public class OpenApiSourceConfig
-{
- ///
- /// Gets or sets the path to the Open API.
- ///
- [Description("The path to the OpenAPI document.")]
- [JsonPropertyName("openApiPath")]
- [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
- public string? OpenApiPath { get; set; }
-
- ///
- /// Gets or sets the paths to multiple Open API documents. When specified, the documents are merged.
- /// This takes precedence over when non-empty.
- ///
- [Description("The paths to multiple OpenAPI documents. When specified, the documents are merged into a single client.")]
- [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
- public string[]? OpenApiPaths { get; set; }
-}
diff --git a/src/Refitter.Core/Settings/OutputConfig.cs b/src/Refitter.Core/Settings/OutputConfig.cs
deleted file mode 100644
index aae7e4477..000000000
--- a/src/Refitter.Core/Settings/OutputConfig.cs
+++ /dev/null
@@ -1,80 +0,0 @@
-using System.ComponentModel;
-using System.Diagnostics.CodeAnalysis;
-
-namespace Refitter.Core;
-
-///
-/// Configuration for generated output paths, filenames, and namespaces.
-///
-[ExcludeFromCodeCoverage]
-public class OutputConfig
-{
- ///
- /// Default output folder for generated files.
- ///
- public const string DefaultOutputFolder = "./Generated";
-
- ///
- /// Default namespace for generated code.
- ///
- public const string DefaultNamespace = "GeneratedCode";
-
- ///
- /// Gets or sets the namespace for the generated code. (default: GeneratedCode)
- ///
- [Description("The namespace for the generated code. Default is GeneratedCode.")]
- public string Namespace { get; set; } = DefaultNamespace;
-
- ///
- /// Gets or sets the namespace for the generated contracts. (default: GeneratedCode);
- ///
- [Description("The namespace for the generated contracts. Default is GeneratedCode.")]
- public string? ContractsNamespace { get; set; }
-
- ///
- /// Gets or sets the relative path to a folder in which the output files are generated. (default: ./Generated)
- ///
- [Description("The relative path to a folder in which the output files are generated. Default is ./Generated.")]
- public string OutputFolder { get; set; } = DefaultOutputFolder;
-
- ///
- /// Gets or sets the relative path to a folder where to store the generated contracts. (default: ./Generated)
- ///
- [Description("The relative path to a folder where to store the generated contracts. Default is ./Generated.")]
- public string? ContractsOutputFolder { get; set; }
-
- ///
- /// Gets or sets the filename of the generated code.
- /// For the CLI tool, the default is Output.cs
- /// For the Source Generator, this is the name of the generated class and the default is [.refitter defined naming OR .refitter filename].g.cs)
- ///
- [Description(
- """
- The filename of the generated code.
- For the CLI tool, the default is Output.cs
- For the Source Generator, this is the name of the generated class
- and the default is [.refitter defined naming OR .refitter filename].g.cs
- """
- )]
- public string? OutputFilename { get; set; }
-
- ///
- /// Set to true to generate multiple files. Default is false
- /// This is automatically set to true when is specified
- /// Refit interface(s) are written to a file called RefitInterfaces.cs
- /// Contracts are written to a file called Contracts.cs
- /// Dependency Injection is written to a file called DependencyInjection.cs
- /// When is enabled, an additional serializer context file is emitted.
- ///
- [Description(
- """
- Generate multiple files. Default is false.
- This is automatically set to true when ContractsOutputFolder is specified
- Refit interface(s) are written to a file called RefitInterfaces.cs
- Contracts are written to a file called Contracts.cs
- Dependency Injection is written to a file called DependencyInjection.cs
- When GenerateJsonSerializerContext is enabled, an additional serializer context file is emitted.
- """
- )]
- public bool GenerateMultipleFiles { get; set; }
-}
diff --git a/src/Refitter.Core/Settings/ParameterConfig.cs b/src/Refitter.Core/Settings/ParameterConfig.cs
deleted file mode 100644
index f69be631d..000000000
--- a/src/Refitter.Core/Settings/ParameterConfig.cs
+++ /dev/null
@@ -1,63 +0,0 @@
-using System.ComponentModel;
-using System.Diagnostics.CodeAnalysis;
-using System.Text.Json.Serialization;
-using NSwag.CodeGeneration;
-
-namespace Refitter.Core;
-
-///
-/// Configuration for method parameter code generation options.
-///
-[ExcludeFromCodeCoverage]
-public class ParameterConfig
-{
- ///
- /// Enable or disable the use of cancellation tokens.
- ///
- [Description("Enable or disable the use of cancellation tokens.")]
- public bool UseCancellationTokens { get; set; }
-
- ///
- /// Set to true to explicitly format date query string parameters
- /// in ISO 8601 standard date format using delimiters (for example: 2023-06-15)
- ///
- [Description(
- """
- Set to true to explicitly format date query string parameters
- in ISO 8601 standard date format using delimiters (for example: 2023-06-15)
- """
- )]
- public bool UseIsoDateFormat { get; set; }
-
- ///
- /// Set to true to re-order optional parameters to the end of the parameter list
- ///
- [Description("Re-order optional parameters to the end of the parameter list.")]
- public bool OptionalParameters { get; set; }
-
- ///
- /// Set to true to wrap multiple query parameters into a single complex one. Default is false (no wrapping).
- /// See https://github.com/reactiveui/refit?tab=readme-ov-file#dynamic-querystring-parameters for more information.
- ///
- [Description(
- """
- Wrap multiple query parameters into a single complex one.
- See https://github.com/reactiveui/refit?tab=readme-ov-file#dynamic-querystring-parameters for more information.
- """
- )]
- public bool UseDynamicQuerystringParameters { get; set; }
-
- ///
- /// Gets or sets the collection format to use for array query parameters.
- /// Default is CollectionFormat.Multi.
- ///
- [Description("The collection format to use for array query parameters. Default is CollectionFormat.Multi.")]
- [JsonConverter(typeof(JsonStringEnumConverter))]
- public CollectionFormat CollectionFormat { get; set; } = CollectionFormat.Multi;
-
- ///
- /// Gets or sets the parameter name generator for customizing parameter names.
- ///
- [JsonIgnore]
- public IParameterNameGenerator? ParameterNameGenerator { get; set; }
-}
diff --git a/src/Refitter.Core/Settings/RefitGeneratorSettings.cs b/src/Refitter.Core/Settings/RefitGeneratorSettings.cs
index 30cc81e87..98679aefc 100644
--- a/src/Refitter.Core/Settings/RefitGeneratorSettings.cs
+++ b/src/Refitter.Core/Settings/RefitGeneratorSettings.cs
@@ -14,21 +14,12 @@ public class RefitGeneratorSettings
///
/// Default output folder for generated files.
///
- public const string DefaultOutputFolder = OutputConfig.DefaultOutputFolder;
+ public const string DefaultOutputFolder = "./Generated";
///
/// Default namespace for generated code.
///
- public const string DefaultNamespace = OutputConfig.DefaultNamespace;
-
- private readonly OpenApiSourceConfig openApiSource = new();
- private readonly CodeGenerationConfig codeGeneration = new();
- private readonly ParameterConfig parameterConfig = new();
- private readonly OutputConfig outputConfig = new();
- private readonly TypeConfig typeConfig = new();
- private readonly FilterConfig filterConfig = new();
- private readonly SchemaConfig schemaConfig = new();
- private readonly FeatureConfig featureConfig = new();
+ public const string DefaultNamespace = "GeneratedCode";
///
/// Gets or sets the path to the Open API.
@@ -36,11 +27,7 @@ public class RefitGeneratorSettings
[Description("The path to the OpenAPI document.")]
[JsonPropertyName("openApiPath")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
- public string? OpenApiPath
- {
- get => openApiSource.OpenApiPath;
- set => openApiSource.OpenApiPath = value;
- }
+ public string? OpenApiPath { get; set; }
///
/// Gets or sets the paths to multiple Open API documents. When specified, the documents are merged.
@@ -48,31 +35,19 @@ public string? OpenApiPath
///
[Description("The paths to multiple OpenAPI documents. When specified, the documents are merged into a single client.")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
- public string[]? OpenApiPaths
- {
- get => openApiSource.OpenApiPaths;
- set => openApiSource.OpenApiPaths = value;
- }
+ public string[]? OpenApiPaths { get; set; }
///
/// Gets or sets the namespace for the generated code. (default: GeneratedCode)
///
[Description("The namespace for the generated code. Default is GeneratedCode.")]
- public string Namespace
- {
- get => outputConfig.Namespace;
- set => outputConfig.Namespace = value;
- }
+ public string Namespace { get; set; } = DefaultNamespace;
///
/// Gets or sets the namespace for the generated contracts. (default: GeneratedCode);
///
[Description("The namespace for the generated contracts. Default is GeneratedCode.")]
- public string? ContractsNamespace
- {
- get => outputConfig.ContractsNamespace;
- set => outputConfig.ContractsNamespace = value;
- }
+ public string? ContractsNamespace { get; set; }
///
/// Gets or sets the naming settings.
@@ -85,51 +60,31 @@ public string? ContractsNamespace
///
[Description("Controls how generated contract properties are named. Default is PascalCase. Possible values: PascalCase, PreserveOriginal.")]
[JsonConverter(typeof(JsonStringEnumConverter))]
- public PropertyNamingPolicy PropertyNamingPolicy
- {
- get => typeConfig.PropertyNamingPolicy;
- set => typeConfig.PropertyNamingPolicy = value;
- }
+ public PropertyNamingPolicy PropertyNamingPolicy { get; set; } = PropertyNamingPolicy.PascalCase;
///
/// Gets or sets a value indicating whether contracts should be generated.
///
[Description("Generate contracts. Default is true.")]
- public bool GenerateContracts
- {
- get => codeGeneration.GenerateContracts;
- set => codeGeneration.GenerateContracts = value;
- }
+ public bool GenerateContracts { get; set; } = true;
///
/// Gets or sets a value indicating whether clients should be generated.
///
[Description("Generate clients. Default is true.")]
- public bool GenerateClients
- {
- get => codeGeneration.GenerateClients;
- set => codeGeneration.GenerateClients = value;
- }
+ public bool GenerateClients { get; set; } = true;
///
/// Gets or sets a value indicating whether clients should implement IDisposable.
///
[Description("Generate clients that implement IDisposable.")]
- public bool GenerateDisposableClients
- {
- get => codeGeneration.GenerateDisposableClients;
- set => codeGeneration.GenerateDisposableClients = value;
- }
+ public bool GenerateDisposableClients { get; set; }
///
/// Gets or sets a value indicating whether XML doc comments should be generated.
///
[Description("Generate XML doc comments. Default is true.")]
- public bool GenerateXmlDocCodeComments
- {
- get => codeGeneration.GenerateXmlDocCodeComments;
- set => codeGeneration.GenerateXmlDocCodeComments = value;
- }
+ public bool GenerateXmlDocCodeComments { get; set; } = true;
///
/// Gets or sets a value indicating whether ApiException and IApiResponse should be documented with
@@ -141,61 +96,37 @@ Indicating whether ApiException and IApiResponse should be documen
the relevant status codes specified in the OpenAPI document.
"""
)]
- public bool GenerateStatusCodeComments
- {
- get => codeGeneration.GenerateStatusCodeComments;
- set => codeGeneration.GenerateStatusCodeComments = value;
- }
+ public bool GenerateStatusCodeComments { get; set; } = true;
///
/// Gets or sets a value indicating whether to add auto-generated header.
///
[Description("Add auto-generated header. Default is true.")]
- public bool AddAutoGeneratedHeader
- {
- get => codeGeneration.AddAutoGeneratedHeader;
- set => codeGeneration.AddAutoGeneratedHeader = value;
- }
+ public bool AddAutoGeneratedHeader { get; set; } = true;
///
/// Gets or sets a value indicating whether to add accept headers [Headers("Accept: application/json")].
///
[Description("Add accept headers [Headers(\"Accept: application/json\")]. Default is true.")]
- public bool AddAcceptHeaders
- {
- get => codeGeneration.AddAcceptHeaders;
- set => codeGeneration.AddAcceptHeaders = value;
- }
+ public bool AddAcceptHeaders { get; set; } = true;
///
/// Gets or sets a value indicating whether to add content-type headers [Headers("Content-Type: application/json")].
///
[Description("Add content-type headers [Headers(\"Content-Type: application/json\")]. Default is true.")]
- public bool AddContentTypeHeaders
- {
- get => codeGeneration.AddContentTypeHeaders;
- set => codeGeneration.AddContentTypeHeaders = value;
- }
+ public bool AddContentTypeHeaders { get; set; } = true;
///
/// Gets or sets a value indicating whether to return IApiResponse objects.
///
[Description("Return IApiResponse objects.")]
- public bool ReturnIApiResponse
- {
- get => codeGeneration.ReturnIApiResponse;
- set => codeGeneration.ReturnIApiResponse = value;
- }
+ public bool ReturnIApiResponse { get; set; }
///
/// Gets or sets a value indicating whether to return IObservable or Task
///
[Description("Return IObservable or Task.")]
- public bool ReturnIObservable
- {
- get => codeGeneration.ReturnIObservable;
- set => codeGeneration.ReturnIObservable = value;
- }
+ public bool ReturnIObservable { get; set; }
///
/// Gets or sets a dictionary of operation ids and a specific response type that they should use. The type is
@@ -203,56 +134,36 @@ public bool ReturnIObservable
///
[Description(
"""
- AddAcceptHeaders dictionary of operation ids and a specific response type that they should use.
+ A dictionary of operation ids and a specific response type that they should use.
The type is wrapped in a task, but otherwise unmodified (so make sure that the namespaces are imported or specified).
"""
)]
- public Dictionary ResponseTypeOverride
- {
- get => codeGeneration.ResponseTypeOverride;
- set => codeGeneration.ResponseTypeOverride = value;
- }
+ public Dictionary ResponseTypeOverride { get; set; } = new();
///
/// Gets or sets a value indicating whether to generate operation headers.
///
[Description("Generate operation headers. Default is true.")]
- public bool GenerateOperationHeaders
- {
- get => codeGeneration.GenerateOperationHeaders;
- set => codeGeneration.GenerateOperationHeaders = value;
- }
+ public bool GenerateOperationHeaders { get; set; } = true;
///
/// Gets or sets a collection of headers to omit from operation signatures. (default: [])
///
[Description("A collection of headers to omit from operation signatures.")]
- public string[] IgnoredOperationHeaders
- {
- get => filterConfig.IgnoredOperationHeaders;
- set => filterConfig.IgnoredOperationHeaders = value;
- }
+ public string[] IgnoredOperationHeaders { get; set; } = [];
///
/// Gets or sets the generated type accessibility. (default: Public)
///
[Description("The generated type accessibility. Default is Public.")]
[JsonConverter(typeof(JsonStringEnumConverter))]
- public TypeAccessibility TypeAccessibility
- {
- get => typeConfig.TypeAccessibility;
- set => typeConfig.TypeAccessibility = value;
- }
+ public TypeAccessibility TypeAccessibility { get; set; } = TypeAccessibility.Public;
///
/// Enable or disable the use of cancellation tokens.
///
[Description("Enable or disable the use of cancellation tokens.")]
- public bool UseCancellationTokens
- {
- get => parameterConfig.UseCancellationTokens;
- set => parameterConfig.UseCancellationTokens = value;
- }
+ public bool UseCancellationTokens { get; set; }
///
/// Set to true to explicitly format date query string parameters
@@ -264,74 +175,46 @@ Set to true to explicitly format date query string parameters
in ISO 8601 standard date format using delimiters (for example: 2023-06-15)
"""
)]
- public bool UseIsoDateFormat
- {
- get => parameterConfig.UseIsoDateFormat;
- set => parameterConfig.UseIsoDateFormat = value;
- }
+ public bool UseIsoDateFormat { get; set; }
///
/// Add additional namespace to generated types
///
[Description("Add additional namespace to generated types.")]
- public string[] AdditionalNamespaces
- {
- get => filterConfig.AdditionalNamespaces;
- set => filterConfig.AdditionalNamespaces = value;
- }
+ public string[] AdditionalNamespaces { get; set; } = [];
///
/// Exclude namespaces on generated types
///
[Description("Exclude namespaces on generated types.")]
- public string[] ExcludeNamespaces
- {
- get => filterConfig.ExcludeNamespaces;
- set => filterConfig.ExcludeNamespaces = value;
- }
+ public string[] ExcludeNamespaces { get; set; } = [];
///
/// Set to true to Generate a Refit interface for each endpoint
///
[Description("Generate a Refit interface for each endpoint.")]
[JsonConverter(typeof(JsonStringEnumConverter))]
- public MultipleInterfaces MultipleInterfaces
- {
- get => codeGeneration.MultipleInterfaces;
- set => codeGeneration.MultipleInterfaces = value;
- }
+ public MultipleInterfaces MultipleInterfaces { get; set; }
///
/// Set to true to only include Paths that match the provided regular expression.
/// May be set multiple times
///
[Description("Only include Paths that match the provided regular expression. May be set multiple times.")]
- public string[] IncludePathMatches
- {
- get => filterConfig.IncludePathMatches;
- set => filterConfig.IncludePathMatches = value;
- }
+ public string[] IncludePathMatches { get; set; } = [];
///
/// Set to true to only include Endpoints that contain this tag.
/// May be set multiple times and result in OR'ed evaluation.
///
[Description("Generate a Refit interface for each endpoint.")]
- public string[] IncludeTags
- {
- get => filterConfig.IncludeTags;
- set => filterConfig.IncludeTags = value;
- }
+ public string[] IncludeTags { get; set; } = [];
///
/// Gets or sets a value indicating whether to generate deprecated operations, otherwise false
///
[Description("Generate deprecated operations. Default is true.")]
- public bool GenerateDeprecatedOperations
- {
- get => codeGeneration.GenerateDeprecatedOperations;
- set => codeGeneration.GenerateDeprecatedOperations = value;
- }
+ public bool GenerateDeprecatedOperations { get; set; } = true;
///
/// Generate operation names using pattern.
@@ -343,41 +226,25 @@ public bool GenerateDeprecatedOperations
this is name of the Execute() method in the interface.
"""
)]
- public string? OperationNameTemplate
- {
- get => codeGeneration.OperationNameTemplate;
- set => codeGeneration.OperationNameTemplate = value;
- }
+ public string? OperationNameTemplate { get; set; }
///
/// Set to true to re-order optional parameters to the end of the parameter list
///
[Description("Re-order optional parameters to the end of the parameter list.")]
- public bool OptionalParameters
- {
- get => parameterConfig.OptionalParameters;
- set => parameterConfig.OptionalParameters = value;
- }
+ public bool OptionalParameters { get; set; }
///
/// Gets or sets the relative path to a folder in which the output files are generated. (default: ./Generated)
///
[Description("The relative path to a folder in which the output files are generated. Default is ./Generated.")]
- public string OutputFolder
- {
- get => outputConfig.OutputFolder;
- set => outputConfig.OutputFolder = value;
- }
+ public string OutputFolder { get; set; } = DefaultOutputFolder;
///
/// Gets or sets the relative path to a folder where to store the generated contracts. (default: ./Generated)
///
[Description("The relative path to a folder where to store the generated contracts. Default is ./Generated.")]
- public string? ContractsOutputFolder
- {
- get => outputConfig.ContractsOutputFolder;
- set => outputConfig.ContractsOutputFolder = value;
- }
+ public string? ContractsOutputFolder { get; set; }
///
/// Gets or sets the filename of the generated code.
@@ -392,11 +259,7 @@ The filename of the generated code.
and the default is [.refitter defined naming OR .refitter filename].g.cs)
"""
)]
- public string? OutputFilename
- {
- get => outputConfig.OutputFilename;
- set => outputConfig.OutputFilename = value;
- }
+ public string? OutputFilename { get; set; }
///
/// Gets or sets the settings describing how to register generated interface to the .NET Core DI container
@@ -420,11 +283,7 @@ Apply tree-shaking to the OpenApi schema.
This works in conjunction with includeTags and includePathMatches.
"""
)]
- public bool TrimUnusedSchema
- {
- get => schemaConfig.TrimUnusedSchema;
- set => schemaConfig.TrimUnusedSchema = value;
- }
+ public bool TrimUnusedSchema { get; set; }
///
/// Array of regular expressions that determine if a schema needs to be kept.
@@ -436,11 +295,7 @@ public bool TrimUnusedSchema
This works in conjunction with TrimUnusedSchema.
"""
)]
- public string[] KeepSchemaPatterns
- {
- get => schemaConfig.KeepSchemaPatterns;
- set => schemaConfig.KeepSchemaPatterns = value;
- }
+ public string[] KeepSchemaPatterns { get; set; } = [];
///
/// Set to true to keep all possible type-instances of inheritance/union types.
@@ -454,52 +309,32 @@ If this is false only directly referenced types will be kept.
This works in conjunction with TrimUnusedSchema.
"""
)]
- public bool IncludeInheritanceHierarchy
- {
- get => schemaConfig.IncludeInheritanceHierarchy;
- set => schemaConfig.IncludeInheritanceHierarchy = value;
- }
+ public bool IncludeInheritanceHierarchy { get; set; }
///
/// The NSwag IOperationNameGenerator implementation to use
///
[Description("The NSwag IOperationNameGenerator implementation to use.")]
[JsonConverter(typeof(JsonStringEnumConverter))]
- public OperationNameGeneratorTypes OperationNameGenerator
- {
- get => codeGeneration.OperationNameGenerator;
- set => codeGeneration.OperationNameGenerator = value;
- }
+ public OperationNameGeneratorTypes OperationNameGenerator { get; set; }
///
/// Set to false to skip default additional properties. Default is true
///
[Description("Skip default additional properties. Default is true.")]
- public bool GenerateDefaultAdditionalProperties
- {
- get => codeGeneration.GenerateDefaultAdditionalProperties;
- set => codeGeneration.GenerateDefaultAdditionalProperties = value;
- }
+ public bool GenerateDefaultAdditionalProperties { get; set; } = true;
///
/// Set to true to generate contracts as immutable records instead of classes
///
[Description("Generate contracts as immutable records instead of classes.")]
- public bool ImmutableRecords
- {
- get => typeConfig.ImmutableRecords;
- set => typeConfig.ImmutableRecords = value;
- }
+ public bool ImmutableRecords { get; set; }
///
/// Get ot set the settings describing how to configure Apizr
///
[Description("The settings describing how to configure Apizr.")]
- public ApizrSettings? ApizrSettings
- {
- get => featureConfig.ApizrSettings;
- set => featureConfig.ApizrSettings = value;
- }
+ public ApizrSettings? ApizrSettings { get; set; }
///
/// Set to true to wrap multiple query parameters into a single complex one. Default is false (no wrapping).
@@ -511,11 +346,7 @@ Wrap multiple query parameters into a single complex one.
See https://github.com/reactiveui/refit?tab=readme-ov-file#dynamic-querystring-parameters for more information.
"""
)]
- public bool UseDynamicQuerystringParameters
- {
- get => parameterConfig.UseDynamicQuerystringParameters;
- set => parameterConfig.UseDynamicQuerystringParameters = value;
- }
+ public bool UseDynamicQuerystringParameters { get; set; }
///
/// Set to true to generate multiple files. Default is false
@@ -535,11 +366,7 @@ Dependency Injection is written to a file called DependencyInjection.cs
When GenerateJsonSerializerContext is enabled, an additional serializer context file is emitted.
"""
)]
- public bool GenerateMultipleFiles
- {
- get => outputConfig.GenerateMultipleFiles;
- set => outputConfig.GenerateMultipleFiles = value;
- }
+ public bool GenerateMultipleFiles { get; set; }
///
/// Set to true to use System.Text.Json polymorphic serialization. Default is false
@@ -558,32 +385,20 @@ payloads with (yet) unknown types are offered by newer versions of an API
See https://learn.microsoft.com/en-us/dotnet/standard/serialization/system-text-json/polymorphism for more information
"""
)]
- public bool UsePolymorphicSerialization
- {
- get => featureConfig.UsePolymorphicSerialization;
- set => featureConfig.UsePolymorphicSerialization = value;
- }
+ public bool UsePolymorphicSerialization { get; set; }
///
/// Gets or sets the parameter name generator for customizing parameter names.
///
[JsonIgnore]
- public IParameterNameGenerator? ParameterNameGenerator
- {
- get => parameterConfig.ParameterNameGenerator;
- set => parameterConfig.ParameterNameGenerator = value;
- }
+ public IParameterNameGenerator? ParameterNameGenerator { get; set; }
///
/// Gets or sets a value indicating whether to generate Security Schema Authentication headers.
///
[Description("Generate Security Schema Authentication headers")]
[JsonConverter(typeof(JsonStringEnumConverter))]
- public AuthenticationHeaderStyle AuthenticationHeaderStyle
- {
- get => featureConfig.AuthenticationHeaderStyle;
- set => featureConfig.AuthenticationHeaderStyle = value;
- }
+ public AuthenticationHeaderStyle AuthenticationHeaderStyle { get; set; }
///
/// Gets or sets the collection format to use for array query parameters.
@@ -591,52 +406,32 @@ public AuthenticationHeaderStyle AuthenticationHeaderStyle
///
[Description("The collection format to use for array query parameters. Default is CollectionFormat.Multi.")]
[JsonConverter(typeof(JsonStringEnumConverter))]
- public CollectionFormat CollectionFormat
- {
- get => parameterConfig.CollectionFormat;
- set => parameterConfig.CollectionFormat = value;
- }
+ public CollectionFormat CollectionFormat { get; set; } = CollectionFormat.Multi;
///
/// Gets or sets a directory path which contains liquid templates for NSwag. If null or empty, uses default
/// templates.
///
[Description("Custom directory with NSwag fluid templates for code generation. Default is null which uses the default NSwag templates. See https://github.com/RicoSuter/NSwag/wiki/Templates")]
- public string? CustomTemplateDirectory
- {
- get => codeGeneration.CustomTemplateDirectory;
- set => codeGeneration.CustomTemplateDirectory = value;
- }
+ public string? CustomTemplateDirectory { get; set; }
///
/// Gets or sets the security scheme name for which to generate authentication headers.
/// When specified, only endpoints using this security scheme will have authentication headers generated.
///
[Description("Security scheme for which to generate authentication headers.")]
- public string? SecurityScheme
- {
- get => featureConfig.SecurityScheme;
- set => featureConfig.SecurityScheme = value;
- }
+ public string? SecurityScheme { get; set; }
///
/// Gets or sets a value indicating whether to generate JsonSerializerContext for AOT compilation support.
/// The context is emitted into the contracts namespace and only when contracts are generated.
///
[Description("Generate JsonSerializerContext for AOT compilation support in the contracts namespace when contracts are generated.")]
- public bool GenerateJsonSerializerContext
- {
- get => featureConfig.GenerateJsonSerializerContext;
- set => featureConfig.GenerateJsonSerializerContext = value;
- }
+ public bool GenerateJsonSerializerContext { get; set; }
///
/// Gets or sets a suffix to append to all generated contract type names.
///
[Description("Suffix to append to all generated contract type names. Default is null which doesn't append any suffix.")]
- public string? ContractTypeSuffix
- {
- get => typeConfig.ContractTypeSuffix;
- set => typeConfig.ContractTypeSuffix = value;
- }
+ public string? ContractTypeSuffix { get; set; }
}
diff --git a/src/Refitter.Core/Settings/SchemaConfig.cs b/src/Refitter.Core/Settings/SchemaConfig.cs
deleted file mode 100644
index 6f67aba7a..000000000
--- a/src/Refitter.Core/Settings/SchemaConfig.cs
+++ /dev/null
@@ -1,49 +0,0 @@
-using System.ComponentModel;
-using System.Diagnostics.CodeAnalysis;
-
-namespace Refitter.Core;
-
-///
-/// Configuration for OpenAPI schema tree-shaking and unused schema trimming.
-///
-[ExcludeFromCodeCoverage]
-public class SchemaConfig
-{
- ///
- /// Set to true to apply tree-shaking to the OpenApi schema.
- /// This works in conjunction with and .
- ///
- [Description(
- """
- Apply tree-shaking to the OpenApi schema.
- This works in conjunction with includeTags and includePathMatches.
- """
- )]
- public bool TrimUnusedSchema { get; set; }
-
- ///
- /// Array of regular expressions that determine if a schema needs to be kept.
- /// This works in conjunction with .
- ///
- [Description(
- """
- Array of regular expressions that determine if a schema needs to be kept.
- This works in conjunction with TrimUnusedSchema.
- """
- )]
- public string[] KeepSchemaPatterns { get; set; } = [];
-
- ///
- /// Set to true to keep all possible type-instances of inheritance/union types.
- /// If this is false only directly referenced types will be kept.
- /// This works in conjunction with .
- ///
- [Description(
- """
- Keep all possible type-instances of inheritance/union types.
- If this is false only directly referenced types will be kept.
- This works in conjunction with TrimUnusedSchema.
- """
- )]
- public bool IncludeInheritanceHierarchy { get; set; }
-}
diff --git a/src/Refitter.Core/Settings/TypeConfig.cs b/src/Refitter.Core/Settings/TypeConfig.cs
deleted file mode 100644
index 61bc15cb8..000000000
--- a/src/Refitter.Core/Settings/TypeConfig.cs
+++ /dev/null
@@ -1,38 +0,0 @@
-using System.ComponentModel;
-using System.Diagnostics.CodeAnalysis;
-using System.Text.Json.Serialization;
-
-namespace Refitter.Core;
-
-///
-/// Configuration for generated type visibility, naming conventions, and immutability.
-///
-[ExcludeFromCodeCoverage]
-public class TypeConfig
-{
- ///
- /// Gets or sets the generated type accessibility. (default: Public)
- ///
- [Description("The generated type accessibility. Default is Public.")]
- [JsonConverter(typeof(JsonStringEnumConverter))]
- public TypeAccessibility TypeAccessibility { get; set; } = TypeAccessibility.Public;
-
- ///
- /// Gets or sets how generated contract properties are named.
- ///
- [Description("Controls how generated contract properties are named. Default is PascalCase. Possible values: PascalCase, PreserveOriginal.")]
- [JsonConverter(typeof(JsonStringEnumConverter))]
- public PropertyNamingPolicy PropertyNamingPolicy { get; set; } = PropertyNamingPolicy.PascalCase;
-
- ///
- /// Gets or sets a suffix to append to all generated contract type names.
- ///
- [Description("Suffix to append to all generated contract type names. Default is null which doesn't append any suffix.")]
- public string? ContractTypeSuffix { get; set; }
-
- ///
- /// Set to true to generate contracts as immutable records instead of classes
- ///
- [Description("Generate contracts as immutable records instead of classes.")]
- public bool ImmutableRecords { get; set; }
-}