Skip to content

How do I respond with only meta data? #1795

Open
@ezekg

Description

I am using the :json_api adapter and am wanting to render only meta data for a few endpoints, e.g. responding without a top-level data key. As far as I can tell, this is allowable under the JSON API spec. I would expect to be able to do something similar to,

render: json: nil, meta: { ... }, serializer: SomeMetaSerializer

I know I could simply do,

render: json: { meta: { ... } }.to_json

but I'd like to take advantage of active model serializers automatic key transform.

Is there a way to do this that I'm just missing? Am I doing it wrong? I've attempted a few different monkey patches, but there doesn't seem to be a way to get rid of the top-level data key, even though it seems it's not explicitly required if a meta or errors key is present.

If needed, I am using Rails 5.0.0.rc1. with AMS 0.10.0.

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions