Hide endpoint in Swagger: retarget net10.0, Swashbuckle 10.2.3, add built-in OpenAPI companion - #2205
Merged
vladimir-pecanac-main merged 3 commits intoSep 22, 2026
Conversation
…uilt-in OpenAPI companion - HideEndpointInSwagger and its test project move from net7.0 to net10.0 - Swashbuckle.AspNetCore 6.4.0 to 10.2.3, Microsoft.AspNetCore.OpenApi 7.0.2 to 10.0.12 - SwaggerDocumentFilter uses Microsoft.OpenApi, the namespace OpenApiDocument lives in now - Program.cs moves to top-level statements and drops AddEndpointsApiExplorer() - Summaries becomes a collection expression - Test packages: Microsoft.NET.Test.Sdk 18.10.0, xunit 2.9.3, xunit.runner.visualstudio 4.0.0, coverlet.collector 10.0.1 - New HideEndpointInOpenApi project shows the same techniques against the built-in OpenAPI generator, with ShouldInclude and an IOpenApiDocumentTransformer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Retargets the HideEndpointInSwagger sample to .NET 10 and adds a companion project that shows the same techniques against the built-in OpenAPI generator.
HideEndpointInSwaggerandHideEndpointInSwaggerTestsmove fromnet7.0tonet10.0.Swashbuckle.AspNetCore6.4.0 to 10.2.3,Microsoft.AspNetCore.OpenApi7.0.2 to 10.0.12. Both clear theNU1903advisories the old versions carried.SwaggerDocumentFilter.csnow usesMicrosoft.OpenApi. On the current Swashbuckle lineMicrosoft.OpenApi.Modelsno longer exists, so the old using is a compile error.Program.csmoves to top-level statements and dropsAddEndpointsApiExplorer(), which the current template does not call.Summariesbecomes a collection expression.Microsoft.NET.Test.Sdk18.10.0,xunit2.9.3,xunit.runner.visualstudio4.0.0,coverlet.collector10.0.1.HideEndpointInOpenApiproject references onlyMicrosoft.AspNetCore.OpenApiand carries the same controller plusOpenApiOptions.ShouldIncludeand anIOpenApiDocumentTransformer.Verified on SDK 10.0.302: solution builds at 0 warnings, 5 of 5 tests pass. The Swashbuckle app serves
/swagger/v1/swagger.jsonwith"paths": {}and/swagger/index.htmlat 200; the companion app serves/openapi/v1.jsonwith"paths": {}. On both buildsGetMethodOnereturns 404 and the other four endpoints return 200 while absent from the document.