Class: Swgr2rb::EndpointClassesGenerator

Inherits:
Object
  • Object
show all
Defined in:
lib/endpoint_class_generator/endpoint_classes_generator.rb

Overview

EndpointClassesGenerator calls a component that generates an array of configs for endpoint models from Swagger JSON, and then invokes Ruby file generators for each config.

Instance Method Summary collapse

Constructor Details

#initialize(swagger_endpoint_path, params) ⇒ EndpointClassesGenerator

Returns a new instance of EndpointClassesGenerator.



12
13
14
15
# File 'lib/endpoint_class_generator/endpoint_classes_generator.rb', line 12

def initialize(swagger_endpoint_path, params)
  @swagger_endpoint_path = swagger_endpoint_path
  @params = params
end

Instance Method Details

#generate_endpoint_classesObject



17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/endpoint_class_generator/endpoint_classes_generator.rb', line 17

def generate_endpoint_classes
  EndpointClassConfigGenerator.new(@swagger_endpoint_path)
                              .generate_configs.map do |endpoint_config|
    endpoint_class_name = generate_class_name(endpoint_config.operation_id)
    SchemaModuleGenerator.new(endpoint_config,
                              generate_schema_opts(endpoint_class_name))
                         .generate_file

    EndpointClassGenerator.new(endpoint_config,
                               generate_class_opts(endpoint_class_name))
                          .generate_file
  end
end