diff --git a/README.md b/README.md index 271024ec..b566a7b0 100644 --- a/README.md +++ b/README.md @@ -202,7 +202,12 @@ You can pass a hash with optional configuration settings to ```add_swagger_docum *not all configuration options supported yet*, but is WIP -`host` and `base_path` are also accepting a `proc` to evaluate. +The `host` and `base_path` options also accept a `proc` or `lambda` to evaluate, which is passed a [request](http://www.rubydoc.info/github/rack/rack/Rack/Request) object: + +```ruby +add_swagger_documentation \ + base_path: proc { |request| request.host =~ /^example/ ? '/api-example' : '/api' } +``` #### host: diff --git a/spec/lib/optional_object_spec.rb b/spec/lib/optional_object_spec.rb index 9ecf79ac..6da8c742 100644 --- a/spec/lib/optional_object_spec.rb +++ b/spec/lib/optional_object_spec.rb @@ -34,7 +34,7 @@ end describe 'option is a proc' do - let(:options) { { host: proc { |foo| foo.host =~ /^example/ ? '/api-example' : '/api' } } } + let(:options) { { host: proc { |request| request.host =~ /^example/ ? '/api-example' : '/api' } } } specify do expect(subject.build(key, options, request)).to eql '/api-example' end