Skip to content

Commit

Permalink
Update documentation with example of base_path proc (#442)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lordnibbler authored and dblock committed May 31, 2016
1 parent a162e7c commit e47c679
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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' }
```

<a name="host" />
#### host:
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/optional_object_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e47c679

Please sign in to comment.