Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@ updates:
time: "02:15"
timezone: "Etc/UTC"
groups:
all-updates:
minor-and-patch-updates:
patterns:
- "*"
update-types:
- "minor"
- "patch"
ignore:
- dependency-name: "Microsoft.ApplicationInsights*"
versions: [">=3.0.0"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration" Version="10.0.11" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="10.0.11" />
<PackageReference Include="MX.Api.Abstractions" Version="2.3.77" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="10.0.12" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="10.0.12" />
<PackageReference Include="MX.Api.Abstractions" Version="2.3.80" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

<ItemGroup>
<PackageReference Include="coverlet.msbuild" Version="10.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="10.0.11" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.9.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="10.0.12" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.10.0" />
<PackageReference Include="Moq" Version="4.20.72" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.4" />
<PackageReference Include="xunit" Version="2.9.3" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@

<ItemGroup>
<PackageReference Include="coverlet.msbuild" Version="10.0.1" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="10.0.11" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.9.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="10.0.12" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.10.0" />
<PackageReference Include="xunit" Version="2.9.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="4.0.0">
<PrivateAssets>all</PrivateAssets>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="MX.Api.Abstractions" Version="2.3.77" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="10.0.11" />
<PackageReference Include="MX.Api.Abstractions" Version="2.3.80" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="10.0.12" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<ItemGroup>
<PackageReference Include="coverlet.msbuild" Version="10.0.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.9.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.10.0" />
<PackageReference Include="Moq" Version="4.20.72" />
<PackageReference Include="xunit" Version="2.9.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="4.0.0">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@

<ItemGroup>
<PackageReference Include="Azure.Identity" Version="1.21.0" />
<PackageReference Include="Microsoft.Extensions.Caching.Abstractions" Version="10.0.11" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="10.0.11" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="10.0.11" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="10.0.11" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="10.0.11" />
<PackageReference Include="Microsoft.Extensions.Options" Version="10.0.11" />
<PackageReference Include="MX.Api.Client" Version="2.3.77" />
<PackageReference Include="Microsoft.Extensions.Caching.Abstractions" Version="10.0.12" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="10.0.12" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="10.0.12" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="10.0.12" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="10.0.12" />
<PackageReference Include="Microsoft.Extensions.Options" Version="10.0.12" />
<PackageReference Include="MX.Api.Client" Version="2.3.80" />
<PackageReference Include="RestSharp" Version="114.0.0" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

<ItemGroup>
<PackageReference Include="coverlet.msbuild" Version="10.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="10.0.11" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.9.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="10.0.12" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.10.0" />
<PackageReference Include="Moq" Version="4.20.72" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.4" />
<PackageReference Include="xunit" Version="2.9.3" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Security.Claims;
using System.Text.Encodings.Web;
using System.Text.Json;

using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Hosting;
Expand Down Expand Up @@ -122,6 +123,23 @@
Assert.NotEmpty(mapsPolicies!.Policies);
}

[Fact]
public async Task HostBoot_ExposesVersionedOpenApiDocument()

Check warning on line 127 in src/XtremeIdiots.Portal.Integrations.Servers.Api.Tests.V1/RepositoryApiClientRegistrationTests.cs

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Missing XML comment for publicly visible type or member 'RepositoryApiClientRegistrationTests.HostBoot_ExposesVersionedOpenApiDocument()'

See more on https://sonarcloud.io/project/issues?id=frasermolyneux_portal-servers-integration&issues=AaCwZcOCb6xddJcuWzT9&open=AaCwZcOCb6xddJcuWzT9&pullRequest=1042
{
using var client = _factory.CreateClient();

using var response = await client.GetAsync("/openapi/v1.0.json");
response.EnsureSuccessStatusCode();

Check warning on line 132 in src/XtremeIdiots.Portal.Integrations.Servers.Api.Tests.V1/RepositoryApiClientRegistrationTests.cs

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Expression value is never used

See more on https://sonarcloud.io/project/issues?id=frasermolyneux_portal-servers-integration&issues=AaCwZcOCb6xddJcuWzT-&open=AaCwZcOCb6xddJcuWzT-&pullRequest=1042

using var document = JsonDocument.Parse(await response.Content.ReadAsStreamAsync());
var root = document.RootElement;
var paths = root.GetProperty("paths").EnumerateObject().Select(path => path.Name).ToArray();

Assert.NotEmpty(paths);
Assert.All(paths, path => Assert.False(path.StartsWith("/v1.0", StringComparison.OrdinalIgnoreCase)));
Assert.True(root.GetProperty("components").GetProperty("securitySchemes").TryGetProperty("Bearer", out _));
}

[Fact]
public void SharedRegistration_Extension_BuildsValidatedContainer()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@

<ItemGroup>
<PackageReference Include="coverlet.msbuild" Version="10.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="10.0.11" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.9.0" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="10.0.11" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="10.0.12" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.10.0" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="10.0.12" />
<PackageReference Include="Moq" Version="4.20.72" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.4" />
<PackageReference Include="xunit" Version="2.9.3" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.OpenApi;
using Microsoft.OpenApi.Models;
using Microsoft.OpenApi;

namespace XtremeIdiots.Portal.Integrations.Servers.Api.V1.OpenApi;

Expand All @@ -15,7 +15,7 @@

if (authenticationSchemes.Any(authScheme => authScheme.Name == "Bearer"))
{
var requirements = new Dictionary<string, OpenApiSecurityScheme>
var requirements = new Dictionary<string, IOpenApiSecurityScheme>
{
["Bearer"] = new OpenApiSecurityScheme
{
Expand All @@ -29,18 +29,12 @@
document.Components ??= new OpenApiComponents();
document.Components.SecuritySchemes = requirements;

foreach (var operation in document.Paths.Values.SelectMany(path => path.Operations))

Check warning on line 32 in src/XtremeIdiots.Portal.Integrations.Servers.Api.V1/OpenApi/BearerSecuritySchemeTransformer.cs

View workflow job for this annotation

GitHub Actions / quality / Code Quality

Loop should be simplified by calling Select(operation => operation.Value))

Check warning on line 32 in src/XtremeIdiots.Portal.Integrations.Servers.Api.V1/OpenApi/BearerSecuritySchemeTransformer.cs

View workflow job for this annotation

GitHub Actions / quality / Code Quality

Loop should be simplified by calling Select(operation => operation.Value))

Check warning on line 32 in src/XtremeIdiots.Portal.Integrations.Servers.Api.V1/OpenApi/BearerSecuritySchemeTransformer.cs

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Loop should be simplified by calling Select(operation => operation.Value))

See more on https://sonarcloud.io/project/issues?id=frasermolyneux_portal-servers-integration&issues=AaCwZcKub6xddJcuWzT3&open=AaCwZcKub6xddJcuWzT3&pullRequest=1042

Check warning on line 32 in src/XtremeIdiots.Portal.Integrations.Servers.Api.V1/OpenApi/BearerSecuritySchemeTransformer.cs

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Possible null reference return.

See more on https://sonarcloud.io/project/issues?id=frasermolyneux_portal-servers-integration&issues=AaCwZcKub6xddJcuWzT4&open=AaCwZcKub6xddJcuWzT4&pullRequest=1042
{
operation.Value.Security ??= [];
operation.Value.Security.Add(new OpenApiSecurityRequirement
{
[new OpenApiSecurityScheme
{
Reference = new OpenApiReference
{
Id = "Bearer",
Type = ReferenceType.SecurityScheme
}
}] = Array.Empty<string>()
[new OpenApiSecuritySchemeReference("Bearer", document)] = []
});
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Text.RegularExpressions;
using Microsoft.AspNetCore.OpenApi;
using Microsoft.OpenApi.Models;
using Microsoft.OpenApi;

namespace XtremeIdiots.Portal.Integrations.Servers.Api.V1.OpenApi;

Expand All @@ -25,7 +25,7 @@
// Ensure the path still starts with /
if (!newPath.StartsWith('/'))
{
newPath = "/" + newPath;

Check warning on line 28 in src/XtremeIdiots.Portal.Integrations.Servers.Api.V1/OpenApi/StripVersionPrefixTransformer.cs

View workflow job for this annotation

GitHub Actions / quality / Code Quality

Remove this hardcoded path-delimiter.

Check warning on line 28 in src/XtremeIdiots.Portal.Integrations.Servers.Api.V1/OpenApi/StripVersionPrefixTransformer.cs

View workflow job for this annotation

GitHub Actions / quality / Code Quality

Remove this hardcoded path-delimiter.
}

updatedPaths.Add(newPath, pathItem);
Expand Down
25 changes: 16 additions & 9 deletions src/XtremeIdiots.Portal.Integrations.Servers.Api.V1/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,24 +82,22 @@
// Configure API versioning
builder.Services.AddApiVersioning(options =>
{
options.DefaultApiVersion = new ApiVersion(1, 0);
options.AssumeDefaultVersionWhenUnspecified = true;
options.ReportApiVersions = true;
// Configure URL path versioning
options.ApiVersionReader = new UrlSegmentApiVersionReader();
})
.AddMvc()
.AddApiExplorer(options =>
{
// Format the version as "'v'major[.minor]" (e.g. v1.0)
options.GroupNameFormat = "'v'VV";
options.SubstituteApiVersionInUrl = true;
});

// Configure OpenAPI
builder.Services.AddOpenApi("v1.0", options =>
})
.AddOpenApi(options =>

Check warning on line 97 in src/XtremeIdiots.Portal.Integrations.Servers.Api.V1/Program.cs

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Set <Description> in the project or add [assembly: AssemblyDescription] to describe the OpenAPI document

See more on https://sonarcloud.io/project/issues?id=frasermolyneux_portal-servers-integration&issues=AaCwZcNdb6xddJcuWzT5&open=AaCwZcNdb6xddJcuWzT5&pullRequest=1042
{
options.AddDocumentTransformer<BearerSecuritySchemeTransformer>();
options.AddDocumentTransformer<StripVersionPrefixTransformer>();
options.Document.AddDocumentTransformer<BearerSecuritySchemeTransformer>();

Check warning on line 99 in src/XtremeIdiots.Portal.Integrations.Servers.Api.V1/Program.cs

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Expression value is never used

See more on https://sonarcloud.io/project/issues?id=frasermolyneux_portal-servers-integration&issues=AaCwZcNdb6xddJcuWzT6&open=AaCwZcNdb6xddJcuWzT6&pullRequest=1042
options.Document.AddDocumentTransformer<StripVersionPrefixTransformer>();

Check warning on line 100 in src/XtremeIdiots.Portal.Integrations.Servers.Api.V1/Program.cs

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Expression value is never used

See more on https://sonarcloud.io/project/issues?id=frasermolyneux_portal-servers-integration&issues=AaCwZcNdb6xddJcuWzT7&open=AaCwZcNdb6xddJcuWzT7&pullRequest=1042
});

builder.Services.AddSingleton<IQueryClientFactory, QueryClientFactory>();
Expand Down Expand Up @@ -141,8 +139,17 @@
}

// Configure the HTTP request pipeline.
app.MapOpenApi();
app.MapScalarApiReference();
app.MapOpenApi().WithDocumentPerVersion();
app.MapScalarApiReference(options =>
{
var descriptions = app.DescribeApiVersions();

for (var i = 0; i < descriptions.Count; i++)
{
var description = descriptions[i];
options.AddDocument(description.GroupName, description.GroupName, isDefault: i == descriptions.Count - 1);

Check warning on line 150 in src/XtremeIdiots.Portal.Integrations.Servers.Api.V1/Program.cs

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Expression value is never used

See more on https://sonarcloud.io/project/issues?id=frasermolyneux_portal-servers-integration&issues=AaCwZcNdb6xddJcuWzT8&open=AaCwZcNdb6xddJcuWzT8&pullRequest=1042
}
});

app.UseHttpsRedirection();

Expand All @@ -153,4 +160,4 @@

app.MapGet("/", () => Results.Ok()).ExcludeFromDescription();

app.Run();

Check warning on line 163 in src/XtremeIdiots.Portal.Integrations.Servers.Api.V1/Program.cs

View workflow job for this annotation

GitHub Actions / quality / Code Quality

Await RunAsync instead.

Check warning on line 163 in src/XtremeIdiots.Portal.Integrations.Servers.Api.V1/Program.cs

View workflow job for this annotation

GitHub Actions / quality / Code Quality

Await RunAsync instead.
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,28 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Asp.Versioning.OpenApi" Version="10.2.1" />
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.23.0" />
<PackageReference Include="Microsoft.ApplicationInsights.Profiler.AspNetCore" Version="3.0.2" />
<PackageReference Include="Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel" Version="2.23.0" />
<PackageReference Include="Azure.Messaging.ServiceBus" Version="7.20.2" />
<PackageReference Include="Microsoft.Azure.AppConfiguration.AspNetCore" Version="8.6.0" />
<PackageReference Include="Asp.Versioning.Mvc" Version="8.1.1" />
<PackageReference Include="Asp.Versioning.Mvc.ApiExplorer" Version="8.1.1" />
<PackageReference Include="Asp.Versioning.Mvc" Version="10.2.1" />
<PackageReference Include="Azure.Identity" Version="1.21.0" />
<PackageReference Include="MX.Api.Client" Version="2.3.77" />
<PackageReference Include="MX.Api.Web.Extensions" Version="2.3.77" />
<PackageReference Include="MX.Observability.ApplicationInsights.AspNetCore" Version="1.1.28" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="9.0.19" />
<PackageReference Include="Scalar.AspNetCore" Version="2.17.2" />
<PackageReference Include="FluentFTP" Version="54.2.0" />
<PackageReference Include="MX.Api.Client" Version="2.3.80" />
<PackageReference Include="MX.Api.Web.Extensions" Version="2.3.80" />
<PackageReference Include="MX.Observability.ApplicationInsights.AspNetCore" Version="1.1.31" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="10.0.12" />
<PackageReference Include="Scalar.AspNetCore" Version="2.17.3" />
<PackageReference Include="FluentFTP" Version="54.2.1" />
<PackageReference Include="FluentFTP.Logging" Version="1.0.0" />
<PackageReference Include="Microsoft.Identity.Web" Version="4.14.2" />
<PackageReference Include="Polly" Version="8.7.0" />
<PackageReference Include="SSH.NET" Version="2026.0.0" />
<PackageReference Include="XtremeIdiots.Portal.Repository.Abstractions.V1" Version="4.2.22" />
<PackageReference Include="XtremeIdiots.Portal.Repository.Api.Client.V1" Version="4.2.22" />
<PackageReference Include="XtremeIdiots.Portal.Server.Events.Abstractions.V1" Version="1.1.174" />
<PackageReference Include="XtremeIdiots.Portal.Settings.Contracts.V1" Version="4.2.22" />
<PackageReference Include="XtremeIdiots.Portal.Repository.Abstractions.V1" Version="4.2.34" />
<PackageReference Include="XtremeIdiots.Portal.Repository.Api.Client.V1" Version="4.2.34" />
<PackageReference Include="XtremeIdiots.Portal.Server.Events.Abstractions.V1" Version="1.1.181" />
<PackageReference Include="XtremeIdiots.Portal.Settings.Contracts.V1" Version="4.2.34" />
</ItemGroup>

<ItemGroup>
Expand Down
Loading