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

Configuration hash inside desc block is empty #1908

Closed
shlima opened this issue Sep 23, 2019 · 6 comments
Closed

Configuration hash inside desc block is empty #1908

shlima opened this issue Sep 23, 2019 · 6 comments
Labels

Comments

@shlima
Copy link

shlima commented Sep 23, 2019

mount Endpoint, with: { test: 'ola' }
class Endpoint < Grape::API
  mounted do 
    # if I call `configuration` here it will return `{ test: 'ola' }`

    desc 'Sample endpoint' do
      # if I call `configuration` here it will return en empty hash `{}`
    end
  end
end
@shlima
Copy link
Author

shlima commented Sep 23, 2019

It seems that configuration method inside desc block refers to the desc configuration, not to the grape's mountable configuration.

How can I access mountable configuration inside the desc block?

I wish to use this feature to set up global headers for the swagger:

desc 'Endpoint configuration' do
  headers configuration[:headers_documentation]
end

@dblock
Copy link
Member

dblock commented Sep 24, 2019

Is this just a bug? See if you can fix it @shlima or at least write a few failing tests around it.

@dblock dblock added the bug? label Sep 24, 2019
@myxoh
Copy link
Member

myxoh commented Oct 1, 2019

This sounds like a probable oversight on my part, as it seems like description had a pre-existing method called configuratoin (which is probably overwriting the configuration bit)

@shlima
Copy link
Author

shlima commented Oct 7, 2019

@myxoh
Copy link
Member

myxoh commented Oct 30, 2019

I've found that the issue was that I was not handling properly the configuration within mounted and given blocks (i.e. when the configuration was already evaluated)

@dblock
Copy link
Member

dblock commented Oct 30, 2019

Fixed via #1926

@dblock dblock closed this as completed Oct 30, 2019
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

3 participants