From 717d3bf43da7d426dba8e093284c74acf90efc4f Mon Sep 17 00:00:00 2001 From: Sergey Tihon Date: Mon, 6 Jan 2025 20:14:33 +0100 Subject: [PATCH 01/11] fix: restore tests --- build.fsx | 2 +- src/Common/AssemblyInfo.fs | 8 ++++---- .../SwaggerProvider.ProviderTests.fsproj | 1 + tests/SwaggerProvider.Tests/Schema.Parser.Tests.fs | 2 +- tests/SwaggerProvider.Tests/SwaggerProvider.Tests.fsproj | 1 + 5 files changed, 8 insertions(+), 6 deletions(-) diff --git a/build.fsx b/build.fsx index c007612..1360514 100644 --- a/build.fsx +++ b/build.fsx @@ -114,7 +114,7 @@ Target.create "BuildTests" (fun _ -> dotnet "build" "SwaggerProvider.TestsAndDoc // Run the unit tests using test runner let runTests assembly = - dotnet "test" $"{assembly} -c Release --no-build" + dotnet $"{assembly}" "" Target.create "RunUnitTests" (fun _ -> runTests "tests/SwaggerProvider.Tests/bin/Release/net9.0/SwaggerProvider.Tests.dll") diff --git a/src/Common/AssemblyInfo.fs b/src/Common/AssemblyInfo.fs index ba1a45c..365ee54 100644 --- a/src/Common/AssemblyInfo.fs +++ b/src/Common/AssemblyInfo.fs @@ -5,13 +5,13 @@ open System.Reflection [] [] [] -[] -[] +[] +[] do () module internal AssemblyVersionInformation = let [] AssemblyTitle = "SwaggerProvider" let [] AssemblyProduct = "SwaggerProvider" let [] AssemblyDescription = "F# Type Provider for Swagger & Open API" - let [] AssemblyVersion = "2.1.3" - let [] AssemblyFileVersion = "2.1.3" + let [] AssemblyVersion = "2.2.0" + let [] AssemblyFileVersion = "2.2.0" diff --git a/tests/SwaggerProvider.ProviderTests/SwaggerProvider.ProviderTests.fsproj b/tests/SwaggerProvider.ProviderTests/SwaggerProvider.ProviderTests.fsproj index cebba28..dcb2e99 100644 --- a/tests/SwaggerProvider.ProviderTests/SwaggerProvider.ProviderTests.fsproj +++ b/tests/SwaggerProvider.ProviderTests/SwaggerProvider.ProviderTests.fsproj @@ -1,6 +1,7 @@ + Exe net9.0 true true diff --git a/tests/SwaggerProvider.Tests/Schema.Parser.Tests.fs b/tests/SwaggerProvider.Tests/Schema.Parser.Tests.fs index 2366edb..5867d93 100644 --- a/tests/SwaggerProvider.Tests/Schema.Parser.Tests.fs +++ b/tests/SwaggerProvider.Tests/Schema.Parser.Tests.fs @@ -76,7 +76,7 @@ let unsupportedSchemaPaths = |> List.filter(fun s -> s.IndexOf("unsupported") > 0) |> List.map(fun s -> [| box s |]) -[] +[] let ``Fail to parse`` file = let file = Path.Combine(rootFolder, file) shouldFail(fun () -> parserTestBody file |> Async.AwaitTask |> Async.RunSynchronously) diff --git a/tests/SwaggerProvider.Tests/SwaggerProvider.Tests.fsproj b/tests/SwaggerProvider.Tests/SwaggerProvider.Tests.fsproj index 2bb7d9b..3292314 100644 --- a/tests/SwaggerProvider.Tests/SwaggerProvider.Tests.fsproj +++ b/tests/SwaggerProvider.Tests/SwaggerProvider.Tests.fsproj @@ -1,6 +1,7 @@ + Exe net9.0 true From 08a5f96cdb66524be434b16c3b3939b45bef28ec Mon Sep 17 00:00:00 2001 From: Sergey Tihon Date: Mon, 6 Jan 2025 20:14:53 +0100 Subject: [PATCH 02/11] feat: add nocontent tests --- .../Swashbuckle.NoContentControllers.Tests.fs | 20 ++++++++++++ .../Controllers/NoContentControllers.fs | 32 +++++++++++++++++++ .../Swashbuckle.WebApi.Server.fsproj | 1 + 3 files changed, 53 insertions(+) create mode 100644 tests/SwaggerProvider.ProviderTests/v3/Swashbuckle.NoContentControllers.Tests.fs create mode 100644 tests/Swashbuckle.WebApi.Server/Controllers/NoContentControllers.fs diff --git a/tests/SwaggerProvider.ProviderTests/v3/Swashbuckle.NoContentControllers.Tests.fs b/tests/SwaggerProvider.ProviderTests/v3/Swashbuckle.NoContentControllers.Tests.fs new file mode 100644 index 0000000..c26a3d3 --- /dev/null +++ b/tests/SwaggerProvider.ProviderTests/v3/Swashbuckle.NoContentControllers.Tests.fs @@ -0,0 +1,20 @@ +module Swashbuckle.v3.NoContentControllersTests + +open Xunit +open Swashbuckle.v3.ReturnControllersTests + +[] +let ``Test 204 with GET``() = + task { do! api.GetNoContent() } + +[] +let ``Test 204 with POST``() = + task { do! api.PostNoContent() } + +[] +let ``Test 204 with PUT``() = + task { do! api.PutNoContent() } + +[] +let ``Test 204 with DELETE``() = + task { do! api.DeleteNoContent() } diff --git a/tests/Swashbuckle.WebApi.Server/Controllers/NoContentControllers.fs b/tests/Swashbuckle.WebApi.Server/Controllers/NoContentControllers.fs new file mode 100644 index 0000000..c4b7b6b --- /dev/null +++ b/tests/Swashbuckle.WebApi.Server/Controllers/NoContentControllers.fs @@ -0,0 +1,32 @@ +namespace Swashbuckle.WebApi.Server.Controllers + +open Microsoft.AspNetCore.Mvc + +[] +[] +type NoContentController() = + inherit ControllerBase() + + [] + [] + [] + member x.Get() = + x.NoContent() + + [] + [] + [] + member x.Post() = + x.NoContent() + + [] + [] + [] + member x.Put() = + x.NoContent() + + [] + [] + [] + member x.Delete() = + x.NoContent() diff --git a/tests/Swashbuckle.WebApi.Server/Swashbuckle.WebApi.Server.fsproj b/tests/Swashbuckle.WebApi.Server/Swashbuckle.WebApi.Server.fsproj index d87181b..60e9dd5 100644 --- a/tests/Swashbuckle.WebApi.Server/Swashbuckle.WebApi.Server.fsproj +++ b/tests/Swashbuckle.WebApi.Server/Swashbuckle.WebApi.Server.fsproj @@ -13,6 +13,7 @@ + From e2d3890c3090effed1f29ada0e442ddd2b0a9eac Mon Sep 17 00:00:00 2001 From: Sergey Tihon Date: Mon, 6 Jan 2025 20:19:22 +0100 Subject: [PATCH 03/11] fix: add tests for fsproj --- .../SwaggerProvider.ProviderTests.fsproj | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/SwaggerProvider.ProviderTests/SwaggerProvider.ProviderTests.fsproj b/tests/SwaggerProvider.ProviderTests/SwaggerProvider.ProviderTests.fsproj index dcb2e99..3ae9ff2 100644 --- a/tests/SwaggerProvider.ProviderTests/SwaggerProvider.ProviderTests.fsproj +++ b/tests/SwaggerProvider.ProviderTests/SwaggerProvider.ProviderTests.fsproj @@ -29,6 +29,7 @@ + APIs.guru.fs From 23feb2ad53b7de8612ca98a72b5a6f27f01deeac Mon Sep 17 00:00:00 2001 From: Sergey Tihon Date: Mon, 6 Jan 2025 20:23:20 +0100 Subject: [PATCH 04/11] fix: method names --- .../v3/Swashbuckle.NoContentControllers.Tests.fs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/SwaggerProvider.ProviderTests/v3/Swashbuckle.NoContentControllers.Tests.fs b/tests/SwaggerProvider.ProviderTests/v3/Swashbuckle.NoContentControllers.Tests.fs index c26a3d3..f08f5eb 100644 --- a/tests/SwaggerProvider.ProviderTests/v3/Swashbuckle.NoContentControllers.Tests.fs +++ b/tests/SwaggerProvider.ProviderTests/v3/Swashbuckle.NoContentControllers.Tests.fs @@ -5,16 +5,16 @@ open Swashbuckle.v3.ReturnControllersTests [] let ``Test 204 with GET``() = - task { do! api.GetNoContent() } + task { do! api.GetApiNoContent() } [] let ``Test 204 with POST``() = - task { do! api.PostNoContent() } + task { do! api.PostApiNoContent() } [] let ``Test 204 with PUT``() = - task { do! api.PutNoContent() } + task { do! api.PutApiNoContent() } [] let ``Test 204 with DELETE``() = - task { do! api.DeleteNoContent() } + task { do! api.DeleteApiNoContent() } From 79da6ea17d916ec89cdb0f181628c4514d336b46 Mon Sep 17 00:00:00 2001 From: Sergey Tihon Date: Mon, 6 Jan 2025 20:37:01 +0100 Subject: [PATCH 05/11] fix: map endpoints --- .../Controllers/SpecialCasesControllers.fs | 2 -- .../Controllers/ValuesController.fs | 6 +----- tests/Swashbuckle.WebApi.Server/Program.fs | 6 ------ tests/Swashbuckle.WebApi.Server/Startup.fs | 5 +++-- 4 files changed, 4 insertions(+), 15 deletions(-) diff --git a/tests/Swashbuckle.WebApi.Server/Controllers/SpecialCasesControllers.fs b/tests/Swashbuckle.WebApi.Server/Controllers/SpecialCasesControllers.fs index 113ea91..717b141 100644 --- a/tests/Swashbuckle.WebApi.Server/Controllers/SpecialCasesControllers.fs +++ b/tests/Swashbuckle.WebApi.Server/Controllers/SpecialCasesControllers.fs @@ -1,8 +1,6 @@ namespace Swashbuckle.WebApi.Server.Controllers -open System open Microsoft.AspNetCore.Mvc -open Swagger.Internal [] [] diff --git a/tests/Swashbuckle.WebApi.Server/Controllers/ValuesController.fs b/tests/Swashbuckle.WebApi.Server/Controllers/ValuesController.fs index 156e7e0..29e8af0 100644 --- a/tests/Swashbuckle.WebApi.Server/Controllers/ValuesController.fs +++ b/tests/Swashbuckle.WebApi.Server/Controllers/ValuesController.fs @@ -1,10 +1,6 @@ namespace Swashbuckle.WebApi.Server.Controllers -open System -open System.Collections.Generic -open System.Linq -open System.Threading.Tasks -open Microsoft.AspNetCore.Mvc + (* //[] diff --git a/tests/Swashbuckle.WebApi.Server/Program.fs b/tests/Swashbuckle.WebApi.Server/Program.fs index 316fb2c..fe12b27 100644 --- a/tests/Swashbuckle.WebApi.Server/Program.fs +++ b/tests/Swashbuckle.WebApi.Server/Program.fs @@ -1,14 +1,8 @@ namespace Swashbuckle.WebApi.Server open System -open System.Collections.Generic -open System.IO -open System.Linq -open System.Threading.Tasks open Microsoft.AspNetCore open Microsoft.AspNetCore.Hosting -open Microsoft.Extensions.Configuration -open Microsoft.Extensions.Logging module Program = let exitCode = 0 diff --git a/tests/Swashbuckle.WebApi.Server/Startup.fs b/tests/Swashbuckle.WebApi.Server/Startup.fs index c8f3be2..b53bebc 100644 --- a/tests/Swashbuckle.WebApi.Server/Startup.fs +++ b/tests/Swashbuckle.WebApi.Server/Startup.fs @@ -3,7 +3,6 @@ namespace Swashbuckle.WebApi.Server open Microsoft.AspNetCore.Builder open Microsoft.AspNetCore.Hosting -open Microsoft.AspNetCore.Mvc open Microsoft.Extensions.Configuration open Microsoft.Extensions.DependencyInjection open Microsoft.OpenApi.Models @@ -33,7 +32,7 @@ type Startup private () = |> ignore // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - member this.Configure(app: IApplicationBuilder, env: IWebHostEnvironment) = + member this.Configure(app: IApplicationBuilder, _: IWebHostEnvironment) = app.UseDeveloperExceptionPage() |> ignore // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. //app.UseHsts() |> ignore @@ -58,5 +57,7 @@ type Startup private () = //app.UseHttpsRedirection() |> ignore app.UseRouting() |> ignore + app.UseEndpoints(fun endpoints -> + endpoints.MapControllers() |> ignore) |> ignore member val Configuration: IConfiguration = null with get, set From a355cd3337a4bf8352e03d1b8da467f93351b694 Mon Sep 17 00:00:00 2001 From: Sergey Tihon Date: Mon, 6 Jan 2025 20:38:06 +0100 Subject: [PATCH 06/11] fix: formatting --- tests/Swashbuckle.WebApi.Server/Startup.fs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/Swashbuckle.WebApi.Server/Startup.fs b/tests/Swashbuckle.WebApi.Server/Startup.fs index b53bebc..1827251 100644 --- a/tests/Swashbuckle.WebApi.Server/Startup.fs +++ b/tests/Swashbuckle.WebApi.Server/Startup.fs @@ -57,7 +57,8 @@ type Startup private () = //app.UseHttpsRedirection() |> ignore app.UseRouting() |> ignore - app.UseEndpoints(fun endpoints -> - endpoints.MapControllers() |> ignore) |> ignore + + app.UseEndpoints(fun endpoints -> endpoints.MapControllers() |> ignore) + |> ignore member val Configuration: IConfiguration = null with get, set From 693c26fa27ab225b5da13035246f22eece1d470f Mon Sep 17 00:00:00 2001 From: Sergey Tihon Date: Mon, 6 Jan 2025 21:05:27 +0100 Subject: [PATCH 07/11] fix: some PetStore tests --- .../v2/Swagger.PetStore.Tests.fs | 14 +++++++------- .../v3/Swagger.PetStore.Tests.fs | 12 +++++------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/tests/SwaggerProvider.ProviderTests/v2/Swagger.PetStore.Tests.fs b/tests/SwaggerProvider.ProviderTests/v2/Swagger.PetStore.Tests.fs index 46b333a..a793384 100644 --- a/tests/SwaggerProvider.ProviderTests/v2/Swagger.PetStore.Tests.fs +++ b/tests/SwaggerProvider.ProviderTests/v2/Swagger.PetStore.Tests.fs @@ -1,4 +1,4 @@ -module Swagger.PetStore.Tests +module Swagger.PetStore.Tests open SwaggerProvider open Swagger @@ -45,11 +45,11 @@ let ``Instantiate provided objects``() = let ``throw custom exceptions from async``() = task { try - let! _ = store.GetPetById(-142L) + let! _ = store.GetPetById(242L) failwith "Call should fail" with :? System.AggregateException as aex -> match aex.InnerException with - | :? OpenApiException as ex -> ex.Description |> shouldEqual "Pet not found" + | :? System.Net.Http.HttpRequestException as ex -> ex.Message |> shouldContainText "Not Found" | _ -> raise aex } @@ -57,11 +57,11 @@ let ``throw custom exceptions from async``() = let ``throw custom exceptions from task``() = task { try - let! _ = storeTask.GetPetById(-142L) + let! _ = storeTask.GetPetById(342L) failwith "Call should fail" with :? System.AggregateException as aex -> match aex.InnerException with - | :? OpenApiException as ex -> ex.Description |> shouldEqual "Pet not found" + | :? System.Net.Http.HttpRequestException as ex -> ex.Message |> shouldContainText "Not Found" | _ -> raise aex } @@ -76,7 +76,7 @@ let ``call provided methods``() = () let tag = PetStore.Tag(None, "foobar") - tag.ToString() |> shouldEqual "foobar" + tag.Name |> shouldEqual "foobar" let pet = PetStore.Pet("foo", [||], Some id) pet.ToString() |> shouldContainText(id.ToString()) @@ -102,7 +102,7 @@ let ``call provided methods``() = [] let ``create types with Nullable properties``() = let tag = PetStoreNullable.Tag(Nullable<_>(), "foobar") - tag.ToString() |> shouldEqual "foobar" + tag.Name |> shouldEqual "foobar" let tag2 = PetStoreNullable.Tag(Name = "foobar") tag2.ToString() |> shouldContainText "foobar" diff --git a/tests/SwaggerProvider.ProviderTests/v3/Swagger.PetStore.Tests.fs b/tests/SwaggerProvider.ProviderTests/v3/Swagger.PetStore.Tests.fs index c71bc4c..1d3026d 100644 --- a/tests/SwaggerProvider.ProviderTests/v3/Swagger.PetStore.Tests.fs +++ b/tests/SwaggerProvider.ProviderTests/v3/Swagger.PetStore.Tests.fs @@ -1,4 +1,4 @@ -module Swagger.v3.PetStore.Tests +module Swagger.v3.PetStore.Tests open SwaggerProvider open Swagger @@ -59,10 +59,8 @@ let ``throw custom exceptions from task``() = try let! _ = storeTask.GetPetById(-142L) failwith "Call should fail" - with :? System.AggregateException as aex -> - match aex.InnerException with - | :? OpenApiException as ex -> ex.Description |> shouldEqual "Pet not found" - | _ -> raise aex + with :? OpenApiException as ex -> + ex.Description |> shouldEqual "Pet not found" } [] @@ -76,7 +74,7 @@ let ``call provided methods``() = () let tag = PetStore.Tag(None, "foobar") - tag.ToString() |> shouldEqual "foobar" + tag.Name |> shouldEqual "foobar" let pet = PetStore.Pet("foo", [||], Some id) pet.ToString() |> shouldContainText(id.ToString()) @@ -102,7 +100,7 @@ let ``call provided methods``() = [] let ``create types with Nullable properties``() = let tag = PetStoreNullable.Tag(Nullable<_>(), "foobar") - tag.ToString() |> shouldEqual "foobar" + tag.Name |> shouldEqual "foobar" let tag2 = PetStoreNullable.Tag(Name = "foobar") tag2.ToString() |> shouldContainText "foobar" From f70974060d4069a72d958fc305c184a3ddbd5c30 Mon Sep 17 00:00:00 2001 From: Sergey Tihon Date: Mon, 6 Jan 2025 21:12:32 +0100 Subject: [PATCH 08/11] fix: petstore --- .../v2/Swagger.PetStore.Tests.fs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tests/SwaggerProvider.ProviderTests/v2/Swagger.PetStore.Tests.fs b/tests/SwaggerProvider.ProviderTests/v2/Swagger.PetStore.Tests.fs index a793384..d97782f 100644 --- a/tests/SwaggerProvider.ProviderTests/v2/Swagger.PetStore.Tests.fs +++ b/tests/SwaggerProvider.ProviderTests/v2/Swagger.PetStore.Tests.fs @@ -59,10 +59,8 @@ let ``throw custom exceptions from task``() = try let! _ = storeTask.GetPetById(342L) failwith "Call should fail" - with :? System.AggregateException as aex -> - match aex.InnerException with - | :? System.Net.Http.HttpRequestException as ex -> ex.Message |> shouldContainText "Not Found" - | _ -> raise aex + with :? System.Net.Http.HttpRequestException as ex -> + ex.Message |> shouldContainText "Not Found" } [] From 96540981a37a1c1e37e92ef6df8ccafb1e55fc87 Mon Sep 17 00:00:00 2001 From: Sergey Tihon Date: Mon, 6 Jan 2025 21:21:45 +0100 Subject: [PATCH 09/11] fix: more tests --- .../v2/Swagger.GitHub.Tests.fs | 4 ++-- .../v2/Swagger.PetStore.Tests.fs | 2 +- .../v2/Swashbuckle.ResourceControllers.Tests.fs | 14 +++++++------- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/tests/SwaggerProvider.ProviderTests/v2/Swagger.GitHub.Tests.fs b/tests/SwaggerProvider.ProviderTests/v2/Swagger.GitHub.Tests.fs index 0aac943..bf5393b 100644 --- a/tests/SwaggerProvider.ProviderTests/v2/Swagger.GitHub.Tests.fs +++ b/tests/SwaggerProvider.ProviderTests/v2/Swagger.GitHub.Tests.fs @@ -18,7 +18,7 @@ let github() = let client = GitHub.Client() client.HttpClient.BaseAddress <- Uri Host - "Mozilla/5.0 (iPad; U; CPU OS 3_2_1 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Mobile/7B405" + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36" |> Headers.ProductInfoHeaderValue.Parse |> client.HttpClient.DefaultRequestHeaders.UserAgent.Add @@ -32,7 +32,7 @@ let taskGitHub() = let client = TaskGitHub.Client() client.HttpClient.BaseAddress <- Uri Host - "Mozilla/5.0 (iPad; U; CPU OS 3_2_1 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Mobile/7B405" + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36" |> Headers.ProductInfoHeaderValue.Parse |> client.HttpClient.DefaultRequestHeaders.UserAgent.Add diff --git a/tests/SwaggerProvider.ProviderTests/v2/Swagger.PetStore.Tests.fs b/tests/SwaggerProvider.ProviderTests/v2/Swagger.PetStore.Tests.fs index d97782f..4c2001e 100644 --- a/tests/SwaggerProvider.ProviderTests/v2/Swagger.PetStore.Tests.fs +++ b/tests/SwaggerProvider.ProviderTests/v2/Swagger.PetStore.Tests.fs @@ -25,7 +25,7 @@ let ``Test provided Host property``() = let store = PetStore.Client() store.HttpClient.BaseAddress.ToString() - |> shouldEqual "https://petstore.swagger.io/v2/" + |> shouldEqual "https://petstore.swagger.io/" store.HttpClient.BaseAddress <- Uri "http://petstore.swagger.io/v3/" diff --git a/tests/SwaggerProvider.ProviderTests/v2/Swashbuckle.ResourceControllers.Tests.fs b/tests/SwaggerProvider.ProviderTests/v2/Swashbuckle.ResourceControllers.Tests.fs index abf0ef0..ea62b79 100644 --- a/tests/SwaggerProvider.ProviderTests/v2/Swashbuckle.ResourceControllers.Tests.fs +++ b/tests/SwaggerProvider.ProviderTests/v2/Swashbuckle.ResourceControllers.Tests.fs @@ -1,4 +1,4 @@ -module Swashbuckle.v2.ResourceControllersTests +module Swashbuckle.v2.ResourceControllersTests open Xunit open FsUnitTyped @@ -7,18 +7,18 @@ open Swashbuckle.v2.ReturnControllersTests [] let ``ResourceStringString Add and get from resource dictionary``() = task { - do! api.PutApiResourceStringString("lang", "F#") - do! api.GetApiResourceStringString("lang") |> asyncEqual "F#" + do! api.PutApiResourceStringString("language", "Fsharp") + do! api.GetApiResourceStringString("language") |> asyncEqual "Fsharp" } [] let ``ResourceStringString Update value in the resource dictionary``() = task { - do! api.PutApiResourceStringString("name", "Sergey") - do! api.GetApiResourceStringString("name") |> asyncEqual "Sergey" + do! api.PutApiResourceStringString("name2", "Sergey") + do! api.GetApiResourceStringString("name2") |> asyncEqual "Sergey" - do! api.PostApiResourceStringString("name", "Siarhei") - do! api.GetApiResourceStringString("name") |> asyncEqual "Siarhei" + do! api.PostApiResourceStringString("name2", "Siarhei") + do! api.GetApiResourceStringString("name2") |> asyncEqual "Siarhei" } let ``ResourceStringString Delete from the dictionary``() = From d4231860f7387fe45eca78071582e430ac547d62 Mon Sep 17 00:00:00 2001 From: Sergey Tihon Date: Mon, 6 Jan 2025 21:27:09 +0100 Subject: [PATCH 10/11] fix: user agent parsing --- .../v2/Swagger.GitHub.Tests.fs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/tests/SwaggerProvider.ProviderTests/v2/Swagger.GitHub.Tests.fs b/tests/SwaggerProvider.ProviderTests/v2/Swagger.GitHub.Tests.fs index bf5393b..df0e56a 100644 --- a/tests/SwaggerProvider.ProviderTests/v2/Swagger.GitHub.Tests.fs +++ b/tests/SwaggerProvider.ProviderTests/v2/Swagger.GitHub.Tests.fs @@ -9,6 +9,11 @@ open System.Net.Http [] let Schema = __SOURCE_DIRECTORY__ + "/../Schemas/v2/github.json" +[] +let UserAgent = + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36" + + [] let Host = "https://api.github.com" @@ -18,9 +23,8 @@ let github() = let client = GitHub.Client() client.HttpClient.BaseAddress <- Uri Host - "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36" - |> Headers.ProductInfoHeaderValue.Parse - |> client.HttpClient.DefaultRequestHeaders.UserAgent.Add + client.HttpClient.DefaultRequestHeaders.TryAddWithoutValidation("User-Agent", UserAgent) + |> ignore client @@ -32,9 +36,8 @@ let taskGitHub() = let client = TaskGitHub.Client() client.HttpClient.BaseAddress <- Uri Host - "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36" - |> Headers.ProductInfoHeaderValue.Parse - |> client.HttpClient.DefaultRequestHeaders.UserAgent.Add + client.HttpClient.DefaultRequestHeaders.TryAddWithoutValidation("User-Agent", UserAgent) + |> ignore client From 42e18a599a8e53fb6a10e1ff2536b57c17cac806 Mon Sep 17 00:00:00 2001 From: Sergey Tihon Date: Mon, 6 Jan 2025 21:29:52 +0100 Subject: [PATCH 11/11] fix: one platform for testing should be enough --- .github/workflows/dotnetcore.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dotnetcore.yml b/.github/workflows/dotnetcore.yml index 53f13ff..af150dd 100644 --- a/.github/workflows/dotnetcore.yml +++ b/.github/workflows/dotnetcore.yml @@ -13,7 +13,7 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-latest, windows-latest, macOS-latest] + os: [ubuntu-latest] runs-on: ${{ matrix.os }} steps: