December 2019
Intermediate to advanced
510 pages
11h 33m
English
The DefaultApiConvention class isn't always suitable for our controllers. Furthermore, it is too generic, and action methods are usually too specific to suit the DefaultApiConvention class. Due to this, ASP.NET Core allows us to create our custom API conventions based on our needs. To declare a new convention, we need to create a new static class with the corresponding static methods, like so:
using Microsoft.AspNetCore.Mvc;using Microsoft.AspNetCore.Mvc.ApiExplorer;namespace Catalog.API.Conventions{ public static class ItemApiConvention { [ProducesResponseType(200)] [ProducesResponseType(404)] [ProducesResponseType(400)] [ProducesDefaultResponseType] [ApiConventionNameMatch(ApiConventionNameMatchBehavior.Prefix)] public ...
Read now
Unlock full access