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

Fixed the bug where 'is_array' in the return entity is ignored. #206

Closed
wants to merge 1 commit into from

Conversation

igormoochnick
Copy link
Contributor

When the entity is marked with 'is_array', swagger will show it as array of entities. Example:

  desc 'Get all teams', {
                        is_array: true,
                        entity: API::Entities::TeamRecord
  }
  get '/' do
    teams = TeamsCatalog.teams.limit(100).to_a
    present teams, include_children: true
  end

@dblock
Copy link
Member

dblock commented Jan 31, 2015

This needs tests and a CHANGELOG entry, please.

@dblock
Copy link
Member

dblock commented Mar 5, 2015

Bump @igormoochnick

@calfzhou
Copy link
Contributor

this doesn't work with grape new dsl, is there any way to use for new dsl?

desc 'blah blah' do
  # how to make grape-swagger generate array of TeamRecord
  success API::Entities::TeamRecord
end
get '/' do
  records = ...
  present records, using API::Entities::TeamRecord
end

@dblock
Copy link
Member

dblock commented Mar 10, 2015

@calfzhou If it doesn't work on HEAD, it's a legit feature request.

@frodrigo
Copy link
Contributor

I'm also interested in this pull request. What is missing for integration into master ? it's only the CHANGELOG ? ... I can do it if need !

@dblock
Copy link
Member

dblock commented Mar 31, 2015

It needs tests and a changelog, please feel free to finish this @frodrigo.

@dblock
Copy link
Member

dblock commented Apr 1, 2015

Fixed in tim-vandecasteele@768454b.

@dblock dblock closed this Apr 1, 2015
@birbird
Copy link

birbird commented Aug 3, 2015

Does this feature work now?
I used code like

  desc 'Get all teams', { is_array: true, entity: API::Entities::TeamRecord }

but the Response Class does not show as a array

@rhomeister
Copy link

Is this supported in the new DSL? See calfzhou's question: #206 (comment)

Something like:

      desc 'Return a user' do
        array true
        success User
        failure [[401, 'Unauthorized', 'APIV2::Entities::ApiError']]
      end

@LeFnord
Copy link
Member

LeFnord commented Dec 27, 2016

yeap, see: #defining-an-endpoint-as-an-array

@rhomeister
Copy link

OK, thanks that works. However, it requires passing a Hash instead of using the DSL. If I use both, I get the following deprecation warning:

[DEPRECATION] Passing a options hash and a block to desc is deprecated. Move all hash options to block.

Example code:

      desc 'Return all accessible memberships', is_array: true do
        success Entities::Membership
      end

@LeFnord
Copy link
Member

LeFnord commented Dec 27, 2016

it should also be working with a block

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants