Converts a genai Schema into a standard JSON Schema object.
Schema
This is the inverse of zodObjectToSchema, which renders Zod into the genai/OpenAPI dialect. The two dialects differ in four ways, all handled here:
zodObjectToSchema
type
STRING
string
TYPE_UNSPECIFIED
nullable: true
['string', 'null']
maxItems: '5'
propertyOrdering
example
Everything else (description, title, default, pattern, required, minimum, maximum, format) is already JSON-Schema-shaped and passes through, with items, properties and anyOf converted recursively.
description
title
default
pattern
required
minimum
maximum
format
items
properties
anyOf
Converts a genai
Schemainto a standard JSON Schema object.This is the inverse of
zodObjectToSchema, which renders Zod into the genai/OpenAPI dialect. The two dialects differ in four ways, all handled here:typeis an uppercase enum (STRING) rather than a JSON Schema type name (string).TYPE_UNSPECIFIEDmeans "no constraint" and is dropped.nullable: truewidens the type, which JSON Schema expresses as a type union (['string', 'null']).maxItems: '5').propertyOrderingandexamplehave no JSON Schema equivalent.Everything else (
description,title,default,pattern,required,minimum,maximum,format) is already JSON-Schema-shaped and passes through, withitems,propertiesandanyOfconverted recursively.