@@ -22,9 +22,10 @@ def test_misuse
22
22
E1 = OpenAI ::Helpers ::StructuredOutput ::EnumOf [ :one ]
23
23
24
24
class M1 < OpenAI ::Helpers ::StructuredOutput ::BaseModel
25
- required :a , String
25
+ required :a , String , doc : "dog"
26
26
required :b , Integer , nil? : true
27
- required :c , E1 , nil? : true
27
+ required :c , E1 , nil? : true , doc : "dog"
28
+ required :d , E1 , doc : "dog"
28
29
end
29
30
30
31
class M2 < OpenAI ::Helpers ::StructuredOutput ::BaseModel
@@ -36,7 +37,7 @@ class M3 < OpenAI::Helpers::StructuredOutput::BaseModel
36
37
end
37
38
38
39
U1 = OpenAI ::Helpers ::StructuredOutput ::UnionOf [ Integer , A1 ]
39
- U2 = OpenAI ::Helpers ::StructuredOutput ::UnionOf [ :type , m2 : M2 , m3 : M3 ]
40
+ U2 = OpenAI ::Helpers ::StructuredOutput ::UnionOf [ M2 , M3 ]
40
41
U3 = OpenAI ::Helpers ::StructuredOutput ::UnionOf [ A1 , A1 ]
41
42
42
43
def test_coerce
@@ -78,18 +79,21 @@ def test_to_schema
78
79
A1 => { type : "array" , items : { type : "string" } } ,
79
80
OpenAI ::Helpers ::StructuredOutput ::ArrayOf [ String , nil? : true , doc : "a1" ] => {
80
81
type : "array" ,
81
- items : { type : %w[ string null ] } ,
82
- description : "a1"
82
+ items : { type : %w[ string null ] , description : "a1" }
83
83
} ,
84
84
E1 => { type : "string" , enum : [ "one" ] } ,
85
85
M1 => {
86
86
type : "object" ,
87
87
properties : {
88
- a : { type : "string" } ,
88
+ a : { type : "string" , description : "dog" } ,
89
89
b : { type : %w[ integer null ] } ,
90
- c : { anyOf : [ { type : "string" , enum : %w[ one ] } , { type : "null" } ] }
90
+ c : {
91
+ anyOf : [ { type : "string" , enum : [ "one" ] } , { type : "null" } ] ,
92
+ description : "dog"
93
+ } ,
94
+ d : { description : "dog" , type : "string" , enum : [ "one" ] }
91
95
} ,
92
- required : %w[ a b c ] ,
96
+ required : %w[ a b c d ] ,
93
97
additionalProperties : false
94
98
} ,
95
99
U1 => {
@@ -162,8 +166,9 @@ class M10 < OpenAI::Helpers::StructuredOutput::BaseModel
162
166
163
167
class M11 < OpenAI ::Helpers ::StructuredOutput ::BaseModel
164
168
required :a , U3
165
- required :b , A1
169
+ required :b , A1 , doc : "dog"
166
170
required :c , A1
171
+ required :d , A1 , doc : "dawg"
167
172
end
168
173
169
174
def test_definition_reusing
@@ -311,20 +316,20 @@ def test_definition_reusing
311
316
]
312
317
} ,
313
318
M11 => {
314
- :$defs => { ".a/?.0/[]" => { type : "array" , items : { type : "string" } } } ,
315
- :type => "object" ,
316
- :properties => {
319
+ type : "object" ,
320
+ properties : {
317
321
a : {
318
322
anyOf : [
319
323
{ type : "array" , items : { type : "string" } } ,
320
324
{ type : "array" , items : { type : "string" } }
321
325
]
322
326
} ,
323
- b : { :$ref => "#/$defs/.a/?.0/[]" } ,
324
- c : { :$ref => "#/$defs/.a/?.0/[]" }
327
+ b : { description : "dog" , type : "array" , items : { type : "string" } } ,
328
+ c : { type : "array" , items : { type : "string" } } ,
329
+ d : { description : "dawg" , type : "array" , items : { type : "string" } }
325
330
} ,
326
- : required => %w[ a b c ] ,
327
- : additionalProperties => false
331
+ required : %w[ a b c d ] ,
332
+ additionalProperties : false
328
333
}
329
334
}
330
335
0 commit comments