You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+14
Original file line number
Diff line number
Diff line change
@@ -1567,6 +1567,20 @@ params do
1567
1567
end
1568
1568
```
1569
1569
1570
+
You can organize settings into layers using nested `with' blocks. Each layer can use, add to, or change the settings of the layer above it. This helps to keep complex parameters organized and consistent, while still allowing for specific customizations to be made.
1571
+
1572
+
```ruby
1573
+
params do
1574
+
with(documentation: { in:'body' }) do# Applies documentation to all nested parameters
1575
+
with(type:String, regexp:/\w+/) do# Applies type and validation to names
1576
+
requires :first_name, desc:'First name'
1577
+
requires :last_name, desc:'Last name'
1578
+
end
1579
+
optional :age, type:Integer, desc:'Age', documentation: { x: { nullable:true } } # Specific settings for 'age'
1580
+
end
1581
+
end
1582
+
```
1583
+
1570
1584
### Renaming
1571
1585
1572
1586
You can rename parameters using `as`, which can be useful when refactoring existing APIs:
0 commit comments