Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove namespace settings from codeGeneratorSettings #197

Merged
merged 2 commits into from
Oct 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ The following is an example `.refitter` file
"firstBackoffRetryInSeconds": 0.5 // Optional. Default=1.0
},
"codeGeneratorSettings": { // Optional. Default settings are the values set in this example
"namespace": "GeneratedCode",
"requiredPropertiesMustBeDefined": true,
"generateDataAnnotations": true,
"anyType": "object",
Expand Down Expand Up @@ -219,7 +218,7 @@ The following is an example `.refitter` file
- `includeTags` - A collection of tags to use a filter for including endpoints that contain this tag.
- `includePathMatches` - A collection of regular expressions used to filter paths.
- `generateDeprecatedOperations` - a boolean indicating whether deprecated operations should be generated or skipped. Default is `true`
- `operationNameTemplate` - Generate operation names using pattern. This must contain the string {operationName}. An example usage of this could be `{operationName}Async` to suffix all method names with Async
- `operationNameTemplate` - Generate operation names using pattern. This must contain the string {operationName}. An example usage of this could be `{operationName}Async` to suffix all method names with Async. When using `"multipleIinterfaces": "ByEndpoint"`, This is name of the Execute() method in the interface
- `optionalParameters` - Generate non-required parameters as nullable optional parameters
- `dependencyInjectionSettings` - Setting this will generated extension methods to `IServiceCollection` for configuring Refit clients
- `baseUrl` - Used as the HttpClient base address. Leave this blank to manually set the base URL
Expand All @@ -228,7 +227,6 @@ The following is an example `.refitter` file
- `pollyMaxRetryCount` - This is the max retry count used in the Polly retry policy. Default is 6
- `firstBackoffRetryInSeconds` - This is the duration of the initial retry backoff. Default is 1 second
- `codeGeneratorSettings` - Setting this allows customization of the NSwag generated types and contracts
- `namespace` - Default is `GeneratedCode`,
- `requiredPropertiesMustBeDefined` - Default is true,
- `generateDataAnnotations` - Default is true,
- `anyType` - Default is `object`,
Expand Down
5 changes: 1 addition & 4 deletions docs/docfx_project/articles/refitter-file-format.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ The following is an example `.refitter` file
"firstBackoffRetryInSeconds": 0.5 // Optional. Default=1.0
},
"codeGeneratorSettings": { // Optional. Default settings are the values set in this example
"namespace": "GeneratedCode",
"requiredPropertiesMustBeDefined": true,
"generateDataAnnotations": true,
"anyType": "object",
Expand Down Expand Up @@ -90,7 +89,6 @@ The following is an example `.refitter` file
Here are some basic explanations of each property:

- `openApiPath` - points to the OpenAPI Specifications file. This can be the path to a file stored on disk, relative to the `.refitter` file. This can also be a URL to a remote file that will be downloaded over HTTP/HTTPS
- `namespace` - the namespace used in the generated code. If not specified, this defaults to `GeneratedCode`
- `naming.useOpenApiTitle` - a boolean indicating whether the OpenApi title should be used. Default is `true`
- `naming.interfaceName` - the name of the generated interface. The generated code will automatically prefix this with `I` so if this set to `MyApiClient` then the generated interface is called `IMyApiClient`. Default is `ApiClient`
- `generateContracts` - a boolean indicating whether contracts should be generated. A use case for this is several API clients use the same contracts. Default is `true`
Expand All @@ -108,7 +106,7 @@ Here are some basic explanations of each property:
- `includeTags` - A collection of tags to use a filter for including endpoints that contain this tag.
- `includePathMatches` - A collection of regular expressions used to filter paths.
- `generateDeprecatedOperations` - a boolean indicating whether deprecated operations should be generated or skipped. Default is `true`
- `operationNameTemplate` - Generate operation names using pattern. This must contain the string {operationName}. An example usage of this could be `{operationName}Async` to suffix all method names with Async
- `operationNameTemplate` - Generate operation names using pattern. This must contain the string {operationName}. An example usage of this could be `{operationName}Async` to suffix all method names with Async. When using `"multipleIinterfaces": "ByEndpoint"`, This is name of the Execute() method in the interface
- `optionalParameters` - Generate non-required parameters as nullable optional parameters
- `dependencyInjectionSettings` - Setting this will generated extension methods to `IServiceCollection` for configuring Refit clients
- `baseUrl` - Used as the HttpClient base address. Leave this blank to manually set the base URL
Expand All @@ -117,7 +115,6 @@ Here are some basic explanations of each property:
- `pollyMaxRetryCount` - This is the max retry count used in the Polly retry policy. Default is 6
- `firstBackoffRetryInSeconds` - This is the duration of the initial retry backoff. Default is 1 second
- `codeGeneratorSettings` - Setting this allows customization of the NSwag generated types and contracts
- `namespace` - Default is `GeneratedCode`,
- `requiredPropertiesMustBeDefined` - Default is true,
- `generateDataAnnotations` - Default is true,
- `anyType` - Default is `object`,
Expand Down
5 changes: 0 additions & 5 deletions src/Refitter.Core/Settings/CodeGeneratorSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@
/// </summary>
public class CodeGeneratorSettings
{
/// <summary>
/// Gets or sets the .NET namespace of the generated types (default: GeneratedCode).
/// </summary>
public string Namespace { get; set; } = "GeneratedCode";

/// <summary>
/// Gets or sets a value indicating whether a required property must be defined in JSON
/// (sets Required.Always when the property is required) (default: true).
Expand Down
2 changes: 1 addition & 1 deletion src/Refitter.Core/Settings/RefitGeneratorSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public class RefitGeneratorSettings

/// <summary>
/// Generate operation names using pattern.
/// When using --multiple-interfaces ByEndpoint, this is name of the Execute() method in the interface.
/// When using <see cref="MultipleInterfaces"/> <see cref="ByEndpoint"/>, this is name of the Execute() method in the interface.
/// </summary>
[JsonPropertyName("operationNameTemplate")]
public string? OperationNameTemplate { get; set; }
Expand Down
3 changes: 1 addition & 2 deletions src/Refitter.SourceGenerator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ The following is an example `.refitter` file
- `includeTags` - A collection of tags to use a filter for including endpoints that contain this tag.
- `includePathMatches` - A collection of regular expressions used to filter paths.
- `generateDeprecatedOperations` - a boolean indicating whether deprecated operations should be generated or skipped. Default is `true`
- `operationNameTemplate` - Generate operation names using pattern. This must contain the string {operationName}. An example usage of this could be `{operationName}Async` to suffix all method names with Async
- `operationNameTemplate` - Generate operation names using pattern. This must contain the string {operationName}. An example usage of this could be `{operationName}Async` to suffix all method names with Async. When using `"multipleIinterfaces": "ByEndpoint"`, This is name of the Execute() method in the interface
- `optionalParameters` - Generate non-required parameters as nullable optional parameters
- `dependencyInjectionSettings` - Setting this will generated extension methods to `IServiceCollection` for configuring Refit clients
- `baseUrl` - Used as the HttpClient base address. Leave this blank to manually set the base URL
Expand All @@ -135,7 +135,6 @@ The following is an example `.refitter` file
- `pollyMaxRetryCount` - This is the max retry count used in the Polly retry policy. Default is 6
- `firstBackoffRetryInSeconds` - This is the duration of the initial retry backoff. Default is 1 second
- `codeGeneratorSettings` - Setting this allows customization of the NSwag generated types and contracts
- `namespace` - Default is `GeneratedCode`,
- `requiredPropertiesMustBeDefined` - Default is true,
- `generateDataAnnotations` - Default is true,
- `anyType` - Default is `object`,
Expand Down
32 changes: 31 additions & 1 deletion src/Refitter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,14 +138,44 @@ The following is an example `.refitter` file
- `includeTags` - A collection of tags to use a filter for including endpoints that contain this tag.
- `includePathMatches` - A collection of regular expressions used to filter paths.
- `generateDeprecatedOperations` - a boolean indicating whether deprecated operations should be generated or skipped. Default is `true`
- `operationNameTemplate` - Generate operation names using pattern. This must contain the string {operationName}. An example usage of this could be `{operationName}Async` to suffix all method names with Async. When using multipleIinterfaces=ByEndpoint, This is name of the Execute() method in the interface
- `operationNameTemplate` - Generate operation names using pattern. This must contain the string {operationName}. An example usage of this could be `{operationName}Async` to suffix all method names with Async. When using `"multipleIinterfaces": "ByEndpoint"`, This is name of the Execute() method in the interface
- `optionalParameters` - Generate non-required parameters as nullable optional parameters
- `dependencyInjectionSettings` - Setting this will generated extension methods to `IServiceCollection` for configuring Refit clients
- `baseUrl` - Used as the HttpClient base address. Leave this blank to manually set the base URL
- `httpMessageHandlers` - A collection of `HttpMessageHandler` that is added to the HttpClient pipeline
- `usePolly` - Set this to true to configure the HttpClient to use Polly using a retry policy with a jittered backoff
- `pollyMaxRetryCount` - This is the max retry count used in the Polly retry policy. Default is 6
- `firstBackoffRetryInSeconds` - This is the duration of the initial retry backoff. Default is 1 second
- `codeGeneratorSettings` - Setting this allows customization of the NSwag generated types and contracts
- `requiredPropertiesMustBeDefined` - Default is true,
- `generateDataAnnotations` - Default is true,
- `anyType` - Default is `object`,
- `dateType` - Default is `System.DateTimeOffset`,
- `dateTimeType` - Default is `System.DateTimeOffset`,
- `timeType` - Default is `System.TimeSpan`,
- `timeSpanType` - Default is `System.TimeSpan`,
- `arrayType` - Default is `System.Collections.Generic.ICollection`,
- `dictionaryType` - Default is `System.Collections.Generic.IDictionary`,
- `arrayInstanceType` - Default is `System.Collections.ObjectModel.Collection`,
- `dictionaryInstanceType` - Default is `System.Collections.Generic.Dictionary`,
- `arrayBaseType` - Default is `System.Collections.ObjectModel.Collection`,
- `dictionaryBaseType` - Default is `System.Collections.Generic.Dictionary`,
- `propertySetterAccessModifier` - Default is ``,
- `generateImmutableArrayProperties` - Default is false,
- `generateImmutableDictionaryProperties` - Default is false,
- `handleReferences` - Default is false,
- `jsonSerializerSettingsTransformationMethod` - Default is null,
- `generateJsonMethods` - Default is false,
- `enforceFlagEnums` - Default is false,
- `inlineNamedDictionaries` - Default is false,
- `inlineNamedTuples` - Default is true,
- `inlineNamedArrays` - Default is false,
- `generateOptionalPropertiesAsNullable` - Default is false,
- `generateNullableReferenceTypes` - Default is false,
- `generateNativeRecords` - Default is false
- `generateDefaultValues` - Default is true
- `inlineNamedAny` - Default is false
- `excludedTypeNames` - Default is empty

To generate code from an OpenAPI specifications file, run the following:

Expand Down