grape-entity
grape-entity copied to clipboard
Nested Documentation
When using Grape, Grape Entity and Grape Swagger and I have an entity with a nested object. Should we have the ability to provide nested documentation if that object has a nested object inside?
Example.
class User < Grape::Entity
expose :id, documentation: { type: 'Integer', desc: 'Id' }
expose :firstname, documentation: { type: 'String', desc: 'First Name' }
expose :lastname, documentation: { type: 'String', desc: 'Last Name' }
expose :username, documentation: { type: 'String', desc: 'Username' }
expose :email, documentation: { type: 'String', desc: 'Email' }
expose :location, using: API::Entities::Location, as: :location
But when I call
API::Entities::User.documentation
it doesn't include my location inside the documentation hash.
Definitely think this could be useful. I think the reason why it doesn't exist is that people avoid creating nested APIs like these and would expose location as a first class thing.
+1
it can be exposed if a documentation
is provided. Using
...
expose :location, using: API::Entities::Location, as: :location, documentation: { type: 'API::Location' }
@calfzhou - How would you get it working with API::Entities::Location.documentation?