grape-swagger 0.33.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +7 -7
  3. data/.rubocop_todo.yml +0 -6
  4. data/.travis.yml +11 -10
  5. data/CHANGELOG.md +75 -5
  6. data/Gemfile +5 -5
  7. data/README.md +73 -5
  8. data/grape-swagger.gemspec +1 -1
  9. data/lib/grape-swagger/doc_methods/build_model_definition.rb +0 -17
  10. data/lib/grape-swagger/doc_methods/data_type.rb +1 -1
  11. data/lib/grape-swagger/doc_methods/extensions.rb +6 -1
  12. data/lib/grape-swagger/doc_methods/format_data.rb +51 -0
  13. data/lib/grape-swagger/doc_methods/move_params.rb +22 -49
  14. data/lib/grape-swagger/doc_methods/parse_params.rb +6 -0
  15. data/lib/grape-swagger/doc_methods.rb +2 -0
  16. data/lib/grape-swagger/endpoint/params_parser.rb +22 -22
  17. data/lib/grape-swagger/endpoint.rb +33 -14
  18. data/lib/grape-swagger/version.rb +1 -1
  19. data/lib/grape-swagger.rb +1 -1
  20. data/spec/issues/751_deeply_nested_objects_spec.rb +190 -0
  21. data/spec/lib/data_type_spec.rb +2 -2
  22. data/spec/lib/endpoint/params_parser_spec.rb +46 -21
  23. data/spec/lib/endpoint_spec.rb +4 -4
  24. data/spec/lib/extensions_spec.rb +10 -0
  25. data/spec/lib/format_data_spec.rb +91 -0
  26. data/spec/lib/move_params_spec.rb +4 -266
  27. data/spec/lib/optional_object_spec.rb +0 -1
  28. data/spec/spec_helper.rb +1 -1
  29. data/spec/support/model_parsers/entity_parser.rb +1 -1
  30. data/spec/support/model_parsers/representable_parser.rb +1 -1
  31. data/spec/swagger_v2/api_swagger_v2_hash_and_array_spec.rb +3 -1
  32. data/spec/swagger_v2/api_swagger_v2_hide_param_spec.rb +14 -3
  33. data/spec/swagger_v2/api_swagger_v2_response_with_root_spec.rb +153 -0
  34. data/spec/swagger_v2/boolean_params_spec.rb +1 -1
  35. data/spec/swagger_v2/description_not_initialized_spec.rb +39 -0
  36. data/spec/swagger_v2/endpoint_versioned_path_spec.rb +33 -0
  37. data/spec/swagger_v2/mounted_target_class_spec.rb +1 -1
  38. data/spec/swagger_v2/namespace_tags_prefix_spec.rb +15 -1
  39. data/spec/swagger_v2/params_array_spec.rb +2 -2
  40. data/spec/swagger_v2/parent_less_namespace_spec.rb +32 -0
  41. data/spec/swagger_v2/{reference_entity.rb → reference_entity_spec.rb} +17 -10
  42. metadata +20 -13
  43. data/spec/swagger_v2/description_not_initialized.rb +0 -39
  44. data/spec/swagger_v2/parent_less_namespace.rb +0 -49
@@ -5,8 +5,9 @@ require 'spec_helper'
5
5
  describe GrapeSwagger::Endpoint::ParamsParser do
6
6
  let(:settings) { {} }
7
7
  let(:params) { [] }
8
+ let(:endpoint) { nil }
8
9
 
9
- let(:parser) { described_class.new(params, settings) }
10
+ let(:parser) { described_class.new(params, settings, endpoint) }
10
11
 
11
12
  describe '#parse_request_params' do
12
13
  subject(:parse_request_params) { parser.parse_request_params }
@@ -46,39 +47,63 @@ describe GrapeSwagger::Endpoint::ParamsParser do
46
47
  context 'when param is nested in a param of array type' do
47
48
  let(:params) { [['param_1', { type: 'Array' }], ['param_1[param_2]', { type: 'String' }]] }
48
49
 
49
- it 'skips root parameter' do
50
- is_expected.not_to have_key 'param_1'
51
- end
52
-
53
- it 'adds is_array option to the nested param' do
54
- expect(parse_request_params['param_1[param_2]']).to eq(type: 'String', is_array: true)
55
- end
56
-
57
50
  context 'and array_use_braces setting set to true' do
58
51
  let(:settings) { { array_use_braces: true } }
59
52
 
60
53
  it 'adds braces to the param key' do
61
- expect(parse_request_params.keys.first).to eq 'param_1[][param_2]'
54
+ expect(parse_request_params.keys.last).to eq 'param_1[param_2]'
62
55
  end
63
56
  end
64
57
  end
65
58
 
66
59
  context 'when param is nested in a param of hash type' do
67
- let(:params) { [['param_1', { type: 'Hash' }], ['param_1[param_2]', { type: 'String' }]] }
68
-
69
- it 'skips root parameter' do
70
- is_expected.not_to have_key 'param_1'
71
- end
72
-
73
- it 'does not change options to the nested param' do
74
- expect(parse_request_params['param_1[param_2]']).to eq(type: 'String')
75
- end
60
+ let(:params) { [param_1, param_2] }
61
+ let(:param_1) { ['param_1', { type: 'Hash' }] }
62
+ let(:param_2) { ['param_1[param_2]', { type: 'String' }] }
76
63
 
77
64
  context 'and array_use_braces setting set to true' do
78
65
  let(:settings) { { array_use_braces: true } }
79
66
 
80
- it 'does not add braces to the param key' do
81
- expect(parse_request_params.keys.first).to eq 'param_1[param_2]'
67
+ context 'and param is of simple type' do
68
+ it 'does not add braces to the param key' do
69
+ expect(parse_request_params.keys.last).to eq 'param_1[param_2]'
70
+ end
71
+ end
72
+
73
+ context 'and param is of array type' do
74
+ let(:param_2) { ['param_1[param_2]', { type: 'Array[String]' }] }
75
+
76
+ it 'adds braces to the param key' do
77
+ expect(parse_request_params.keys.last).to eq 'param_1[param_2][]'
78
+ end
79
+
80
+ context 'and `param_type` option is set to body' do
81
+ let(:param_2) do
82
+ ['param_1[param_2]', { type: 'Array[String]', documentation: { param_type: 'body' } }]
83
+ end
84
+
85
+ it 'does not add braces to the param key' do
86
+ expect(parse_request_params.keys.last).to eq 'param_1[param_2]'
87
+ end
88
+ end
89
+
90
+ context 'and `in` option is set to body' do
91
+ let(:param_2) do
92
+ ['param_1[param_2]', { type: 'Array[String]', documentation: { in: 'body' } }]
93
+ end
94
+
95
+ it 'does not add braces to the param key' do
96
+ expect(parse_request_params.keys.last).to eq 'param_1[param_2]'
97
+ end
98
+ end
99
+
100
+ context 'and hash `param_type` option is set to body' do
101
+ let(:param_1) { ['param_1', { type: 'Hash', documentation: { param_type: 'body' } }] }
102
+
103
+ it 'does not add braces to the param key' do
104
+ expect(parse_request_params.keys.last).to eq 'param_1[param_2]'
105
+ end
106
+ end
82
107
  end
83
108
  end
84
109
  end
@@ -49,7 +49,7 @@ describe Grape::Endpoint do
49
49
  describe 'parse_request_params' do
50
50
  let(:subject) { GrapeSwagger::Endpoint::ParamsParser }
51
51
  before do
52
- subject.send(:parse_request_params, params, {})
52
+ subject.send(:parse_request_params, params, {}, nil)
53
53
  end
54
54
 
55
55
  context 'when params do not contain an array' do
@@ -109,7 +109,7 @@ describe Grape::Endpoint do
109
109
  ['id', { required: true, type: 'String' }],
110
110
  ['description', { required: false, type: 'String' }],
111
111
  ['stuffs', { required: true, type: 'Array', is_array: true }],
112
- ['stuffs[id]', { required: true, type: 'String', is_array: true }]
112
+ ['stuffs[id]', { required: true, type: 'String' }]
113
113
  ]
114
114
  end
115
115
 
@@ -138,8 +138,8 @@ describe Grape::Endpoint do
138
138
  ['stuffs', { required: true, type: 'Array', is_array: true }],
139
139
  ['stuffs[owners]', { required: true, type: 'Array', is_array: true }],
140
140
  ['stuffs[creators]', { required: true, type: 'Array', is_array: true }],
141
- ['stuffs[owners][id]', { required: true, type: 'String', is_array: true }],
142
- ['stuffs[creators][id]', { required: true, type: 'String', is_array: true }],
141
+ ['stuffs[owners][id]', { required: true, type: 'String' }],
142
+ ['stuffs[creators][id]', { required: true, type: 'String' }],
143
143
  ['stuffs_and_things', { required: true, type: 'String' }]
144
144
  ]
145
145
  end
@@ -3,6 +3,16 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  describe GrapeSwagger::DocMethods::Extensions do
6
+ context 'it should not break method introspection' do
7
+ describe '.method' do
8
+ describe 'method introspection' do
9
+ specify do
10
+ expect(described_class.method(described_class.methods.first)).to be_a(Method)
11
+ end
12
+ end
13
+ end
14
+ end
15
+
6
16
  describe '#find_definition' do
7
17
  subject { described_class }
8
18
 
@@ -0,0 +1,91 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe GrapeSwagger::DocMethods::FormatData do
6
+ let(:subject) { GrapeSwagger::DocMethods::FormatData }
7
+
8
+ [true, false].each do |array_use_braces|
9
+ context 'when param is nested in a param of array type' do
10
+ let(:braces) { array_use_braces ? '[]' : '' }
11
+ let(:params) do
12
+ [
13
+ { in: 'formData', name: "param1#{braces}", type: 'array', items: { type: 'string' } },
14
+ { in: 'formData', name: 'param1[param2]', type: 'string' }
15
+ ]
16
+ end
17
+
18
+ it 'skips root parameter' do
19
+ expect(subject.to_format(params).first).not_to have_key "param1#{braces}"
20
+ end
21
+
22
+ it 'Move array type to param2' do
23
+ expect(subject.to_format(params).first).to include(name: "param1#{braces}[param2]", type: 'array')
24
+ end
25
+ end
26
+ end
27
+
28
+ context 'when param is nested in a param of hash type' do
29
+ let(:params) { [{ in: 'formData', type: 'object', name: 'param1' }, { in: 'formData', name: 'param1[param2]', type: 'string' }] }
30
+
31
+ it 'skips root parameter' do
32
+ expect(subject.to_format(params).first).not_to have_key 'param1'
33
+ end
34
+
35
+ it 'Move array type to param2' do
36
+ expect(subject.to_format(params).first).to include(name: 'param1[param2]', type: 'string')
37
+ end
38
+ end
39
+
40
+ context 'when params contain a complex array' do
41
+ let(:params) do
42
+ [
43
+ { name: 'id', required: true, type: 'string' },
44
+ { name: 'description', required: false, type: 'string' },
45
+ { name: 'stuffs', required: true, type: 'array' },
46
+ { name: 'stuffs[id]', required: true, type: 'string' }
47
+ ]
48
+ end
49
+
50
+ let(:expected_params) do
51
+ [
52
+ { name: 'id', required: true, type: 'string' },
53
+ { name: 'description', required: false, type: 'string' },
54
+ { name: 'stuffs[id]', required: true, type: 'array', items: { type: 'string' } }
55
+ ]
56
+ end
57
+
58
+ it 'parses params correctly and adds array type all concerned elements' do
59
+ expect(subject.to_format(params)).to eq expected_params
60
+ end
61
+
62
+ context 'when array params are not contiguous with parent array' do
63
+ let(:params) do
64
+ [
65
+ { name: 'id', required: true, type: 'string' },
66
+ { name: 'description', required: false, type: 'string' },
67
+ { name: 'stuffs', required: true, type: 'array' },
68
+ { name: 'stuffs[owners]', required: true, type: 'array' },
69
+ { name: 'stuffs[creators]', required: true, type: 'array' },
70
+ { name: 'stuffs[owners][id]', required: true, type: 'string' },
71
+ { name: 'stuffs[creators][id]', required: true, type: 'string' },
72
+ { name: 'stuffs_and_things', required: true, type: 'string' }
73
+ ]
74
+ end
75
+
76
+ let(:expected_params) do
77
+ [
78
+ { name: 'id', required: true, type: 'string' },
79
+ { name: 'description', required: false, type: 'string' },
80
+ { name: 'stuffs[owners][id]', required: true, type: 'array', items: { type: 'string' } },
81
+ { name: 'stuffs[creators][id]', required: true, type: 'array', items: { type: 'string' } },
82
+ { name: 'stuffs_and_things', required: true, type: 'string' }
83
+ ]
84
+ end
85
+
86
+ it 'parses params correctly and adds array type all concerned elements' do
87
+ expect(subject.to_format(params)).to eq expected_params
88
+ end
89
+ end
90
+ end
91
+ end
@@ -40,13 +40,13 @@ describe GrapeSwagger::DocMethods::MoveParams do
40
40
  describe 'movable params' do
41
41
  specify 'allowed verbs' do
42
42
  allowed_verbs.each do |verb|
43
- expect(subject.can_be_moved?(movable_params, verb)).to be true
43
+ expect(subject.can_be_moved?(verb, movable_params)).to be true
44
44
  end
45
45
  end
46
46
 
47
47
  specify 'not allowed verbs' do
48
48
  not_allowed_verbs.each do |verb|
49
- expect(subject.can_be_moved?(movable_params, verb)).to be false
49
+ expect(subject.can_be_moved?(verb, movable_params)).to be false
50
50
  end
51
51
  end
52
52
  end
@@ -54,13 +54,13 @@ describe GrapeSwagger::DocMethods::MoveParams do
54
54
  describe 'not movable params' do
55
55
  specify 'allowed verbs' do
56
56
  allowed_verbs.each do |verb|
57
- expect(subject.can_be_moved?(not_movable_params, verb)).to be false
57
+ expect(subject.can_be_moved?(verb, not_movable_params)).to be false
58
58
  end
59
59
  end
60
60
 
61
61
  specify 'not allowed verbs' do
62
62
  not_allowed_verbs.each do |verb|
63
- expect(subject.can_be_moved?(not_movable_params, verb)).to be false
63
+ expect(subject.can_be_moved?(verb, not_movable_params)).to be false
64
64
  end
65
65
  end
66
66
  end
@@ -326,268 +326,6 @@ describe GrapeSwagger::DocMethods::MoveParams do
326
326
  end
327
327
  end
328
328
 
329
- describe 'prepare_nested_types' do
330
- before :each do
331
- subject.send(:prepare_nested_types, params)
332
- end
333
-
334
- let(:params) do
335
- [
336
- {
337
- in: 'body',
338
- name: 'address[street_lines]',
339
- description: 'street lines',
340
- type: 'array',
341
- items: {
342
- type: 'string'
343
- },
344
- required: true
345
- }
346
- ]
347
- end
348
-
349
- context 'when params contains nothing with :items key' do
350
- let(:params) do
351
- [
352
- {
353
- in: 'body',
354
- name: 'phone_number',
355
- description: 'phone number',
356
- type: 'string',
357
- required: true
358
- }
359
- ]
360
- end
361
-
362
- let(:expected_params) do
363
- [
364
- {
365
- in: 'body',
366
- name: 'phone_number',
367
- description: 'phone number',
368
- type: 'string',
369
- required: true
370
- }
371
- ]
372
- end
373
-
374
- it 'does nothing' do
375
- expect(params).to eq expected_params
376
- end
377
- end
378
-
379
- context 'when params contains :items key with array type' do
380
- let(:params) do
381
- [
382
- {
383
- in: 'body',
384
- name: 'address_street_lines',
385
- description: 'street lines',
386
- type: 'array',
387
- items: {
388
- type: 'array'
389
- },
390
- required: true
391
- }
392
- ]
393
- end
394
-
395
- let(:expected_params) do
396
- [
397
- {
398
- in: 'body',
399
- name: 'address_street_lines',
400
- description: 'street lines',
401
- type: 'string',
402
- required: true
403
- }
404
- ]
405
- end
406
-
407
- it 'sets type to string and removes :items' do
408
- expect(params).to eq expected_params
409
- end
410
- end
411
-
412
- context 'when params contains :items key with $ref' do
413
- let(:params) do
414
- [
415
- {
416
- in: 'body',
417
- name: 'address_street_lines',
418
- description: 'street lines',
419
- type: 'array',
420
- items: {
421
- '$ref' => '#/definitions/StreetLine'
422
- },
423
- required: true
424
- }
425
- ]
426
- end
427
-
428
- let(:expected_params) do
429
- [
430
- {
431
- in: 'body',
432
- name: 'address_street_lines',
433
- description: 'street lines',
434
- type: 'object',
435
- items: {
436
- '$ref' => '#/definitions/StreetLine'
437
- },
438
- required: true
439
- }
440
- ]
441
- end
442
-
443
- it 'sets type to object and does not remove :items' do
444
- expect(params).to eq expected_params
445
- end
446
- end
447
-
448
- context 'when params contains :items without $ref or array type' do
449
- let(:params) do
450
- [
451
- {
452
- in: 'body',
453
- name: 'address_street_lines',
454
- description: 'street lines',
455
- type: 'array',
456
- items: {
457
- type: 'string'
458
- },
459
- required: true
460
- }
461
- ]
462
- end
463
-
464
- let(:expected_params) do
465
- [
466
- {
467
- in: 'body',
468
- name: 'address_street_lines',
469
- description: 'street lines',
470
- type: 'string',
471
- required: true
472
- }
473
- ]
474
- end
475
-
476
- it 'sets type to :items :type and removes :items' do
477
- expect(params).to eq expected_params
478
- end
479
- end
480
-
481
- context 'when params contains :items key with :format' do
482
- let(:params) do
483
- [
484
- {
485
- in: 'body',
486
- name: 'street_number',
487
- description: 'street number',
488
- type: 'array',
489
- items: {
490
- type: 'integer',
491
- format: 'int32'
492
- },
493
- required: true
494
- }
495
- ]
496
- end
497
-
498
- let(:expected_params) do
499
- [
500
- {
501
- in: 'body',
502
- name: 'street_number',
503
- description: 'street number',
504
- type: 'integer',
505
- format: 'int32',
506
- required: true
507
- }
508
- ]
509
- end
510
-
511
- it 'sets format and removes :items' do
512
- expect(params).to eq expected_params
513
- end
514
- end
515
- end
516
-
517
- describe 'recursive_call' do
518
- before :each do
519
- subject.send(:recursive_call, properties, 'test', nested_params)
520
- end
521
-
522
- let(:properties) { {} }
523
-
524
- context 'when nested params is an array' do
525
- let(:nested_params) do
526
- [
527
- {
528
- in: 'body',
529
- name: 'aliases',
530
- description: 'The aliases of test.',
531
- type: 'array',
532
- items: { type: 'string' },
533
- required: true
534
- }
535
- ]
536
- end
537
-
538
- let(:expected_properties) do
539
- {
540
- type: 'array',
541
- items: {
542
- type: 'object',
543
- properties: {
544
- aliases: {
545
- type: 'string',
546
- description: 'The aliases of test.'
547
- }
548
- },
549
- required: [:aliases]
550
- }
551
- }
552
- end
553
-
554
- it 'adds property as symbol with array type and items' do
555
- expect(properties[:test]).to eq expected_properties
556
- end
557
- end
558
-
559
- context 'when nested params is not an array' do
560
- let(:nested_params) do
561
- [
562
- {
563
- in: 'body',
564
- name: 'id',
565
- description: 'The unique ID of test.',
566
- type: 'string',
567
- required: true
568
- }
569
- ]
570
- end
571
-
572
- let(:expected_properties) do
573
- {
574
- type: 'object',
575
- required: [:id],
576
- properties: {
577
- id: {
578
- type: 'string',
579
- description: 'The unique ID of test.'
580
- }
581
- }
582
- }
583
- end
584
-
585
- it 'adds property as symbol with object type' do
586
- expect(properties[:test]).to eq expected_properties
587
- end
588
- end
589
- end
590
-
591
329
  describe 'add_properties_to_definition' do
592
330
  before :each do
593
331
  subject.send(:add_properties_to_definition, definition, properties, [])
@@ -39,7 +39,6 @@ describe GrapeSwagger::DocMethods::OptionalObject do
39
39
  let(:options) do
40
40
  { host: proc { |request| request.host =~ /^example/ ? '/api-example' : '/api' } }
41
41
  end
42
- # rubocop:enable RegexpMatch
43
42
  specify do
44
43
  expect(subject.build(key, options, request)).to eql '/api-example'
45
44
  end
data/spec/spec_helper.rb CHANGED
@@ -19,7 +19,7 @@ MODEL_PARSER = ENV.key?('MODEL_PARSER') ? ENV['MODEL_PARSER'].to_s.downcase.sub(
19
19
  require 'grape'
20
20
  require 'grape-swagger'
21
21
 
22
- Dir[File.join(Dir.getwd, 'spec/support/*.rb')].each { |f| require f }
22
+ Dir[File.join(Dir.getwd, 'spec/support/*.rb')].sort.each { |f| require f }
23
23
  require "grape-swagger/#{MODEL_PARSER}" if MODEL_PARSER != 'mock'
24
24
  require File.join(Dir.getwd, "spec/support/model_parsers/#{MODEL_PARSER}_parser.rb")
25
25
 
@@ -116,7 +116,7 @@ RSpec.shared_context 'entity swagger example' do
116
116
  expose :prop_time, documentation: { type: Time, desc: 'prop_time description' }
117
117
  expose :prop_password, documentation: { type: 'password', desc: 'prop_password description' }
118
118
  expose :prop_email, documentation: { type: 'email', desc: 'prop_email description' }
119
- expose :prop_boolean, documentation: { type: Virtus::Attribute::Boolean, desc: 'prop_boolean description' }
119
+ expose :prop_boolean, documentation: { type: Grape::API::Boolean, desc: 'prop_boolean description' }
120
120
  expose :prop_file, documentation: { type: File, desc: 'prop_file description' }
121
121
  expose :prop_json, documentation: { type: JSON, desc: 'prop_json description' }
122
122
  end
@@ -186,7 +186,7 @@ RSpec.shared_context 'representable swagger example' do
186
186
  property :prop_time, documentation: { type: Time, desc: 'prop_time description' }
187
187
  property :prop_password, documentation: { type: 'password', desc: 'prop_password description' }
188
188
  property :prop_email, documentation: { type: 'email', desc: 'prop_email description' }
189
- property :prop_boolean, documentation: { type: Virtus::Attribute::Boolean, desc: 'prop_boolean description' }
189
+ property :prop_boolean, documentation: { type: Grape::API::Boolean, desc: 'prop_boolean description' }
190
190
  property :prop_file, documentation: { type: File, desc: 'prop_file description' }
191
191
  property :prop_json, documentation: { type: JSON, desc: 'prop_json description' }
192
192
  end
@@ -10,7 +10,9 @@ describe 'document hash and array' do
10
10
  class TestApi < Grape::API
11
11
  format :json
12
12
 
13
- documentation = ::Entities::DocumentedHashAndArrayModel.documentation if ::Entities::DocumentedHashAndArrayModel.respond_to?(:documentation)
13
+ if ::Entities::DocumentedHashAndArrayModel.respond_to?(:documentation)
14
+ documentation = ::Entities::DocumentedHashAndArrayModel.documentation
15
+ end
14
16
 
15
17
  desc 'This returns something'
16
18
  namespace :arbitrary do
@@ -7,12 +7,19 @@ describe 'hidden flag enables a single endpoint parameter to be excluded from th
7
7
  before :all do
8
8
  module TheApi
9
9
  class HideParamsApi < Grape::API
10
+ helpers do
11
+ def resource_owner
12
+ '123'
13
+ end
14
+ end
15
+
10
16
  namespace :flat_params_endpoint do
11
17
  desc 'This is a endpoint with a flat parameter hierarchy'
12
18
  params do
13
19
  requires :name, type: String, documentation: { desc: 'name' }
14
20
  optional :favourite_color, type: String, documentation: { desc: 'I should not be anywhere', hidden: true }
15
- optional :proc_param, type: String, documentation: { desc: 'I should not be anywhere', hidden: -> { true } }
21
+ optional :proc_param, type: String, documentation: { desc: 'I should not be anywhere', hidden: proc { true } }
22
+ optional :proc_with_token, type: String, documentation: { desc: 'I may be somewhere', hidden: proc { |token_owner = nil| token_owner.nil? } }
16
23
  end
17
24
 
18
25
  post do
@@ -50,7 +57,7 @@ describe 'hidden flag enables a single endpoint parameter to be excluded from th
50
57
  end
51
58
  end
52
59
 
53
- add_swagger_documentation
60
+ add_swagger_documentation token_owner: 'resource_owner'
54
61
  end
55
62
  end
56
63
  end
@@ -63,9 +70,13 @@ describe 'hidden flag enables a single endpoint parameter to be excluded from th
63
70
  JSON.parse(last_response.body)
64
71
  end
65
72
 
66
- specify do
73
+ it 'ignores parameters that are explicitly hidden' do
67
74
  expect(subject['paths']['/flat_params_endpoint']['post']['parameters'].map { |p| p['name'] }).not_to include('favourite_color', 'proc_param')
68
75
  end
76
+
77
+ it 'allows procs to consult the token_owner' do
78
+ expect(subject['paths']['/flat_params_endpoint']['post']['parameters'].map { |p| p['name'] }).to include('proc_with_token')
79
+ end
69
80
  end
70
81
 
71
82
  describe 'nested parameter hierarchy' do