diff --git a/nuget.config b/nuget.config index 16164967c6..7464b9784c 100644 --- a/nuget.config +++ b/nuget.config @@ -2,6 +2,7 @@ + diff --git a/package-versions.props b/package-versions.props index b9a5c36ce0..d036b72b0e 100644 --- a/package-versions.props +++ b/package-versions.props @@ -20,7 +20,7 @@ 2.0.* 1.* 8.0.* - 13.20.* + 14.0.8-preview-20240707-1915 13.0.* 8.0.* 6.*-* diff --git a/src/Examples/OpenApiNSwagClientExample/ExampleApiClient.cs b/src/Examples/OpenApiNSwagClientExample/ExampleApiClient.cs index c60fb8f50f..245719d08d 100644 --- a/src/Examples/OpenApiNSwagClientExample/ExampleApiClient.cs +++ b/src/Examples/OpenApiNSwagClientExample/ExampleApiClient.cs @@ -7,12 +7,14 @@ namespace OpenApiNSwagClientExample; [UsedImplicitly(ImplicitUseTargetFlags.Itself)] public partial class ExampleApiClient : JsonApiClient { - partial void UpdateJsonSerializerSettings(JsonSerializerSettings settings) + partial void Initialize() { - SetSerializerSettingsForJsonApi(settings); + _instanceSettings = new JsonSerializerSettings(); #if DEBUG - settings.Formatting = Formatting.Indented; + _instanceSettings.Formatting = Formatting.Indented; #endif + + SetSerializerSettingsForJsonApi(_instanceSettings); } } diff --git a/src/Examples/OpenApiNSwagClientExample/OpenApiNSwagClientExample.csproj b/src/Examples/OpenApiNSwagClientExample/OpenApiNSwagClientExample.csproj index 942fc78c36..66bb51349f 100644 --- a/src/Examples/OpenApiNSwagClientExample/OpenApiNSwagClientExample.csproj +++ b/src/Examples/OpenApiNSwagClientExample/OpenApiNSwagClientExample.csproj @@ -24,7 +24,14 @@ ExampleApiClient ExampleApiClient.cs NSwagCSharp - /GenerateExceptionClasses:false /WrapResponses:true /GenerateResponseClasses:false /ResponseClass:ApiResponse /GenerateNullableReferenceTypes:true /GenerateOptionalPropertiesAsNullable:true /GenerateOptionalParameters:true /AdditionalNamespaceUsages:JsonApiDotNetCore.OpenApi.Client.NSwag + false + true + false + ApiResponse + true + true + true + JsonApiDotNetCore.OpenApi.Client.NSwag diff --git a/src/JsonApiDotNetCore.OpenApi/SwaggerComponents/DocumentationOpenApiOperationFilter.cs b/src/JsonApiDotNetCore.OpenApi/SwaggerComponents/DocumentationOpenApiOperationFilter.cs index 04d7048dd9..0a7f203328 100644 --- a/src/JsonApiDotNetCore.OpenApi/SwaggerComponents/DocumentationOpenApiOperationFilter.cs +++ b/src/JsonApiDotNetCore.OpenApi/SwaggerComponents/DocumentationOpenApiOperationFilter.cs @@ -540,7 +540,7 @@ private static void AddQueryStringParameters(OpenApiOperation operation, bool is // The next best thing is to expose the query string parameters as unstructured and optional. // - This makes SwaggerUI ask for JSON, which is a bit odd, but it works. For example: {"sort":"-id"} produces: ?sort=-id // - This makes NSwag produce a C# client with method signature: GetAsync(IDictionary? query) - // when combined with /GenerateNullableReferenceTypes:true in the project file. + // when combined with true in the project file. operation.Parameters.Add(new OpenApiParameter { diff --git a/test/OpenApiNSwagClientTests/LegacyOpenApi/GeneratedCode/LegacyClient.cs b/test/OpenApiNSwagClientTests/LegacyOpenApi/GeneratedCode/LegacyClient.cs index 660417de48..5a3741a885 100644 --- a/test/OpenApiNSwagClientTests/LegacyOpenApi/GeneratedCode/LegacyClient.cs +++ b/test/OpenApiNSwagClientTests/LegacyOpenApi/GeneratedCode/LegacyClient.cs @@ -5,10 +5,13 @@ namespace OpenApiNSwagClientTests.LegacyOpenApi.GeneratedCode; internal partial class LegacyClient : JsonApiClient { - partial void UpdateJsonSerializerSettings(JsonSerializerSettings settings) + partial void Initialize() { - SetSerializerSettingsForJsonApi(settings); + _instanceSettings = new JsonSerializerSettings + { + Formatting = Formatting.Indented + }; - settings.Formatting = Formatting.Indented; + SetSerializerSettingsForJsonApi(_instanceSettings); } } diff --git a/test/OpenApiNSwagClientTests/OpenApiNSwagClientTests.csproj b/test/OpenApiNSwagClientTests/OpenApiNSwagClientTests.csproj index 4dc9030f70..62d173ed4b 100644 --- a/test/OpenApiNSwagClientTests/OpenApiNSwagClientTests.csproj +++ b/test/OpenApiNSwagClientTests/OpenApiNSwagClientTests.csproj @@ -28,56 +28,77 @@ LegacyClient LegacyClient.cs NSwagCSharp - /GenerateClientInterfaces:true /ClientClassAccessModifier:internal /GenerateExceptionClasses:false /AdditionalNamespaceUsages:JsonApiDotNetCore.OpenApi.Client.NSwag + true + internal + false + JsonApiDotNetCore.OpenApi.Client.NSwag OpenApiNSwagClientTests.NamingConventions.KebabCase.GeneratedCode KebabCaseClient KebabCaseClient.cs NSwagCSharp - /ClientClassAccessModifier:internal /GenerateExceptionClasses:false /AdditionalNamespaceUsages:JsonApiDotNetCore.OpenApi.Client.NSwag + internal + false + JsonApiDotNetCore.OpenApi.Client.NSwag OpenApiNSwagClientTests.NamingConventions.CamelCase.GeneratedCode CamelCaseClient CamelCaseClient.cs NSwagCSharp - /ClientClassAccessModifier:internal /GenerateExceptionClasses:false /AdditionalNamespaceUsages:JsonApiDotNetCore.OpenApi.Client.NSwag + internal + false + JsonApiDotNetCore.OpenApi.Client.NSwag OpenApiNSwagClientTests.NamingConventions.PascalCase.GeneratedCode PascalCaseClient PascalCaseClient.cs NSwagCSharp - /ClientClassAccessModifier:internal /GenerateExceptionClasses:false /AdditionalNamespaceUsages:JsonApiDotNetCore.OpenApi.Client.NSwag + internal + false + JsonApiDotNetCore.OpenApi.Client.NSwag + OpenApiNSwagClientTests.ResourceFieldValidation.NullableReferenceTypesOff.ModelStateValidationOff.GeneratedCode NrtOffMsvOffClient NrtOffMsvOffClient.cs NSwagCSharp - OpenApiNSwagClientTests.ResourceFieldValidation.NullableReferenceTypesOff.ModelStateValidationOff.GeneratedCode - /ClientClassAccessModifier:internal /GenerateExceptionClasses:false /AdditionalNamespaceUsages:JsonApiDotNetCore.OpenApi.Client.NSwag /GenerateNullableReferenceTypes:false + internal + false + JsonApiDotNetCore.OpenApi.Client.NSwag + false + OpenApiNSwagClientTests.ResourceFieldValidation.NullableReferenceTypesOff.ModelStateValidationOn.GeneratedCode NrtOffMsvOnClient NrtOffMsvOnClient.cs NSwagCSharp - OpenApiNSwagClientTests.ResourceFieldValidation.NullableReferenceTypesOff.ModelStateValidationOn.GeneratedCode - /ClientClassAccessModifier:internal /GenerateExceptionClasses:false /AdditionalNamespaceUsages:JsonApiDotNetCore.OpenApi.Client.NSwag /GenerateNullableReferenceTypes:false + internal + false + JsonApiDotNetCore.OpenApi.Client.NSwag + false + OpenApiNSwagClientTests.ResourceFieldValidation.NullableReferenceTypesOn.ModelStateValidationOff.GeneratedCode NrtOnMsvOffClient NrtOnMsvOffClient.cs NSwagCSharp - OpenApiNSwagClientTests.ResourceFieldValidation.NullableReferenceTypesOn.ModelStateValidationOff.GeneratedCode - /ClientClassAccessModifier:internal /GenerateExceptionClasses:false /AdditionalNamespaceUsages:JsonApiDotNetCore.OpenApi.Client.NSwag /GenerateNullableReferenceTypes:true + internal + false + JsonApiDotNetCore.OpenApi.Client.NSwag + true + OpenApiNSwagClientTests.ResourceFieldValidation.NullableReferenceTypesOn.ModelStateValidationOn.GeneratedCode NrtOnMsvOnClient NrtOnMsvOnClient.cs NSwagCSharp - OpenApiNSwagClientTests.ResourceFieldValidation.NullableReferenceTypesOn.ModelStateValidationOn.GeneratedCode - /ClientClassAccessModifier:internal /GenerateExceptionClasses:false /AdditionalNamespaceUsages:JsonApiDotNetCore.OpenApi.Client.NSwag /GenerateNullableReferenceTypes:true + internal + false + JsonApiDotNetCore.OpenApi.Client.NSwag + true diff --git a/test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOff/GeneratedCode/NrtOffMsvOffClient.cs b/test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOff/GeneratedCode/NrtOffMsvOffClient.cs index 4a0eed4e39..ddaf89880e 100644 --- a/test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOff/GeneratedCode/NrtOffMsvOffClient.cs +++ b/test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOff/GeneratedCode/NrtOffMsvOffClient.cs @@ -5,10 +5,13 @@ namespace OpenApiNSwagClientTests.ResourceFieldValidation.NullableReferenceTypes internal partial class NrtOffMsvOffClient : JsonApiClient { - partial void UpdateJsonSerializerSettings(JsonSerializerSettings settings) + partial void Initialize() { - SetSerializerSettingsForJsonApi(settings); + _instanceSettings = new JsonSerializerSettings + { + Formatting = Formatting.Indented + }; - settings.Formatting = Formatting.Indented; + SetSerializerSettingsForJsonApi(_instanceSettings); } } diff --git a/test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOn/GeneratedCode/NrtOffMsvOnClient.cs b/test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOn/GeneratedCode/NrtOffMsvOnClient.cs index 1da4da6712..b068bc4362 100644 --- a/test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOn/GeneratedCode/NrtOffMsvOnClient.cs +++ b/test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOn/GeneratedCode/NrtOffMsvOnClient.cs @@ -5,10 +5,13 @@ namespace OpenApiNSwagClientTests.ResourceFieldValidation.NullableReferenceTypes internal partial class NrtOffMsvOnClient : JsonApiClient { - partial void UpdateJsonSerializerSettings(JsonSerializerSettings settings) + partial void Initialize() { - SetSerializerSettingsForJsonApi(settings); + _instanceSettings = new JsonSerializerSettings + { + Formatting = Formatting.Indented + }; - settings.Formatting = Formatting.Indented; + SetSerializerSettingsForJsonApi(_instanceSettings); } } diff --git a/test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOff/GeneratedCode/NrtOnMsvOffClient.cs b/test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOff/GeneratedCode/NrtOnMsvOffClient.cs index f86a5229fc..d0a9e413dd 100644 --- a/test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOff/GeneratedCode/NrtOnMsvOffClient.cs +++ b/test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOff/GeneratedCode/NrtOnMsvOffClient.cs @@ -5,10 +5,13 @@ namespace OpenApiNSwagClientTests.ResourceFieldValidation.NullableReferenceTypes internal partial class NrtOnMsvOffClient : JsonApiClient { - partial void UpdateJsonSerializerSettings(JsonSerializerSettings settings) + partial void Initialize() { - SetSerializerSettingsForJsonApi(settings); + _instanceSettings = new JsonSerializerSettings + { + Formatting = Formatting.Indented + }; - settings.Formatting = Formatting.Indented; + SetSerializerSettingsForJsonApi(_instanceSettings); } } diff --git a/test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOn/GeneratedCode/NrtOnMsvOnClient.cs b/test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOn/GeneratedCode/NrtOnMsvOnClient.cs index 0a506d41ec..e9495107db 100644 --- a/test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOn/GeneratedCode/NrtOnMsvOnClient.cs +++ b/test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOn/GeneratedCode/NrtOnMsvOnClient.cs @@ -5,10 +5,13 @@ namespace OpenApiNSwagClientTests.ResourceFieldValidation.NullableReferenceTypes internal partial class NrtOnMsvOnClient : JsonApiClient { - partial void UpdateJsonSerializerSettings(JsonSerializerSettings settings) + partial void Initialize() { - SetSerializerSettingsForJsonApi(settings); + _instanceSettings = new JsonSerializerSettings + { + Formatting = Formatting.Indented + }; - settings.Formatting = Formatting.Indented; + SetSerializerSettingsForJsonApi(_instanceSettings); } } diff --git a/test/OpenApiNSwagEndToEndTests/OpenApiNSwagEndToEndTests.csproj b/test/OpenApiNSwagEndToEndTests/OpenApiNSwagEndToEndTests.csproj index 55f5a14995..c6e0d45495 100644 --- a/test/OpenApiNSwagEndToEndTests/OpenApiNSwagEndToEndTests.csproj +++ b/test/OpenApiNSwagEndToEndTests/OpenApiNSwagEndToEndTests.csproj @@ -28,49 +28,75 @@ ClientIdGenerationModesClient ClientIdGenerationModesClient.cs NSwagCSharp - /ClientClassAccessModifier:internal /GenerateExceptionClasses:false /AdditionalNamespaceUsages:JsonApiDotNetCore.OpenApi.Client.NSwag /GenerateNullableReferenceTypes:true + internal + false + JsonApiDotNetCore.OpenApi.Client.NSwag + true OpenApiNSwagEndToEndTests.ModelStateValidation.GeneratedCode ModelStateValidationClient ModelStateValidationClient.cs NSwagCSharp - /ClientClassAccessModifier:internal /GenerateExceptionClasses:false /AdditionalNamespaceUsages:JsonApiDotNetCore.OpenApi.Client.NSwag /GenerateNullableReferenceTypes:true /GenerateOptionalParameters:true + internal + false + JsonApiDotNetCore.OpenApi.Client.NSwag + true + true + true OpenApiNSwagEndToEndTests.Headers.GeneratedCode HeadersClient HeadersClient.cs NSwagCSharp - /ClientClassAccessModifier:internal /GenerateExceptionClasses:false /WrapResponses:true /GenerateResponseClasses:false /ResponseClass:ApiResponse /AdditionalNamespaceUsages:JsonApiDotNetCore.OpenApi.Client.NSwag /GenerateNullableReferenceTypes:true + internal + false + true + ApiResponse + false + JsonApiDotNetCore.OpenApi.Client.NSwag + true OpenApiNSwagEndToEndTests.QueryStrings.GeneratedCode QueryStringsClient QueryStringsClient.cs NSwagCSharp - /ClientClassAccessModifier:internal /GenerateExceptionClasses:false /AdditionalNamespaceUsages:JsonApiDotNetCore.OpenApi.Client.NSwag /GenerateNullableReferenceTypes:true + internal + false + JsonApiDotNetCore.OpenApi.Client.NSwag + true OpenApiNSwagEndToEndTests.RestrictedControllers.GeneratedCode RestrictedControllersClient RestrictedControllersClient.cs NSwagCSharp - /ClientClassAccessModifier:internal /GenerateExceptionClasses:false /AdditionalNamespaceUsages:JsonApiDotNetCore.OpenApi.Client.NSwag /GenerateNullableReferenceTypes:true + internal + false + JsonApiDotNetCore.OpenApi.Client.NSwag + true OpenApiNSwagEndToEndTests.Links.GeneratedCode LinksClient LinksClient.cs NSwagCSharp - /ClientClassAccessModifier:internal /GenerateExceptionClasses:false /AdditionalNamespaceUsages:JsonApiDotNetCore.OpenApi.Client.NSwag /GenerateNullableReferenceTypes:true + internal + false + JsonApiDotNetCore.OpenApi.Client.NSwag + true OpenApiNSwagEndToEndTests.AtomicOperations.GeneratedCode AtomicOperationsClient AtomicOperationsClient.cs NSwagCSharp - /ClientClassAccessModifier:internal /GenerateExceptionClasses:false /AdditionalNamespaceUsages:JsonApiDotNetCore.OpenApi.Client.NSwag /GenerateNullableReferenceTypes:true + internal + false + JsonApiDotNetCore.OpenApi.Client.NSwag + true