From 6421a67c5ca497b5d2538cc69e8cd3099fe925b7 Mon Sep 17 00:00:00 2001 From: Andrii Chebukin Date: Sat, 27 May 2023 21:49:46 +0300 Subject: [PATCH] Added missing properties to `OpenApiException` (#222) * Updated Fantomas to 6.0.3 * Added missing properties to `OpenApiException` --- .config/dotnet-tools.json | 4 ++-- .github/workflows/dotnetcore.yml | 1 - paket.lock | 4 ++-- src/SwaggerProvider.Runtime/ProvidedApiClientBase.fs | 6 ++++-- tests/SwaggerProvider.Tests/paket.references | 4 ++-- tests/Swashbuckle.WebApi.Server/paket.references | 5 +++-- 6 files changed, 13 insertions(+), 11 deletions(-) diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index 9765f74..4e87988 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -21,10 +21,10 @@ ] }, "fantomas": { - "version": "6.0.1", + "version": "6.0.3", "commands": [ "fantomas" ] } } -} \ No newline at end of file +} diff --git a/.github/workflows/dotnetcore.yml b/.github/workflows/dotnetcore.yml index b3b4670..41f2792 100644 --- a/.github/workflows/dotnetcore.yml +++ b/.github/workflows/dotnetcore.yml @@ -7,7 +7,6 @@ on: pull_request: branches: - master - - net5 jobs: build: diff --git a/paket.lock b/paket.lock index c31ac3f..599c7a0 100644 --- a/paket.lock +++ b/paket.lock @@ -40,8 +40,8 @@ GITHUB src/ProvidedTypes.fs (b7c930b0bd9e0e0476981ba0813ac17e7d61742b) src/ProvidedTypes.fsi (b7c930b0bd9e0e0476981ba0813ac17e7d61742b) remote: fsprojects/FSharp.Data - src/FSharp.Data.Runtime.Utilities/NameUtils.fs (ef2eda4cb33386335e25d03e694668b0af6f0945) - src/FSharp.Data.Runtime.Utilities/Pluralizer.fs (ef2eda4cb33386335e25d03e694668b0af6f0945) + src/FSharp.Data.Runtime.Utilities/NameUtils.fs (bbe54edc63a2d1ca3616f3b847ee34c0a88f91f2) + src/FSharp.Data.Runtime.Utilities/Pluralizer.fs (bbe54edc63a2d1ca3616f3b847ee34c0a88f91f2) GROUP Server RESTRICTION: == net6.0 NUGET diff --git a/src/SwaggerProvider.Runtime/ProvidedApiClientBase.fs b/src/SwaggerProvider.Runtime/ProvidedApiClientBase.fs index 8584948..0976a74 100644 --- a/src/SwaggerProvider.Runtime/ProvidedApiClientBase.fs +++ b/src/SwaggerProvider.Runtime/ProvidedApiClientBase.fs @@ -6,10 +6,12 @@ open System.Threading.Tasks open System.Text.Json open System.Text.Json.Serialization -type OpenApiException(code: int, description: string) = +type OpenApiException(code: int, description: string, headers: Headers.HttpResponseHeaders, content: HttpContent) = inherit Exception(description) member _.StatusCode = code member _.Description = description + member _.Headers = headers + member _.Content = content type ProvidedApiClientBase(httpClient: HttpClient, options: JsonSerializerOptions) = @@ -48,7 +50,7 @@ type ProvidedApiClientBase(httpClient: HttpClient, options: JsonSerializerOption |> Array.tryFindIndex((=) codeStr) |> Option.iter(fun idx -> let desc = errorDescriptions[idx] - raise(OpenApiException(code, desc))) + raise(OpenApiException(code, desc, response.Headers, response.Content))) // fail with HttpRequestException if we do not know error description return response.EnsureSuccessStatusCode().Content diff --git a/tests/SwaggerProvider.Tests/paket.references b/tests/SwaggerProvider.Tests/paket.references index 7ec32f7..399fcde 100755 --- a/tests/SwaggerProvider.Tests/paket.references +++ b/tests/SwaggerProvider.Tests/paket.references @@ -1,7 +1,7 @@ group Test FSharp.Core - Microsoft.NET.Test.Sdk + FSharp.SystemTextJson FsUnit.xUnit + Microsoft.NET.Test.Sdk Microsoft.OpenApi.Readers System.Text.Json - FSharp.SystemTextJson diff --git a/tests/Swashbuckle.WebApi.Server/paket.references b/tests/Swashbuckle.WebApi.Server/paket.references index 11f425e..2f7ead3 100644 --- a/tests/Swashbuckle.WebApi.Server/paket.references +++ b/tests/Swashbuckle.WebApi.Server/paket.references @@ -1,7 +1,8 @@ group Server + FSharp.Core Microsoft.AspNetCore Microsoft.AspNetCore.Mvc Microsoft.AspNetCore.HttpsPolicy - Swashbuckle.AspNetCore Microsoft.OpenApi - FSharp.Core + Swashbuckle.AspNetCore + System.Text.Json