Skip to content

Commit 8ccce9c

Browse files
committed
Show depreciation warning
1 parent 0565f7e commit 8ccce9c

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

lib/ruby_llm/schema/dsl/schema_builders.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,12 @@ def null_schema(description: nil)
4444
{type: "null", description: description}.compact
4545
end
4646

47-
def object_schema(description: nil, of: nil, &block)
47+
def object_schema(description: nil, of: nil, reference: nil, &block)
48+
if reference
49+
warn "[DEPRECATION] The `reference` option will be deprecated. Please use `of` instead."
50+
of = reference
51+
end
52+
4853
if of
4954
determine_object_reference(of, description)
5055
else

spec/ruby_llm/schema_spec.rb

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@
249249
})
250250
end
251251

252-
it "supports reference to a defined schema by reference option" do
252+
it "supports reference to a defined schema by `of` option" do
253253
schema_class.define :address do
254254
string :street
255255
string :city
@@ -274,6 +274,20 @@
274274
additionalProperties: false
275275
})
276276
end
277+
278+
it "shows deprecation warning if using `reference` instead of `of`" do
279+
schema_class.define :address do
280+
string :street
281+
string :city
282+
end
283+
284+
expect {
285+
schema_class.object :user do
286+
string :name
287+
object :address, reference: :address
288+
end
289+
}.to output(/DEPRECATION.*reference/).to_stderr
290+
end
277291
end
278292

279293
# ===========================================

0 commit comments

Comments
 (0)