Aspnetcore.docs: Example for ApiConventionNameMatchBehavior.Any?

Created on 12 Dec 2019  Â·  7Comments  Â·  Source: dotnet/AspNetCore.Docs

An example of using ApiConventionNameMatchBehavior.Any would be good. Simply doing

[ApiConventionNameMatch(ApiConventionNameMatchBehavior.Any)]
public static void Any(params object[] _) { }

doesn't work.


Document Details

⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

Source - Docs.ms doc-enhancement

Most helpful comment

@VictorioBerra I cc'd you from #10954 :)

Thanks for responding.

All 7 comments

Address concerns in https://github.com/aspnet/AspNetCore.Docs/issues/10954
ApiConventionNameMatchBehavior.Any only makes sense on params, not methods.

That sounds contradictory to the documentation for ApiConventionNameMatchBehavior.Any:

_Matches any name. Use this if the parameter or method name does not need to be matched._

Should the documentation be amended?

Should the documentation be amended?

API changes are only made to source code /// comments.
Probably a copy/paste error.

@pranavkm

Matches any name. Use this if the parameter ~or method name~ does not need to be matched.
This doesn't work on methods does it?

Should I do a PR on https://github.com/aspnet/AspNetCore/blob/master/src/Mvc/Mvc.Core/src/ApiExplorer/ApiConventionNameMatchBehavior.cs#L12

cc @VictorioBerra

I do not think it works on methods:

IE:

    public static class CustomApiConventions
    {
        [ApiConventionNameMatch(ApiConventionNameMatchBehavior.Any)]
        [ProducesResponseType(418)]
        public static void ABCTEST()
        {

        }

Would NOT get applied to:

        [HttpPost(Name = "CreateProduct")]
        public Product Create([FromBody, Required]Product product)
        {
            return product;
        }

Also, I think you CCed the wrong person @Rick-Anderson but I checked anyway.

@VictorioBerra I cc'd you from #10954 :)

Thanks for responding.

Was this page helpful?
0 / 5 - 0 ratings