Class: R2OAS::Schema::V3::SchemaGenerator

Inherits:
BaseGenerator show all
Defined in:
lib/r2-oas/schema/v3/generator/schema_generator.rb

Constant Summary

Constants inherited from Base

Base::SUPPORT_COMPONENTS_OBJECTS

Instance Method Summary collapse

Methods included from R2OAS::Sortable

#deep_sort

Methods inherited from Base

#support_components_objects

Constructor Details

#initialize(options = {}) ⇒ SchemaGenerator

Returns a new instance of SchemaGenerator.



13
14
15
16
17
# File 'lib/r2-oas/schema/v3/generator/schema_generator.rb', line 13

def initialize(options = {})
  super(options)
  @docs = create_docs
  @options = options
end

Instance Method Details

#create_docsObject



29
30
31
32
33
34
35
36
37
# File 'lib/r2-oas/schema/v3/generator/schema_generator.rb', line 29

def create_docs
  if !skip_generate_docs
    super
  elsif skip_generate_docs && FileTest.exists?(doc_save_file_path)
    YAML.load_file(doc_save_file_path)
  else
    {}
  end
end

#generate_docsObject



19
20
21
22
23
24
25
26
27
# File 'lib/r2-oas/schema/v3/generator/schema_generator.rb', line 19

def generate_docs
  if force_update_schema || schema_file_do_not_exists?
    logger.info '<From routes data>'
    generate_docs_from_routes_data
  else
    logger.info '<From schema files>'
    generate_docs_from_schema_fiels
  end
end