README.md in bright_serializer-0.1.1 vs README.md in bright_serializer-0.2.0

- old
+ new

@@ -1,6 +1,7 @@ [![Actions Status](https://github.com/petalmd/bright_serializer/workflows/Build/badge.svg)](https://github.com/petalmd/bright_serializer/actions?query=workflow%3ABuild) +[![Gem Version](https://badge.fury.io/rb/bright_serializer.svg)](https://badge.fury.io/rb/bright_serializer) # BrightSerializer This is a very light and fast gem to serialize object in a Ruby project. @@ -117,9 +118,30 @@ class AccountSerializer include BrightSerializer::Serializer attributes :id, :first_name, :last_name attribute :friends do |object| + FriendSerializer.new(object.friends) + end +end +``` + +### Entity + +You can define the entity of your serializer to generate documentation with the option `entity`. +The feature was build to work with [grape-swagger](https://github.com/ruby-grape/grape-swagger). +For more information about defining a model entity see the [Swagger documentation](https://swagger.io/specification/v2/?sbsearch=array%20response#schema-object). + +```ruby +class AccountSerializer + include BrightSerializer::Serializer + attribute :id, entity: { type: :string, description: 'The id of the account' } + attribute :name + + attribute :friends, + entity: { + type: :array, items: { ref: 'FriendSerializer' }, description: 'The list the account friends.' + } do |object| FriendSerializer.new(object.friends) end end ```