diff --git a/CHANGELOG.md b/CHANGELOG.md index cbbface..79b6c77 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), For more details, please refer to `PackageReleaseNotes.txt` on a per assembly basis in the `.nuget` folder. > [!NOTE] -> Changelog entries prior to version 8.4.0 was migrated from previous versions of Codebelt.Extensions.Asp.Versioning. +> Changelog entries prior to version 8.4.0 was migrated from previous versions of Cuemon.Extensions.Asp.Versioning. ## [9.0.0] - TBD @@ -20,7 +20,6 @@ This major release is first and foremost focused on ironing out any wrinkles tha - RestfulApiVersioningOptions class in the Codebelt.Extensions.Asp.Versioning namespace to include non-official MIME-types in the ValidAcceptHeaders property - ## [7.1.0] 2022-12-11 ### Added diff --git a/Directory.Build.props b/Directory.Build.props index fb3f512..74c8865 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -77,7 +77,7 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/src/Codebelt.Extensions.Asp.Versioning/Codebelt.Extensions.Asp.Versioning.csproj b/src/Codebelt.Extensions.Asp.Versioning/Codebelt.Extensions.Asp.Versioning.csproj index 1b44797..db00b1b 100644 --- a/src/Codebelt.Extensions.Asp.Versioning/Codebelt.Extensions.Asp.Versioning.csproj +++ b/src/Codebelt.Extensions.Asp.Versioning/Codebelt.Extensions.Asp.Versioning.csproj @@ -14,7 +14,7 @@ - + diff --git a/test/Codebelt.Extensions.Asp.Versioning.Tests/ApiVersionReaderTest.cs b/test/Codebelt.Extensions.Asp.Versioning.Tests/ApiVersionReaderTest.cs index 8420c60..f8c5c68 100644 --- a/test/Codebelt.Extensions.Asp.Versioning.Tests/ApiVersionReaderTest.cs +++ b/test/Codebelt.Extensions.Asp.Versioning.Tests/ApiVersionReaderTest.cs @@ -19,6 +19,7 @@ using Microsoft.Extensions.DependencyInjection; using Xunit; using Xunit.Abstractions; +using YamlDotNet.Serialization.NamingConventions; namespace Codebelt.Extensions.Asp.Versioning { @@ -207,7 +208,7 @@ public async Task GetRequest_ShouldFailWithBadRequestFormattedAsXmlResponse_As_d .AddApplicationPart(typeof(FakeController).Assembly) .AddJsonFormatters() .AddXmlFormatters() - .AddYamlFormatters(); + .AddYamlFormatters(o => o.Settings.NamingConvention = PascalCaseNamingConvention.Instance); services.AddHttpContextAccessor(); services.AddRestfulApiVersioning(); }, app => @@ -228,13 +229,14 @@ public async Task GetRequest_ShouldFailWithBadRequestFormattedAsXmlResponse_As_d Assert.Equal(HttpStatusCode.BadRequest, sut.StatusCode); Assert.Equal(HttpMethod.Get, sut.RequestMessage.Method); Assert.EndsWith(yamlAccept, sut.Content.Headers.ContentType.ToString()); - Assert.Equal(""" + Assert.True(Match(""" Error: + Instance: http://localhost/fake/throw Status: 400 Code: BadRequest Message: The HTTP resource that matches the request URI 'http://localhost/fake/throw' does not support the API version 'd3'. - - """, await sut.Content.ReadAsStringAsync(), ignoreLineEndingDifferences: true); + TraceId: * + """.ReplaceLineEndings(), await sut.Content.ReadAsStringAsync(), o => o.ThrowOnNoMatch = true)); } } diff --git a/test/Codebelt.Extensions.Asp.Versioning.Tests/Codebelt.Extensions.Asp.Versioning.Tests.csproj b/test/Codebelt.Extensions.Asp.Versioning.Tests/Codebelt.Extensions.Asp.Versioning.Tests.csproj index b3cba12..5030ae6 100644 --- a/test/Codebelt.Extensions.Asp.Versioning.Tests/Codebelt.Extensions.Asp.Versioning.Tests.csproj +++ b/test/Codebelt.Extensions.Asp.Versioning.Tests/Codebelt.Extensions.Asp.Versioning.Tests.csproj @@ -5,11 +5,11 @@ - + - - - + + + diff --git a/test/Codebelt.Extensions.Asp.Versioning.Tests/ProblemDetailsFactoryTest.cs b/test/Codebelt.Extensions.Asp.Versioning.Tests/ProblemDetailsFactoryTest.cs index d668eed..b4aa9d1 100644 --- a/test/Codebelt.Extensions.Asp.Versioning.Tests/ProblemDetailsFactoryTest.cs +++ b/test/Codebelt.Extensions.Asp.Versioning.Tests/ProblemDetailsFactoryTest.cs @@ -18,6 +18,7 @@ using Microsoft.Extensions.DependencyInjection; using Xunit; using Xunit.Abstractions; +using YamlDotNet.Serialization.NamingConventions; namespace Codebelt.Extensions.Asp.Versioning { @@ -162,7 +163,7 @@ public async Task GetRequest_ShouldFailWithBadRequestFormattedAsYamlResponse_As_ services.AddFaultDescriptorOptions(); services.AddControllers(o => o.Filters.AddFaultDescriptor()) .AddApplicationPart(typeof(FakeController).Assembly) - .AddYamlFormatters(); + .AddYamlFormatters(o => o.Settings.NamingConvention = PascalCaseNamingConvention.Instance); services.AddHttpContextAccessor() .AddRestfulApiVersioning(o => { @@ -186,37 +187,45 @@ public async Task GetRequest_ShouldFailWithBadRequestFormattedAsYamlResponse_As_ Assert.Equal(HttpStatusCode.BadRequest, sut.StatusCode); Assert.Equal(HttpMethod.Get, sut.RequestMessage.Method); Assert.EndsWith("*/*", sut.Content.Headers.ContentType.ToString()); - Assert.StartsWith(@"Error: - Status: 400 - Code: BadRequest - Message: The HTTP resource that matches the request URI 'http://localhost/fake/throw' does not support the API version 'b3'. - Failure: - Type: Cuemon.AspNetCore.Http.BadRequestException - Source: Codebelt.Extensions.Asp.Versioning - Message: The HTTP resource that matches the request URI 'http://localhost/fake/throw' does not support the API version 'b3'. - Stack: -".ReplaceLineEndings(), await sut.Content.ReadAsStringAsync()); - Assert.EndsWith(@"Evidence: - Request: - Location: http://localhost/fake/throw - Method: GET - Headers: - Accept: - - text/html - - application/xhtml+xml - - image/avif - - image/webp - - image/apng - - '*/*; q=0.8' - - application/signed-exchange; v=b3; q=0.9 - - application/json; q=10.0 - Host: - - localhost - Query: [] - Form: - Cookies: [] - Body: '' -".ReplaceLineEndings(), await sut.Content.ReadAsStringAsync()); + Assert.True(Match(""" + Error: + Instance: http://localhost/fake/throw + Status: 400 + Code: BadRequest + Message: The HTTP resource that matches the request URI 'http://localhost/fake/throw' does not support the API version 'b3'. + Failure: + Type: Cuemon.AspNetCore.Http.BadRequestException + Source: Codebelt.Extensions.Asp.Versioning + Message: The HTTP resource that matches the request URI 'http://localhost/fake/throw' does not support the API version 'b3'. + Stack: + - at Codebelt.Extensions.Asp.Versioning.ServiceCollectionExtensions.<>c.* + - at Microsoft.AspNetCore.Http.DefaultProblemDetailsWriter.WriteAsync(ProblemDetailsContext context) + - at Microsoft.AspNetCore.Http.ProblemDetailsService.TryWriteAsync(ProblemDetailsContext context) + - at Microsoft.AspNetCore.Routing.EndpointMiddleware.g__AwaitRequestTask|7_0(Endpoint endpoint, Task requestTask, ILogger logger) + - at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddlewareImpl.g__Awaited|10_0(ExceptionHandlerMiddlewareImpl middleware, HttpContext context, Task task) + StatusCode: 400 + ReasonPhrase: Bad Request + Evidence: + Request: + Location: http://localhost/fake/throw + Method: GET + Headers: + Accept: + - text/html + - application/xhtml+xml + - image/avif + - image/webp + - image/apng + - '*/*; q=0.8' + - application/signed-exchange; v=b3; q=0.9 + - application/json; q=10.0 + Host: + - localhost + Query: [] + Cookies: [] + Body: '' + TraceId: * + """.ReplaceLineEndings(), await sut.Content.ReadAsStringAsync(), o => o.ThrowOnNoMatch = true)); } } diff --git a/testenvironments.json b/testenvironments.json index 3cd700b..f6c1c47 100644 --- a/testenvironments.json +++ b/testenvironments.json @@ -9,7 +9,7 @@ { "name": "Docker-Ubuntu", "type": "docker", - "dockerImage": "gimlichael/ubuntu-testrunner:net6.0.425-net8.0.401-9.0.100-rc.1.24452.12" + "dockerImage": "gimlichael/ubuntu-testrunner:6.0.427-net8.0.403-9.0.100-rc.2.24474.11" } ] }