Skip to content

Mapping self url does not works #35

Open
@regniblod

Description

I try to serialise an object but I get an error with the URL generation for the self url property.

This is my mapping:

mapping:
  class: AppBundle\User
  alias: User
  id_properties:
    - id
  urls:
    self: get_user

This is get_user route definition (which works if I call it directly):

@Route(
    path="/user/{id}",
    name="get_user",
    requirements={"id": "\d+"}
)

And this is the error I get:

Parameter "id" for route "get_user" must match "\d+" ("{id}" given) to generate a corresponding URL.

If I change the mapping to something like

# ...
  urls:
    self: route_without_parameters
# ...

I get a response but without any url referencing that route:

{
  "data": {
    "type": "user",
    "id": "1",
    "attributes": {
        ...
    }
  },
  "jsonapi": {
    "version": "1.0"
  }
}

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions