@@ -3316,4 +3316,226 @@ mod tests {
33163316 }
33173317 "# ) ;
33183318 }
3319+
3320+ #[ test]
3321+ fn nullable_list_of_nullable_input_objects ( ) {
3322+ let operation = Operation :: from_document (
3323+ RawOperation {
3324+ source_text : "query QueryName($objects: [RealInputObject]) { id }" . to_string ( ) ,
3325+ persisted_query_id : None ,
3326+ headers : None ,
3327+ variables : None ,
3328+ source_path : None ,
3329+ } ,
3330+ & SCHEMA ,
3331+ None ,
3332+ MutationMode :: None ,
3333+ false ,
3334+ false ,
3335+ )
3336+ . unwrap ( )
3337+ . unwrap ( ) ;
3338+ let tool = Tool :: from ( operation) ;
3339+
3340+ insta:: assert_debug_snapshot!( tool, @r##"
3341+ Tool {
3342+ name: "QueryName",
3343+ description: Some(
3344+ "The returned value is optional and has type `String`",
3345+ ),
3346+ input_schema: {
3347+ "type": String("object"),
3348+ "properties": Object {
3349+ "objects": Object {
3350+ "type": String("array"),
3351+ "items": Object {
3352+ "oneOf": Array [
3353+ Object {
3354+ "$ref": String("#/definitions/RealInputObject"),
3355+ },
3356+ Object {
3357+ "type": String("null"),
3358+ },
3359+ ],
3360+ },
3361+ },
3362+ },
3363+ "definitions": Object {
3364+ "RealInputObject": Object {
3365+ "type": String("object"),
3366+ "required": Array [
3367+ String("required"),
3368+ ],
3369+ "properties": Object {
3370+ "optional": Object {
3371+ "description": String("optional is a input field that is optional"),
3372+ "type": String("string"),
3373+ },
3374+ "required": Object {
3375+ "description": String("required is a input field that is required"),
3376+ "type": String("string"),
3377+ },
3378+ },
3379+ },
3380+ },
3381+ },
3382+ annotations: Some(
3383+ ToolAnnotations {
3384+ title: None,
3385+ read_only_hint: Some(
3386+ true,
3387+ ),
3388+ destructive_hint: None,
3389+ idempotent_hint: None,
3390+ open_world_hint: None,
3391+ },
3392+ ),
3393+ }
3394+ "## ) ;
3395+ insta:: assert_snapshot!( serde_json:: to_string_pretty( & serde_json:: json!( tool. input_schema) ) . unwrap( ) , @r##"
3396+ {
3397+ "type": "object",
3398+ "properties": {
3399+ "objects": {
3400+ "type": "array",
3401+ "items": {
3402+ "oneOf": [
3403+ {
3404+ "$ref": "#/definitions/RealInputObject"
3405+ },
3406+ {
3407+ "type": "null"
3408+ }
3409+ ]
3410+ }
3411+ }
3412+ },
3413+ "definitions": {
3414+ "RealInputObject": {
3415+ "type": "object",
3416+ "required": [
3417+ "required"
3418+ ],
3419+ "properties": {
3420+ "optional": {
3421+ "description": "optional is a input field that is optional",
3422+ "type": "string"
3423+ },
3424+ "required": {
3425+ "description": "required is a input field that is required",
3426+ "type": "string"
3427+ }
3428+ }
3429+ }
3430+ }
3431+ }
3432+ "## ) ;
3433+ }
3434+
3435+ #[ test]
3436+ fn non_nullable_list_of_non_nullable_input_objects ( ) {
3437+ let operation = Operation :: from_document (
3438+ RawOperation {
3439+ source_text : "query QueryName($objects: [RealInputObject!]!) { id }" . to_string ( ) ,
3440+ persisted_query_id : None ,
3441+ headers : None ,
3442+ variables : None ,
3443+ source_path : None ,
3444+ } ,
3445+ & SCHEMA ,
3446+ None ,
3447+ MutationMode :: None ,
3448+ false ,
3449+ false ,
3450+ )
3451+ . unwrap ( )
3452+ . unwrap ( ) ;
3453+ let tool = Tool :: from ( operation) ;
3454+
3455+ insta:: assert_debug_snapshot!( tool, @r##"
3456+ Tool {
3457+ name: "QueryName",
3458+ description: Some(
3459+ "The returned value is optional and has type `String`",
3460+ ),
3461+ input_schema: {
3462+ "type": String("object"),
3463+ "required": Array [
3464+ String("objects"),
3465+ ],
3466+ "properties": Object {
3467+ "objects": Object {
3468+ "type": String("array"),
3469+ "items": Object {
3470+ "$ref": String("#/definitions/RealInputObject"),
3471+ },
3472+ },
3473+ },
3474+ "definitions": Object {
3475+ "RealInputObject": Object {
3476+ "type": String("object"),
3477+ "required": Array [
3478+ String("required"),
3479+ ],
3480+ "properties": Object {
3481+ "optional": Object {
3482+ "description": String("optional is a input field that is optional"),
3483+ "type": String("string"),
3484+ },
3485+ "required": Object {
3486+ "description": String("required is a input field that is required"),
3487+ "type": String("string"),
3488+ },
3489+ },
3490+ },
3491+ },
3492+ },
3493+ annotations: Some(
3494+ ToolAnnotations {
3495+ title: None,
3496+ read_only_hint: Some(
3497+ true,
3498+ ),
3499+ destructive_hint: None,
3500+ idempotent_hint: None,
3501+ open_world_hint: None,
3502+ },
3503+ ),
3504+ }
3505+ "## ) ;
3506+ insta:: assert_snapshot!( serde_json:: to_string_pretty( & serde_json:: json!( tool. input_schema) ) . unwrap( ) , @r##"
3507+ {
3508+ "type": "object",
3509+ "required": [
3510+ "objects"
3511+ ],
3512+ "properties": {
3513+ "objects": {
3514+ "type": "array",
3515+ "items": {
3516+ "$ref": "#/definitions/RealInputObject"
3517+ }
3518+ }
3519+ },
3520+ "definitions": {
3521+ "RealInputObject": {
3522+ "type": "object",
3523+ "required": [
3524+ "required"
3525+ ],
3526+ "properties": {
3527+ "optional": {
3528+ "description": "optional is a input field that is optional",
3529+ "type": "string"
3530+ },
3531+ "required": {
3532+ "description": "required is a input field that is required",
3533+ "type": "string"
3534+ }
3535+ }
3536+ }
3537+ }
3538+ }
3539+ "## ) ;
3540+ }
33193541}
0 commit comments