Skip to content

Public API generator #642

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
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
1 change: 1 addition & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
<PackageVersion Include="Serilog.Sinks.File" Version="7.0.0" />
<PackageVersion Include="Serilog" Version="4.3.0" />
<PackageVersion Include="System.Linq.AsyncEnumerable" Version="$(System10Version)" />
<PackageVersion Include="PublicApiGenerator" Version="11.4.6" />
<PackageVersion Include="xunit.v3" Version="2.0.3" />
<PackageVersion Include="xunit.runner.visualstudio" Version="3.1.1" />
<PackageVersion Include="System.Net.Http" Version="4.3.4" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="PublicApiGenerator" />
</ItemGroup>

<ItemGroup>
Expand All @@ -60,4 +61,10 @@
<ProjectReference Include="..\ModelContextProtocol.TestOAuthServer\ModelContextProtocol.TestOAuthServer.csproj" />
</ItemGroup>

<ItemGroup>
<None Include="PublicApiTests.*.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
namespace ModelContextProtocol.AspNetCore.Authentication
{
public static class McpAuthenticationDefaults
{
public const string AuthenticationScheme = "McpAuth";
public const string DisplayName = "MCP Authentication";
}
public class McpAuthenticationEvents
{
public McpAuthenticationEvents() { }
public System.Func<ModelContextProtocol.AspNetCore.Authentication.ResourceMetadataRequestContext, System.Threading.Tasks.Task> OnResourceMetadataRequest { get; set; }
}
public class McpAuthenticationHandler : Microsoft.AspNetCore.Authentication.AuthenticationHandler<ModelContextProtocol.AspNetCore.Authentication.McpAuthenticationOptions>, Microsoft.AspNetCore.Authentication.IAuthenticationHandler, Microsoft.AspNetCore.Authentication.IAuthenticationRequestHandler
{
public McpAuthenticationHandler(Microsoft.Extensions.Options.IOptionsMonitor<ModelContextProtocol.AspNetCore.Authentication.McpAuthenticationOptions> options, Microsoft.Extensions.Logging.ILoggerFactory logger, System.Text.Encodings.Web.UrlEncoder encoder) { }
protected override System.Threading.Tasks.Task<Microsoft.AspNetCore.Authentication.AuthenticateResult> HandleAuthenticateAsync() { }
protected override System.Threading.Tasks.Task HandleChallengeAsync(Microsoft.AspNetCore.Authentication.AuthenticationProperties properties) { }
public System.Threading.Tasks.Task<bool> HandleRequestAsync() { }
}
public class McpAuthenticationOptions : Microsoft.AspNetCore.Authentication.AuthenticationSchemeOptions
{
public McpAuthenticationOptions() { }
public new ModelContextProtocol.AspNetCore.Authentication.McpAuthenticationEvents Events { get; set; }
public ModelContextProtocol.Authentication.ProtectedResourceMetadata? ResourceMetadata { get; set; }
public System.Uri ResourceMetadataUri { get; set; }
}
public class ResourceMetadataRequestContext : Microsoft.AspNetCore.Authentication.HandleRequestContext<ModelContextProtocol.AspNetCore.Authentication.McpAuthenticationOptions>
{
public ResourceMetadataRequestContext(Microsoft.AspNetCore.Http.HttpContext context, Microsoft.AspNetCore.Authentication.AuthenticationScheme scheme, ModelContextProtocol.AspNetCore.Authentication.McpAuthenticationOptions options) { }
public ModelContextProtocol.Authentication.ProtectedResourceMetadata? ResourceMetadata { get; set; }
}
}
namespace ModelContextProtocol.AspNetCore
{
public class HttpServerTransportOptions
{
public HttpServerTransportOptions() { }
public System.Func<Microsoft.AspNetCore.Http.HttpContext, ModelContextProtocol.Server.McpServerOptions, System.Threading.CancellationToken, System.Threading.Tasks.Task>? ConfigureSessionOptions { get; set; }
public System.TimeSpan IdleTimeout { get; set; }
public int MaxIdleSessionCount { get; set; }
public bool PerSessionExecutionContext { get; set; }
public System.Func<Microsoft.AspNetCore.Http.HttpContext, ModelContextProtocol.Server.IMcpServer, System.Threading.CancellationToken, System.Threading.Tasks.Task>? RunSessionHandler { get; set; }
public bool Stateless { get; set; }
public System.TimeProvider TimeProvider { get; set; }
}
}
15 changes: 15 additions & 0 deletions tests/ModelContextProtocol.AspNetCore.Tests/PublicApiTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using Microsoft.AspNetCore.Builder;
using PublicApiGenerator;

namespace ModelContextProtocol.AspNetCore.Tests;

public class PublicApiTests
{
[Fact]
public void AspNetCore_PublicApi_Approved()
{
var api = typeof(McpEndpointRouteBuilderExtensions).Assembly.GeneratePublicApi(new ApiGeneratorOptions { IncludeAssemblyAttributes = false });
var approved = File.ReadAllText(Path.Combine(AppContext.BaseDirectory, "PublicApiTests.ModelContextProtocol.AspNetCore.txt"));
Assert.Equal(approved, api);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="PublicApiGenerator" />
</ItemGroup>

<ItemGroup>
Expand All @@ -66,6 +67,12 @@
<ProjectReference Include="..\..\samples\TestServerWithHosting\TestServerWithHosting.csproj" />
</ItemGroup>

<ItemGroup>
<None Include="PublicApiTests.*.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

<ItemGroup>
<Content Include="$([System.IO.Path]::GetFullPath('$(ArtifactsBinDir)'))ModelContextProtocol.TestServer\$(Configuration)\$(TargetFramework)\*">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
Expand Down
Loading
Loading