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

Why are Hashes not included? #445

Closed
aschuster3 opened this issue Jun 3, 2016 · 3 comments
Closed

Why are Hashes not included? #445

aschuster3 opened this issue Jun 3, 2016 · 3 comments
Labels

Comments

@aschuster3
Copy link
Contributor

While parsing through to see why my Hash was not appearing, I found this line: https://github.com/ruby-grape/grape-swagger/blob/master/lib/grape-swagger/endpoint.rb#L234

Basically, when that line says that if a parameter is a Hash, it will not be included. In a personal branch, I changed the logic to read as follows (emphasis on the added parenthesis):

memo[key] = param.last unless (param.last[:type] == 'Hash' || param.last[:type] == 'Array') && !param.last.key?(:documentation)

This makes it so that a Hash or an Array is not included if it is not documented instead of not including Hashes ever. Before I make a PR upstream, I was curious if this was intentional. I'm using this in conjunction with grape-entity and the problem I faced was when I call ObjectEntity.documentation as a required param like as follows:

params do
  requires :something, using: ObjectEntity.documentation
end

With ObjectEntity looking like this:

class ObjectEntity < Grape::Entity
  expose :object_id, documentation: { type: Integer, documentation: { in: 'body' } }
  expose :object_hash, documentation: { type: Hash, documentation: { in: 'body' } }
end

The object_id appears just fine, but the object_hash does not.

It is worth mentioning that if I state my parameters as follows, it works fine, but doesn't let me have path paramenters appear as I would prefer:

desc 'Sample description' do
  params ObjectEntity.documentation
end

I'm using the Master branch of grape-swagger with all dependencies updated to the latest versions.

@dblock dblock added the bug? label Jun 4, 2016
@dblock
Copy link
Member

dblock commented Jun 4, 2016

I would say that if there's no spec for it, it's not intentional.

This was referenced Jun 10, 2016
@dblock
Copy link
Member

dblock commented Jun 14, 2016

Does #454 address everything? Closing.

@dblock dblock closed this as completed Jun 14, 2016
@aschuster3
Copy link
Contributor Author

Yep!

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

No branches or pull requests

2 participants