Class: Apia::OpenApi::Objects::Schema

Inherits:
Object
  • Object
show all
Includes:
Helpers
Defined in:
lib/apia/open_api/objects/schema.rb

Instance Method Summary collapse

Methods included from Helpers

#add_to_components_schemas, #convert_type_to_open_api_data_type, #formatted_description, #generate_array_schema, #generate_id_from_definition, #generate_scalar_schema, #generate_schema_ref

Constructor Details

#initialize(spec:, definition:, schema:, id:, endpoint: nil, path: nil) ⇒ Schema

Returns a new instance of Schema.



38
39
40
41
42
43
44
45
46
# File 'lib/apia/open_api/objects/schema.rb', line 38

def initialize(spec:, definition:, schema:, id:, endpoint: nil, path: nil)
  @spec = spec
  @definition = definition
  @schema = schema
  @id = id
  @endpoint = endpoint # endpoint gets specified when we are dealing with a partial response (see below)
  @path = path
  @children = []
end

Instance Method Details

#add_to_specObject



48
49
50
51
52
53
54
55
56
# File 'lib/apia/open_api/objects/schema.rb', line 48

def add_to_spec
  if @definition.try(:type)&.polymorph?
    build_schema_for_polymorph
    return @schema
  end

  generate_child_schemas
  @schema
end