Skip to content

Commit f564a14

Browse files
committed
Add docs
1 parent 8ccce9c commit f564a14

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,28 @@ class MySchema < RubyLLM::Schema
291291
end
292292
```
293293

294+
### Nested Schemas
295+
296+
You can embed existing schema classes directly within objects or arrays for reusable schema composition.
297+
298+
```ruby
299+
class PersonSchema < RubyLLM::Schema
300+
string :name
301+
integer :age
302+
end
303+
304+
class CompanySchema < RubyLLM::Schema
305+
# Using 'of' parameter
306+
object :ceo, of: PersonSchema
307+
array :employees, of: PersonSchema
308+
309+
# Using Schema.new in block
310+
object :founder do
311+
PersonSchema.new
312+
end
313+
end
314+
```
315+
294316
## JSON Output
295317

296318
```ruby

0 commit comments

Comments
 (0)