Module: Swgr2rb::JsonPathsParserMethods
- Included in:
- EndpointClassConfigGenerator
- Defined in:
- lib/endpoint_class_config_generator/json_paths_parser_methods.rb
Instance Method Summary collapse
- #generate_expected_response(request_properties) ⇒ Object
- #generate_operation_id(request_properties) ⇒ Object
- #generate_request_params(request_properties) ⇒ Object
- #generate_request_type(request_type, request_properties) ⇒ Object
- #generate_version ⇒ Object
Instance Method Details
#generate_expected_response(request_properties) ⇒ Object
11 12 13 14 |
# File 'lib/endpoint_class_config_generator/json_paths_parser_methods.rb', line 11 def generate_expected_response(request_properties) EndpointClassConfig::ExpectedResponse.new(generate_expected_response_code(request_properties), generate_expected_response_schema(request_properties)) end |
#generate_operation_id(request_properties) ⇒ Object
33 34 35 |
# File 'lib/endpoint_class_config_generator/json_paths_parser_methods.rb', line 33 def generate_operation_id(request_properties) request_properties[:operationId] end |
#generate_request_params(request_properties) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/endpoint_class_config_generator/json_paths_parser_methods.rb', line 16 def generate_request_params(request_properties) params = EndpointClassConfig::RequestParams.new([], [], [], []) request_properties[:parameters].select { |hsh| hsh[:required] }.each do |param_hash| param_schema = case param_hash in { schema: } parse_field_properties(schema) in { type: } field_type_to_ruby_class(type) end params.send(param_hash[:in] == 'formData' ? :form_data : param_hash[:in].to_sym) << { name: param_hash[:name], schema: param_schema } end params end |
#generate_request_type(request_type, request_properties) ⇒ Object
3 4 5 6 7 8 9 |
# File 'lib/endpoint_class_config_generator/json_paths_parser_methods.rb', line 3 def generate_request_type(request_type, request_properties) if request_properties[:parameters].find { |param| param[:in] == 'formData' && param[:type] == 'file' } :multipart_post else request_type end end |
#generate_version ⇒ Object
37 38 39 |
# File 'lib/endpoint_class_config_generator/json_paths_parser_methods.rb', line 37 def generate_version @json[:info][:version].to_i end |