DotNetAnalyzers / AspNetCoreAnalyzers

MIT License
62 stars 4 forks source link

Check [Produces(type)] #64

Open JohanLarsson opened 5 years ago

JohanLarsson commented 5 years ago

Before:

namespace AspBox
{
    using Microsoft.AspNetCore.Mvc;

    [Route("api/values")]
    [ApiController]
    public class ValuesController : ControllerBase
    {
        [Produces(typeof(string))]
        [HttpPost]
        public IActionResult Create([FromBody]Foo foo)
        {
            return CreatedAtAction("Get", new { id = foo.Id }, foo);
        }
    }
}

After:

namespace AspBox
{
    using Microsoft.AspNetCore.Mvc;

    [Route("api/values")]
    [ApiController]
    public class ValuesController : ControllerBase
    {
        [Produces(typeof(Foo))]
        [HttpPost]
        public IActionResult Create([FromBody]Foo foo)
        {
            return CreatedAtAction("Get", new { id = foo.Id }, foo);
        }
    }
}