Module: Dry::Schema::JSONSchema::SchemaMethods

Defined in:
lib/dspy/ext/dry_schema.rb

Instance Method Summary collapse

Instance Method Details

#json_schema(loose: false) ⇒ Object

Override the original json_schema method



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/dspy/ext/dry_schema.rb', line 74

def json_schema(loose: false)
  compiler = SchemaCompiler.new(root: true, loose: loose)
  compiler.call(to_ast)
  result = compiler.to_hash

  # Add descriptions to properties from schema_metas
  if respond_to?(:schema_metas) && !schema_metas.empty?
    schema_metas.each do |key, meta|
      if meta[:description] && result[:properties][key]
        result[:properties][key][:description] = meta[:description]
      end
    end
  end

  result
end