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

added a look up for nested presenters #114

Conversation

dspaeth-faber
Copy link
Contributor

When you expose a property with a presenter like this:

expose :links, using: Link, :documentation => { type: 'array', items: {'$ref' => 'link'} }

The Link entity does not apear in the documentation unless you use it direktly for another action.
With this PR directly used presenters (not recursivly) are looked up and used.

Furthor more I did change parse_entity_name to use instance_variable_get(:@root)
because the property name must match my $ref entry. When you dont change this
the shown model name can differ from the linked one. Example:

module API
  class Link < Grape::Entity
      root 'links', 'link'
  end
end

Would be displayed as "link" for the Modelname, but I have to define

expose :links, using: Link, :documentation => { type: 'array', items: {'$ref' => 'API::Link'} }

And swagger would display the property like this:

links (array[API::Link], optional)

@dblock
Copy link
Member

dblock commented Jul 14, 2014

I like it. This needs tests and an update to CHANGELOG to be merged, please.

@dspaeth-faber
Copy link
Contributor Author

@dblock I did add some spec's but merge with master will result in many merge conflicts.

@dblock
Copy link
Member

dblock commented Jul 15, 2014

You have to do the rebase work, please. If the merge looks crazy, I usually just copy-paste the code into the right place(s) in a new branch.

@dspaeth-faber
Copy link
Contributor Author

I hope that it is now in a better condition. If not please give me a hint how I can improve the PR.

@dblock
Copy link
Member

dblock commented Jul 16, 2014

Looks great. Merged via tim-vandecasteele@860da15, thanks.

@dblock dblock closed this Jul 16, 2014
@dspaeth-faber
Copy link
Contributor Author

Thank you too.

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

Successfully merging this pull request may close these issues.

2 participants