Skip to content

Commit

Permalink
added parameters in path when missing
Browse files Browse the repository at this point in the history
  • Loading branch information
Mario.RuizSanchez committed Feb 1, 2019
1 parent 6cd585e commit eccc57b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
12 changes: 12 additions & 0 deletions lib/open_api_import.rb
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,18 @@ def self.from(swagger_file, create_method_name: :operation_id, include_responses
output << description_parameters
end

#for the case we still have some parameters on path that were not in 'parameters'
if path_txt.match?(/[^#]{\w+}/)
paramst = []
prms = path_txt.scan(/[^#]{(\w+)}/)
prms.each do |p|
paramst<<p[0].to_s.snake_case
path_txt.gsub!("{#{p[0]}}", "\#{#{p[0].to_s.snake_case}}")
end
paramst.concat params
params = paramst
end
output << "def self.#{method_name} (#{params.join(", ")})"
output << "{"
Expand Down
2 changes: 1 addition & 1 deletion open_api_import.gemspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Gem::Specification.new do |s|
s.name = 'open_api_import'
s.version = '0.1.0'
s.version = '0.2.0'
s.summary = "OpenApiImport -- Import a Swagger or Open API file and create a Ruby Request Hash file including all requests and responses with all the examples. The file can be in JSON or YAML"
s.description = "OpenApiImport -- Import a Swagger or Open API file and create a Ruby Request Hash file including all requests and responses with all the examples. The file can be in JSON or YAML"
s.authors = ["Mario Ruiz"]
Expand Down

0 comments on commit eccc57b

Please sign in to comment.