Class: Swgr2rb::EndpointClassConfigGenerator

Inherits:
Object
  • Object
show all
Includes:
JsonPathsParserMethods, JsonSchemaDefinitionsParserMethods
Defined in:
lib/endpoint_class_config_generator/endpoint_class_config_generator.rb

Overview

EndpointClassConfigGenerator parses Swagger JSON, extracts all parameters necessary for endpoint models generation, and generates an array of EndpointClassConfig instances.

Instance Method Summary collapse

Methods included from JsonPathsParserMethods

#generate_expected_response, #generate_operation_id, #generate_request_params, #generate_request_type, #generate_version

Methods included from JsonSchemaDefinitionsParserMethods

#generate_response_schema_definitions

Constructor Details

#initialize(swagger_path) ⇒ EndpointClassConfigGenerator

Returns a new instance of EndpointClassConfigGenerator.



19
20
21
22
# File 'lib/endpoint_class_config_generator/endpoint_class_config_generator.rb', line 19

def initialize(swagger_path)
  @json = fetch_swagger_json(swagger_path)
  @schema_definitions = {}
end

Instance Method Details

#generate_configsObject



24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/endpoint_class_config_generator/endpoint_class_config_generator.rb', line 24

def generate_configs
  generate_response_schema_definitions
  configs = @json[:paths].map do |request_path, request_hash|
    request_hash.map do |request_type, request_properties|
      generate_endpoint_config(request_path,
                               request_type,
                               request_properties)
    end
  end.flatten
  generate_uniq_identifiers(configs)
  configs
end