Class: RubyLLM::Contract::SchemaValidator::SchemaExtractor

Inherits:
Object
  • Object
show all
Includes:
Concerns::DeepSymbolize
Defined in:
lib/ruby_llm/contract/contract/schema_validator/schema_extractor.rb

Instance Method Summary collapse

Methods included from Concerns::DeepSymbolize

#deep_symbolize

Instance Method Details

#call(schema) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/ruby_llm/contract/contract/schema_validator/schema_extractor.rb', line 9

def call(schema)
  schema_payload = schema.is_a?(Class) ? schema.new : schema
  raw_schema = if schema_payload.respond_to?(:to_json_schema)
                 json_schema = schema_payload.to_json_schema
                 json_schema[:schema] || json_schema["schema"] || json_schema
               else
                 schema
               end

  deep_symbolize(raw_schema)
end