Skip to content

Commit b5e003b

Browse files
committed
Merge pull request #249 from joshsoftware/grouping_parameters
Update README.md
2 parents 9fd5cc3 + 54c47d0 commit b5e003b

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,33 @@ resource "Orders" do
447447
end
448448
```
449449

450+
451+
You can also group metadata using [with_options](http://api.rubyonrails.org/classes/Object.html#method-i-with_options) to factor out duplications.
452+
453+
```ruby
454+
resource "Orders" do
455+
post "/orders" do
456+
457+
with_options :scope => :order, :required => true do
458+
parameter :name, "Order Name"
459+
parameter :item, "Order items"
460+
end
461+
462+
with_options :scope => :order do
463+
response_field :id, "Order ID"
464+
response_field :status, "Order status"
465+
end
466+
467+
let(:name) { "My Order" }
468+
let(:item_id) { 1 }
469+
470+
example "Creating an order" do
471+
expect(status).to be 201
472+
end
473+
end
474+
end
475+
```
476+
450477
#### callback
451478

452479
This is complicated, see [relish docs](https://www.relishapp.com/zipmark/rspec-api-documentation/docs/document-callbacks).

0 commit comments

Comments
 (0)