Skip to content

Commit

Permalink
path parameters uniq
Browse files Browse the repository at this point in the history
  • Loading branch information
Mario.RuizSanchez committed Sep 27, 2019
1 parent c795cd7 commit 614ecfd
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions lib/open_api_import.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class OpenApiImport
# tags_file: It will be used the tags key to create the module name, for example the tags: [users,list] will create the module UsersList and and each module will be in a new requests file.
# fixed: all the requests will be under the module Requests
##############################################################################################
def self.from(swagger_file, create_method_name: :operation_id, include_responses: true, mock_response: false, name_for_module: :path)
def self.from(swagger_file, create_method_name: :operation_id, include_responses: true, mock_response: false, name_for_module: :path, silent: false)
begin
f = File.new("#{swagger_file}_open_api_import.log", "w")
f.sync = true
Expand Down Expand Up @@ -140,7 +140,7 @@ def self.from(swagger_file, create_method_name: :operation_id, include_responses

# for the case operationId is missing
cont[:operationId] = "undefined" unless cont.key?(:operationId)

if create_method_name == :path
method_name = (met.to_s + "_" + path.path.to_s).snake_case
method_name.chop! if method_name[-1] == "_"
Expand Down Expand Up @@ -276,9 +276,11 @@ def self.from(swagger_file, create_method_name: :operation_id, include_responses
param_name = p[:name].to_s.snake_case
path_txt.gsub!("{#{p[:name]}}", "\#{#{param_name}}")
end
params_path << param_name
#params_required << param_name if p[:required].to_s=="true"
description_parameters << "# #{p[:name]}: (#{type}) #{"(required)" if p[:required].to_s=="true"} #{p[:description]}"
unless params_path.include?(param_name)
params_path << param_name
#params_required << param_name if p[:required].to_s=="true"
description_parameters << "# #{p[:name]}: (#{type}) #{"(required)" if p[:required].to_s=="true"} #{p[:description]}"
end
elsif p[:in] == "query"
params_query << p[:name]
params_required << p[:name] if p[:required].to_s=="true"
Expand Down

0 comments on commit 614ecfd

Please sign in to comment.