Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

entity documentation support for array of entities? #66

Closed
chebyte opened this issue Mar 28, 2014 · 8 comments
Closed

entity documentation support for array of entities? #66

chebyte opened this issue Mar 28, 2014 · 8 comments

Comments

@chebyte
Copy link

chebyte commented Mar 28, 2014

hi there I have the following grape-entites

module HQ
  module Entities
    class Client < Grape::Entity
      expose :created_by_id, documentation: {type: Integer, desc: "Created by id"}
      expose :updated_by_id, documentation: {type: Integer, desc: "Updated by id"}
      expose :first_name,    documentation: {type: String, desc: 'First Name.'}
      expose :last_name,     documentation: {type: String, desc: 'Last Name.'}
      expose :zipcode,       documentation: {type: String, desc: 'Zip Code.'}
      expose :emails, using: HQ::Entities::Email, documentation: {type: ::Item, desc: 'Emails.'}
    end
  end
end

module HQ
  module Entities
    class Email < Grape::Entity
      expose :address, documentation: {type: Integer, desc: "Email"}
    end
  end
end

the problem that I need that swagger generate the UI with the complex form I means client has many emails

      expose :emails, using: HQ::Entities::Email, documentation: {type: Array, desc: 'Emails.'}

what type I need to use? I added array but it show me just as string field like this

https://www.evernote.com/shard/s143/sh/a53f78c8-5599-4148-811f-e6b7617cd13a/419383ac0d5d9e5bac0a06278ac481da

@idyll
Copy link
Contributor

idyll commented Mar 28, 2014

Does swagger actually support that? If so can you link the format that swagger expects.

@mtorres-ix
Copy link

yeap swagger supports complex forms

@idyll
Copy link
Contributor

idyll commented Mar 28, 2014

When I look at the swagger example i just see a text block where it will let me paste in a bunch of JSON. Do you have an example where it is building a complex form.

@dspaeth-faber
Copy link
Contributor

@chebyte The actual grape-swagger release supports this feature:

expose :emails,  documentation: {type: 'HQ::Entities::Email', is_array: true }

@igormoochnick
Copy link

I'm trying to figure out the same thing. The 'is_array' flag doesn't change anything on the swagger side.
Am I missing anything too?

@igormoochnick
Copy link

Just submitted a pull request for grape-swagger that fixes the issue for the 'is_array' on return entity: https://github.com/tim-vandecasteele/grape-swagger/pull/206

@siriniok
Copy link

Perhaps, this issue should be closed already.
ruby-grape/grape-swagger#206

@dblock
Copy link
Member

dblock commented Dec 11, 2015

Yes.

@dblock dblock closed this as completed Dec 11, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants