procore-oss / blueprinter

Simple, Fast, and Declarative Serialization Library for Ruby
MIT License
1.14k stars 109 forks source link

JSON API specification #305

Closed GMorris-professional closed 10 months ago

GMorris-professional commented 1 year ago

I see that it is possible to serialize links through the meta attributes but it would be nice to have the option to specify links in the blueprint.

It would be ideal to ultimately be able to set the specification adapter that blueprinter could use during serialization (similar to ActiveModel::Serializers).

class ArticleBlueprint < Blueprinter::Base
...
field :content

link :self do |object|
    href "articles/#{object.id}"
end

Which would give:


{
  data: {content: "some content"},
  links: {
    self: {href: "http://localhost:4000/articles/1"}
  }
}
github-actions[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.