Skip to content
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

Pattern for mapping json or yaml document incorrect #2434

Closed
dnperfors opened this issue Jun 8, 2022 · 3 comments
Closed

Pattern for mapping json or yaml document incorrect #2434

dnperfors opened this issue Jun 8, 2022 · 3 comments
Milestone

Comments

@dnperfors
Copy link
Contributor

With the basic configuration it is possible to request swagger documents with incorrect extensions. I believe the following tests will fail (I haven't had the change to test this yet on the swashbuckle codebase):

        [Theory]
        [InlineData(typeof(Basic.Startup), "/swagger/v1/swagger.jsonxxx")]
        [InlineData(typeof(Basic.Startup), "/swagger/v1/swagger.yamlxxx")]
        [InlineData(typeof(Basic.Startup), "/swagger/v1/swagger.txt")]
        public async Task SwaggerEndpoint_ReturnsValidSwaggerJson(
            Type startupType,
            string swaggerRequestUri)
        {
            var testSite = new TestSite(startupType);
            var client = testSite.BuildClient();

            var swaggerResponse = await client.GetAsync(swaggerRequestUri);

            Assert.Equal(HttpStatusCode.NotFound, swaggerResponse.StatusCode);
        }

Instead of returning 404 NotFound these will return the json document.

The reason for this seems to be that the patter "/swagger/{documentName}/swagger.{json|yaml}" doesn't actually perform an "or" on the extension, but will generate a route parameter with the name "json|yaml" for the above example the value for this parameter is either "jsonxxx", "yamlxxx" or "txt"

Copy link
Contributor

This issue is stale because it has been open for 60 days with no activity. It will be automatically closed in 14 days if no further updates are made.

@github-actions github-actions bot added the stale Stale issues or pull requests label Apr 22, 2024
@dnperfors
Copy link
Contributor Author

dnperfors commented Apr 22, 2024

This is still an issue, so please leave it open 😇

But I see a pr that should fix this issue 😇

@martincostello
Copy link
Collaborator

This should be fixed by #2418.

@martincostello martincostello removed the stale Stale issues or pull requests label Apr 22, 2024
@martincostello martincostello added this to the v6.6.0 milestone Apr 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants