From be839503ea1147f4f3ac6620713566166e76185d Mon Sep 17 00:00:00 2001 From: Christian Helle Date: Wed, 11 Sep 2024 10:02:24 +0200 Subject: [PATCH 1/5] Update CLI option description for --use-polymorphic-serialization --- src/Refitter/Settings.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Refitter/Settings.cs b/src/Refitter/Settings.cs index 20f646e6..dbe6f1db 100644 --- a/src/Refitter/Settings.cs +++ b/src/Refitter/Settings.cs @@ -211,7 +211,7 @@ The NSwag IOperationNameGenerator implementation to use. [DefaultValue(false)] public bool UseDynamicQuerystringParameters { get; set; } - [Description("Set to true to use System.Text.Json polymorphic serialization.")] + [Description("Use System.Text.Json polymorphic serialization.")] [CommandOption("--use-polymorphic-serialization")] [DefaultValue(false)] public bool UsePolymorphicSerialization { get; set; } From e36c9aba1de95ac3ed508d84bf38625e22fd67f1 Mon Sep 17 00:00:00 2001 From: Christian Helle Date: Wed, 11 Sep 2024 10:02:38 +0200 Subject: [PATCH 2/5] Update CLI option description for --use-dynamic-querystring-parameters --- src/Refitter/Settings.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Refitter/Settings.cs b/src/Refitter/Settings.cs index dbe6f1db..5d9243ee 100644 --- a/src/Refitter/Settings.cs +++ b/src/Refitter/Settings.cs @@ -204,7 +204,7 @@ The NSwag IOperationNameGenerator implementation to use. public bool UseApizr { get; set; } [Description(""" - Set to true to wrap multiple query parameters into a single complex one. Default is false (no wrapping). + Enable wrapping multiple query parameters into a single complex one. Default is no wrapping. See https://github.com/reactiveui/refit?tab=readme-ov-file#dynamic-querystring-parameters for more information. """)] [CommandOption("--use-dynamic-querystring-parameters")] From 3040ad41cdc47343611474787d1ab758740548c2 Mon Sep 17 00:00:00 2001 From: Christian Helle Date: Wed, 11 Sep 2024 10:02:52 +0200 Subject: [PATCH 3/5] Update CLI option description for --use-apizr --- src/Refitter/Settings.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Refitter/Settings.cs b/src/Refitter/Settings.cs index 5d9243ee..44969efa 100644 --- a/src/Refitter/Settings.cs +++ b/src/Refitter/Settings.cs @@ -193,7 +193,7 @@ The NSwag IOperationNameGenerator implementation to use. public bool ImmutableRecords { get; set; } [Description(""" - Set to true to use Apizr by: + Use Apizr by: - Adding a final IApizrRequestOptions options parameter to all generated methods - Providing cancellation tokens by Apizr request options instead of a dedicated parameter - Using method overloads instead of optional parameters From 7ad41b3a86dcf64afaca500f1597a270fad234dc Mon Sep 17 00:00:00 2001 From: Christian Helle Date: Wed, 11 Sep 2024 15:45:03 +0200 Subject: [PATCH 4/5] Update CLI option descriptions in README for --use-apizr, --use-dynamic-querystring-parameters, and --use-polymorphic-serialization --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f022e5a8..ff70966d 100644 --- a/README.md +++ b/README.md @@ -111,13 +111,14 @@ OPTIONS: - SingleClientFromPathSegments See https://refitter.github.io/api/Refitter.Core.OperationNameGeneratorTypes.html for more information --immutable-records Generate contracts as immutable records instead of classes - --use-apizr Set to true to use Apizr by: + --use-apizr Use Apizr by: - Adding a final IApizrRequestOptions options parameter to all generated methods - Providing cancellation tokens by Apizr request options instead of a dedicated parameter - Using method overloads instead of optional parameters See https://refitter.github.io for more information and https://www.apizr.net to get started with Apizr - --use-dynamic-querystring-parameters Set to true to wrap multiple query parameters into a single complex one. Default is false (no wrapping). + --use-dynamic-querystring-parameters Enable wrapping multiple query parameters into a single complex one. Default is no wrapping. See https://github.com/reactiveui/refit?tab=readme-ov-file#dynamic-querystring-parameters for more information + --use-polymorphic-serialization Use System.Text.Json polymorphic serialization ``` To generate code from an OpenAPI specifications file, run the following: From b165b75175ed1794f1e8ede39fc1eab2efd9eec7 Mon Sep 17 00:00:00 2001 From: Christian Helle Date: Thu, 12 Sep 2024 22:06:01 +0200 Subject: [PATCH 5/5] Update file format docs for usePolymorphicSerialization --- README.md | 1 + docs/docfx_project/articles/refitter-file-format.md | 6 ++++++ src/Refitter/README.md | 3 +++ 3 files changed, 10 insertions(+) diff --git a/README.md b/README.md index ff70966d..0a9b675f 100644 --- a/README.md +++ b/README.md @@ -209,6 +209,7 @@ The following is an example `.refitter` file "operationNameGenerator": "Default", // Optional. May be one of Default, MultipleClientsFromOperationId, MultipleClientsFromPathSegments, MultipleClientsFromFirstTagAndOperationId, MultipleClientsFromFirstTagAndOperationName, MultipleClientsFromFirstTagAndPathSegments, SingleClientFromOperationId, SingleClientFromPathSegments "immutableRecords": false, "useDynamicQuerystringParameters": true, // Optional. Default=false + "usePolymorphicSerialization", false, // Optional. Default=false "dependencyInjectionSettings": { // Optional "baseUrl": "https://petstore3.swagger.io/api/v3", // Optional. Leave this blank to set the base address manually "httpMessageHandlers": [ // Optional diff --git a/docs/docfx_project/articles/refitter-file-format.md b/docs/docfx_project/articles/refitter-file-format.md index 8c97b86c..954d1e52 100644 --- a/docs/docfx_project/articles/refitter-file-format.md +++ b/docs/docfx_project/articles/refitter-file-format.md @@ -61,6 +61,7 @@ The following is an example `.refitter` file "operationNameGenerator": "Default", // Optional. May be one of Default, MultipleClientsFromOperationId, MultipleClientsFromPathSegments, MultipleClientsFromFirstTagAndOperationId, MultipleClientsFromFirstTagAndOperationName, MultipleClientsFromFirstTagAndPathSegments, SingleClientFromOperationId, SingleClientFromPathSegments "immutableRecords": false, "useDynamicQuerystringParameters": false, // Optional. Default=false + "usePolymorphicSerialization", false, // Optional. Default=false "dependencyInjectionSettings": { // Optional "baseUrl": "https://petstore3.swagger.io/api/v3", // Optional. Leave this blank to set the base address manually "httpMessageHandlers": [ // Optional @@ -153,6 +154,7 @@ The following is an example `.refitter` file - `operationNameGenerator`: The NSwag `IOperationNameGenerator` implementation to use. See https://refitter.github.io/api/Refitter.Core.OperationNameGeneratorTypes.html - `immutableRecords`: Set to `true` to generate contracts as immutable records instead of classes. Default is `false` - `useDynamicQuerystringParameters`: 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. +- `usePolymorphicSerialization`: Set to `true` to use `System.Text.Json` polymorphic serialization. - `generateMultipleFiles`: Set to `true` to generate multiple files. 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`, and Dependency Injection is written to a file called `DependencyInjection.cs` - `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 @@ -367,6 +369,10 @@ The following is an example `.refitter` file "type": "boolean", "description": "Set to true to wrap multiple query parameters into a single complex one." }, + "usePolymorphicSerialization": { + "type": "boolean", + "description": "Set to true to use System.Text.Json polymorphic serialization" + }, "generateMultipleFiles": { "type": "boolean", "description": "Set to `true` to generate multiple files. 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`, and Dependency Injection is written to a file called `DependencyInjection.cs`" diff --git a/src/Refitter/README.md b/src/Refitter/README.md index 7280771e..98deea2c 100644 --- a/src/Refitter/README.md +++ b/src/Refitter/README.md @@ -96,6 +96,7 @@ OPTIONS: See https://refitter.github.io for more information and https://www.apizr.net to get started with Apizr --use-dynamic-querystring-parameters 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. + --use-polymorphic-serialization Use System.Text.Json polymorphic serialization ``` ### .Refitter File format @@ -156,6 +157,7 @@ The following is an example `.refitter` file "operationNameGenerator": "Default", // Optional. May be one of Default, MultipleClientsFromOperationId, MultipleClientsFromPathSegments, MultipleClientsFromFirstTagAndOperationId, MultipleClientsFromFirstTagAndOperationName, MultipleClientsFromFirstTagAndPathSegments, SingleClientFromOperationId, SingleClientFromPathSegments "immutableRecords": false, "useDynamicQuerystringParameters": true, // Optional. Default=false + "usePolymorphicSerialization" true, // Optional. Default=false "dependencyInjectionSettings": { // Optional "baseUrl": "https://petstore3.swagger.io/api/v3", // Optional. Leave this blank to set the base address manually "httpMessageHandlers": [ // Optional @@ -243,6 +245,7 @@ The following is an example `.refitter` file - `operationNameGenerator`: The NSwag `IOperationNameGenerator` implementation to use. See https://refitter.github.io/api/Refitter.Core.OperationNameGeneratorTypes.html - `immutableRecords`: Set to `true` to generate contracts as immutable records instead of classes. Default is `false` - `useDynamicQuerystringParameters`: 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. +- `usePolymorphicSerialization`: Set to `true` to use `System.Text.Json` polymorphic serialization. - `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