Class JsonApiRoutingConvention
- Namespace
- JsonApiDotNetCore.Middleware
- Assembly
- JsonApiDotNetCore.dll
Registers routes based on the JSON:API resource name, which defaults to camel-case pluralized form of the resource CLR type name. If unavailable (for example, when a controller directly inherits from CoreJsonApiController), the serializer naming convention is applied on the controller type name (camel-case by default).
[PublicAPI]
public sealed class JsonApiRoutingConvention : IJsonApiRoutingConvention, IApplicationModelConvention, IControllerResourceMapping
- Inheritance
-
JsonApiRoutingConvention
- Implements
- Inherited Members
Examples
// controller name is ignored when resource type is available: public class RandomNameController<SomeResource> : JsonApiController<SomeResource> { } // => /someResources
// when using kebab-case naming convention in options: public class RandomNameController<SomeResource> : JsonApiController<SomeResource> { } // => /some-resources
// unable to determine resource type: public class SomeVeryCustomController<SomeResource> : CoreJsonApiController { } // => /someVeryCustom
Constructors
JsonApiRoutingConvention(IJsonApiOptions, IResourceGraph, IJsonApiEndpointFilter, ILogger<JsonApiRoutingConvention>)
public JsonApiRoutingConvention(IJsonApiOptions options, IResourceGraph resourceGraph, IJsonApiEndpointFilter jsonApiEndpointFilter, ILogger<JsonApiRoutingConvention> logger)
Parameters
options
IJsonApiOptionsresourceGraph
IResourceGraphjsonApiEndpointFilter
IJsonApiEndpointFilterlogger
ILogger<JsonApiRoutingConvention>
Methods
Apply(ApplicationModel)
Called to apply the convention to the ApplicationModel.
public void Apply(ApplicationModel application)
Parameters
application
ApplicationModelThe ApplicationModel.
GetControllerNameForResourceType(ResourceType?)
Gets the associated controller name for the provided resource type.
public string? GetControllerNameForResourceType(ResourceType? resourceType)
Parameters
resourceType
ResourceType
Returns
GetResourceTypeForController(Type?)
Gets the associated resource type for the provided controller type.
public ResourceType? GetResourceTypeForController(Type? controllerType)
Parameters
controllerType
Type