Class: Meta::JsonSchema::SchemaBuilderTool

Inherits:
Object
  • Object
show all
Defined in:
lib/meta/json_schema/builders/schema_builder_tool.rb

Class Method Summary collapse

Class Method Details

.build(options = {}, &block) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/meta/json_schema/builders/schema_builder_tool.rb', line 13

def build(options = {}, &block)
  options = SchemaOptions::BaseBuildOptions.check(options)
  SchemaOptions.fix_type_option!(options)

  if apply_staging_schema?(options)
    # 原则上,SchemaBuilderTool 不处理 param render scope 选项,这几个选项只会在 property 宏中出现,
    # 并且交由 StagingSchema 和 ScopingSchema 专业处理。
    # 只不过,经过后置修复后可能包含了 param 和 render 选项
    StagingSchema.build_from_options(options)
  elsif apply_array_schema?(options, block)
    ArraySchemaBuilder.new(options, &block).to_schema
  elsif apply_ref_schema?(options, block)
    RefSchemaBuilder.new(options).to_schema
  elsif apply_dynamic_schema?(options, block)
    DynamicSchemaBuilder.new(options).to_schema
  elsif apply_object_schema?(options, block)
    ObjectSchemaBuilder.new(options, &block).to_schema
  else
    BaseSchema.new(options)
  end
end