Table of Contents

Class JsonApiRoutingConvention

Namespace
JsonApiDotNetCore.Middleware
Assembly
JsonApiDotNetCore.dll

The default routing convention registers the name of the resource as the route using the serializer naming convention. The default for this is a camel case formatter. If the controller directly inherits from CoreJsonApiController and there is no resource directly associated, it uses the name of the controller instead of the name of the type.

[PublicAPI]
public sealed class JsonApiRoutingConvention : IJsonApiRoutingConvention, IApplicationModelConvention, IControllerResourceMapping
Inheritance
JsonApiRoutingConvention
Implements
Inherited Members

Examples

public class SomeResourceController : JsonApiController<SomeResource> { } // => /someResources/relationship/relatedResource

public class RandomNameController<SomeResource> : JsonApiController<SomeResource> { } // => /someResources/relationship/relatedResource

// when using kebab-case naming convention: public class SomeResourceController<SomeResource> : JsonApiController<SomeResource> { } // => /some-resources/relationship/related-resource

public class SomeVeryCustomController<SomeResource> : CoreJsonApiController { } // => /someVeryCustoms/relationship/relatedResource

Constructors

JsonApiRoutingConvention(IJsonApiOptions, IResourceGraph, ILogger<JsonApiRoutingConvention>)

public JsonApiRoutingConvention(IJsonApiOptions options, IResourceGraph resourceGraph, ILogger<JsonApiRoutingConvention> logger)

Parameters

options IJsonApiOptions
resourceGraph IResourceGraph
logger ILogger<JsonApiRoutingConvention>

Methods

Apply(ApplicationModel)

Called to apply the convention to the ApplicationModel.

public void Apply(ApplicationModel application)

Parameters

application ApplicationModel

The ApplicationModel.

GetControllerNameForResourceType(ResourceType?)

Gets the associated controller name for the provided resource type.

public string? GetControllerNameForResourceType(ResourceType? resourceType)

Parameters

resourceType ResourceType

Returns

string

GetResourceTypeForController(Type?)

Gets the associated resource type for the provided controller type.

public ResourceType? GetResourceTypeForController(Type? controllerType)

Parameters

controllerType Type

Returns

ResourceType