Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
95fe538
Fix API blueprint documentation.
FabienChaynes Feb 7, 2018
aee3bc0
Fix API blueprint documentation.
FabienChaynes Feb 8, 2018
6a86bfe
Fix API blueprint documentation.
FabienChaynes Feb 8, 2018
b57259d
Fix API blueprint documentation.
FabienChaynes Feb 8, 2018
96fbd74
Fix API blueprint documentation.
FabienChaynes Feb 8, 2018
6534f28
Add api_explanation to the api-blueprint template
icidasset Feb 14, 2018
4a30554
Add route and method explanations
icidasset Feb 14, 2018
56873e7
Add explanations to template
icidasset Feb 14, 2018
b9d7801
Fix attributes
icidasset Feb 14, 2018
bb5546d
Further improve template
icidasset Feb 14, 2018
d7d85ef
Improve field properties
icidasset Feb 14, 2018
8048cd2
Clean up template
icidasset Feb 14, 2018
4758f6c
Fix specs
icidasset Feb 15, 2018
35c6a8b
Actually use the attributes in the request
icidasset Feb 15, 2018
24ff4f7
Handle multiple examples correctly
icidasset Feb 15, 2018
f221b66
Remove example from parameters and attributes
icidasset Feb 15, 2018
3429130
Add ability to define default values for parameters and attributes
icidasset Feb 15, 2018
4f8c44d
Move method explanation to the right place in the template
icidasset Feb 16, 2018
ec98981
Allow the use of action methods (eg. `get`) outside `route` blocks
icidasset Feb 19, 2018
13ea7de
Allow multiple http methods if they have different action names
icidasset Feb 21, 2018
454d0ab
Move the description of the parameters
icidasset Feb 27, 2018
b2ec981
Add ability to sort the routes alphabetically
icidasset Feb 28, 2018
2f56cb8
Merge pull request #2 from icidasset/fix-api-blueprint-format
Mar 22, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Actually use the attributes in the request
  • Loading branch information
icidasset committed Feb 15, 2018
commit 35c6a8bd35e94da61fc45dc6351dd276b1f3824c
16 changes: 12 additions & 4 deletions lib/rspec_api_documentation/dsl/endpoint/params.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,19 @@ def initialize(example_group, example, extra_params)
end

def call
parameters = example.metadata.fetch(:parameters, {}).inject({}) do |hash, param|
set_param = -> hash, param {
SetParam.new(self, hash, param).call
end
parameters.deep_merge!(extra_params)
parameters
}

example.metadata
.fetch(:parameters, {})
.inject({}, &set_param)
.deep_merge(
example.metadata
.fetch(:attributes, {})
.inject({}, &set_param)
)
.deep_merge(extra_params)
end

private
Expand Down
7 changes: 7 additions & 0 deletions spec/dsl_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,12 @@
parameter :id, 'The ID of the resource.', :required => true, scope: :data
parameter :note, "Any additional notes about your order."

attribute :tip, "The amount you want to tip", :required => true

let(:type) { "coffee" }
let(:size) { "medium" }
let(:data_id) { 2 }
let(:tip) { 20 }

let(:id) { 1 }

Expand All @@ -157,6 +160,10 @@
expect(params['data']).to eq({'id' => 2})
end

it "should set attributes as well" do
expect(params["tip"]).to eq(tip())
end

it "should allow extra parameters to be passed in" do
expect(client).to receive(method).with(path, params.merge("extra" => true), nil)
do_request(:extra => true)
Expand Down