grape-entity icon indicating copy to clipboard operation
grape-entity copied to clipboard

Nested Documentation

Open rmatesic opened this issue 10 years ago • 4 comments

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.

rmatesic avatar Nov 27 '14 01:11 rmatesic

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.

dblock avatar Nov 27 '14 14:11 dblock

+1

szehnder avatar Dec 30 '14 20:12 szehnder

it can be exposed if a documentation is provided. Using

...
expose :location, using: API::Entities::Location, as: :location, documentation: { type: 'API::Location' }

calfzhou avatar Mar 10 '15 15:03 calfzhou

@calfzhou - How would you get it working with API::Entities::Location.documentation?

Aryk avatar Mar 01 '17 22:03 Aryk