Skip to content

PluralizedTypeName option when adding resource doesn't work for routing #786

Closed
@vdaras

Description

@vdaras

Description

Explicitly setting a pluralized type name for a resource doesn't work for routing purposes. Example:

var mvcBuilder = services.AddMvcCore();
services.AddJsonApi(options => {
    options.Namespace = "api/v1";
}, resources: resources => {
    resources.AddResource<TodoResource, Guid>(pluralizedTypeName: "todos");
});

services.AddScoped<IResourceService<TodoResource, Guid>, TodoResourceService>();

Controller is defined as follows

public sealed class TodoController : JsonApiController<TodoResource, Guid>
{
    public TodoController(
        IJsonApiOptions jsonApiOptions,
        ILoggerFactory loggerFactory,
        IResourceService<TodoResource, Guid> resourceService) 
    : base(jsonApiOptions, loggerFactory, resourceService)
    {
    }
}

But when trying to call the API it seems the respective controller is still registered at /api/v1/todoResources instead of /ap1/v1/todos

curl -I -X GET http://localhost:5001/api/v1/todos        
HTTP/1.1 404 Not Found
Date: Sun, 28 Jun 2020 19:14:46 GMT
Server: Kestrel
Content-Length: 0
curl -I -X GET http://localhost:5001/api/v1/todoResources
HTTP/1.1 200 OK
Date: Sun, 28 Jun 2020 19:13:15 GMT
Content-Type: application/vnd.api+json
Server: Kestrel
Transfer-Encoding: chunked

Environment

  • JsonApiDotNetCore Version: 4.0.0-alpha5
  • Other Relevant Package Versions:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions