open_api_import 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/open_api_import.rb +31 -12
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1a8f63ba6acbf1d3734f2e0e3b6df8edec9030a5ede1e14414dad974a1c3fab3
4
- data.tar.gz: e4ef52b2d0f5cd2830951b8b1ffdf9843b2140c8b8da518bfbcdb5f345f7bb62
3
+ metadata.gz: 1785c2aeaa1f0211104cf19f3a827f95f001787ec6d96133ad74fec3651b617d
4
+ data.tar.gz: c28a8aa99ec9b3f98c0aebe9335ca4366418ec80f25bdedd4563cfb4d0be31dd
5
5
  SHA512:
6
- metadata.gz: 5a35275273edc44be3dad32e73b90e0cf09d37612b91ac81a05e1c5be99f2d62ee1ff94f14861c9ab095ed44a2b6af48bf687a48f0ef126cf583bed17aab22d6
7
- data.tar.gz: 9546b16e8f880e8b2678e591b917b593e2c69f2281dc540621e64c9b7222ec22b61a5d9345338390b7f1f39056d5263e181c4c8d62c6a9ee9d0ba5d70052ff24
6
+ metadata.gz: 86bc8c53a3932521a9245b386baafdf384171ac546a6306ac3b745014a6b633de8eb485f2498c88748edb7280316771fa42f853443406fac90adfe82bee5208c
7
+ data.tar.gz: 0bb4013a8dc30bbec7132dcbda4dbb64a33c218573caa29090d0107bbe26f0000f3aa0171a4bbfb27e56eb596cccf17f0746f69dddb5337af62a7b2466730b0e
@@ -113,6 +113,7 @@ class OpenApiImport
113
113
  params = []
114
114
  params_path = []
115
115
  params_query = []
116
+ params_required = []
116
117
  description_parameters = []
117
118
  data_required = []
118
119
  data_read_only = []
@@ -211,19 +212,23 @@ class OpenApiImport
211
212
  cont[:parameters].each do |p|
212
213
  if p[:in] == "path"
213
214
  if create_method_name == :operationId
214
- params_path << p[:name]
215
- path_txt.gsub!("{#{p[:name]}}", "\#{#{p[:name]}}")
215
+ param_name = p[:name]
216
+ path_txt.gsub!("{#{param_name}}", "\#{#{param_name}}")
216
217
  else
217
- params_path << p[:name].to_s.snake_case
218
- path_txt.gsub!("{#{p[:name]}}", "\#{#{p[:name].to_s.snake_case}}")
218
+ param_name = p[:name].to_s.snake_case
219
+ path_txt.gsub!("{#{p[:name]}}", "\#{#{param_name}}")
219
220
  end
221
+ params_path << param_name
222
+ #params_required << param_name if p[:required].to_s=="true"
223
+
220
224
  if p.keys.include?(:description)
221
- description_parameters << "# #{p[:name]}: (#{p[:type]}) #{p[:description]}"
225
+ description_parameters << "# #{p[:name]}: (#{p[:type]}) #{"(required)" if p[:required].to_s=="true"} #{p[:description]}"
222
226
  end
223
227
  elsif p[:in] == "query"
224
228
  params_query << p[:name]
229
+ params_required << p[:name] if p[:required].to_s=="true"
225
230
  if p.keys.include?(:description)
226
- description_parameters << "# #{p[:name]}: (#{p[:type]}) #{p[:description]}"
231
+ description_parameters << "# #{p[:name]}: (#{p[:type]}) #{"(required)" if p[:required].to_s=="true"} #{p[:description]}"
227
232
  end
228
233
  elsif p[:in] == "body"
229
234
  if p.keys.include?(:schema)
@@ -294,13 +299,27 @@ class OpenApiImport
294
299
 
295
300
  unless params_query.empty?
296
301
  path_txt += "?"
302
+ params_required.each do |pr|
303
+ if params_query.include?(pr)
304
+ if create_method_name == :operationId
305
+ path_txt += "#{pr}=\#{#{pr}}&"
306
+ params << "#{pr}"
307
+ else
308
+ path_txt += "#{pr}=\#{#{pr.to_s.snake_case}}&"
309
+ params << "#{pr.to_s.snake_case}"
310
+ end
311
+
312
+ end
313
+ end
297
314
  params_query.each do |pq|
298
- if create_method_name == :operationId
299
- path_txt += "#{pq}=\#{#{pq}}&"
300
- params << "#{pq}: ''"
301
- else
302
- path_txt += "#{pq}=\#{#{pq.to_s.snake_case}}&"
303
- params << "#{pq.to_s.snake_case}: ''"
315
+ unless params_required.include?(pq)
316
+ if create_method_name == :operationId
317
+ path_txt += "#{pq}=\#{#{pq}}&"
318
+ params << "#{pq}: ''"
319
+ else
320
+ path_txt += "#{pq}=\#{#{pq.to_s.snake_case}}&"
321
+ params << "#{pq.to_s.snake_case}: ''"
322
+ end
304
323
  end
305
324
  end
306
325
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: open_api_import
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mario Ruiz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-02-01 00:00:00.000000000 Z
11
+ date: 2019-02-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: oas_parser