grape-swagger 1.0.0 → 1.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +94 -1
  3. data/.rubocop_todo.yml +1 -1
  4. data/.travis.yml +14 -8
  5. data/CHANGELOG.md +56 -6
  6. data/Gemfile +9 -4
  7. data/README.md +191 -12
  8. data/UPGRADING.md +34 -0
  9. data/grape-swagger.gemspec +1 -1
  10. data/lib/grape-swagger.rb +7 -4
  11. data/lib/grape-swagger/doc_methods.rb +65 -62
  12. data/lib/grape-swagger/doc_methods/build_model_definition.rb +53 -2
  13. data/lib/grape-swagger/doc_methods/data_type.rb +5 -5
  14. data/lib/grape-swagger/doc_methods/format_data.rb +2 -2
  15. data/lib/grape-swagger/doc_methods/operation_id.rb +2 -2
  16. data/lib/grape-swagger/doc_methods/parse_params.rb +19 -4
  17. data/lib/grape-swagger/endpoint.rb +73 -31
  18. data/lib/grape-swagger/rake/oapi_tasks.rb +12 -2
  19. data/lib/grape-swagger/version.rb +1 -1
  20. data/spec/issues/427_entity_as_string_spec.rb +1 -1
  21. data/spec/issues/430_entity_definitions_spec.rb +7 -5
  22. data/spec/issues/537_enum_values_spec.rb +1 -0
  23. data/spec/issues/776_multiple_presents_spec.rb +56 -0
  24. data/spec/issues/784_extensions_on_params_spec.rb +38 -0
  25. data/spec/issues/809_utf8_routes_spec.rb +55 -0
  26. data/spec/lib/data_type_spec.rb +12 -0
  27. data/spec/lib/move_params_spec.rb +2 -2
  28. data/spec/lib/oapi_tasks_spec.rb +15 -5
  29. data/spec/support/empty_model_parser.rb +1 -2
  30. data/spec/support/mock_parser.rb +1 -2
  31. data/spec/support/model_parsers/entity_parser.rb +8 -8
  32. data/spec/support/model_parsers/mock_parser.rb +8 -8
  33. data/spec/support/model_parsers/representable_parser.rb +8 -8
  34. data/spec/support/namespace_tags.rb +1 -0
  35. data/spec/swagger_v2/api_swagger_v2_hide_param_spec.rb +1 -1
  36. data/spec/swagger_v2/api_swagger_v2_mounted_spec.rb +1 -0
  37. data/spec/swagger_v2/api_swagger_v2_param_type_body_spec.rb +2 -2
  38. data/spec/swagger_v2/api_swagger_v2_response_with_models_spec.rb +53 -0
  39. data/spec/swagger_v2/api_swagger_v2_spec.rb +1 -0
  40. data/spec/swagger_v2/boolean_params_spec.rb +1 -0
  41. data/spec/swagger_v2/float_api_spec.rb +1 -0
  42. data/spec/swagger_v2/inheritance_and_discriminator_spec.rb +56 -0
  43. data/spec/swagger_v2/namespace_tags_prefix_spec.rb +1 -0
  44. data/spec/swagger_v2/param_multi_type_spec.rb +2 -0
  45. data/spec/swagger_v2/param_type_spec.rb +3 -0
  46. data/spec/swagger_v2/param_values_spec.rb +6 -0
  47. data/spec/swagger_v2/reference_entity_spec.rb +74 -29
  48. data/spec/swagger_v2/security_requirement_spec.rb +2 -2
  49. data/spec/swagger_v2/simple_mounted_api_spec.rb +1 -0
  50. metadata +19 -9
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a02b298de5d3db8a877e2d19c3a33d926793beea5f6de12f637a142593ebf6cd
4
- data.tar.gz: d794323888e880667ba53916e4b8e028c200910309da26fbbc823c5a1a11f4d9
3
+ metadata.gz: 1d9d2fa1309701cf2c24f0993db15660df9be1c437861529a321e6344390fc90
4
+ data.tar.gz: 8e74a44fddb127a89ec914da70de6118a86fe17318fb16e4f68d2761cd69dc1c
5
5
  SHA512:
6
- metadata.gz: f52b468dcfc8bb22a52a2b0d3cb9609d9b512c31836c69644dfbfbb63ece456dfa9e0eb3200b54006bda1ebac848bf10538bed4ab7cc92241af19b63c01451e4
7
- data.tar.gz: ccf7750c17e52a0172b5c8d6df101ebad543e9960793267e6d607be4f812e7dd1d6d3fab8cd07919b4bee39dad80c6ac3f79628ece4d4fd45c51314a6cc6049c
6
+ metadata.gz: 79db26518f7697a7347ad92749eaa14722310e41e395177e839d04bfc5e490026989a687158f89f34ea52a62a390482430d79067aa887f4ef90e95bf991315d7
7
+ data.tar.gz: 95e85e0b5d337b53bd4ed260aed3fcaae2acae613fcf337552afe0b4be280da89587351008f1f2054440b61e868804c1710340214d2ad80ca4950439af3f5fbe
@@ -4,11 +4,17 @@ AllCops:
4
4
  Exclude:
5
5
  - vendor/**/*
6
6
  - example/**/*
7
+ NewCops: enable
7
8
  TargetRubyVersion: 2.7
8
9
 
10
+ # Layout stuff
11
+ #
9
12
  Layout/EmptyLinesAroundArguments:
10
13
  Enabled: false
11
14
 
15
+ Layout/EmptyLinesAroundAttributeAccessor:
16
+ Enabled: true
17
+
12
18
  Layout/FirstHashElementIndentation:
13
19
  EnforcedStyle: consistent
14
20
 
@@ -17,19 +23,106 @@ Layout/LineLength:
17
23
  Exclude:
18
24
  - spec/**/*
19
25
 
26
+ Layout/SpaceAroundMethodCallOperator:
27
+ Enabled: true
28
+
29
+ # Lint stuff
30
+ #
31
+ Lint/ConstantDefinitionInBlock:
32
+ Exclude:
33
+ - spec/**/*
34
+
35
+ Lint/DeprecatedOpenSSLConstant:
36
+ Enabled: true
37
+
38
+ Lint/DuplicateElsifCondition:
39
+ Enabled: true
40
+
41
+ Lint/MixedRegexpCaptureTypes:
42
+ Enabled: true
43
+
44
+ Lint/RaiseException:
45
+ Enabled: true
46
+
47
+ Lint/StructNewOverride:
48
+ Enabled: true
49
+
50
+ # Metrics stuff
51
+ #
20
52
  Metrics/BlockLength:
21
53
  Exclude:
22
54
  - spec/**/*
23
55
 
24
56
  Metrics/ClassLength:
25
- Max: 300
57
+ Max: 350
58
+
59
+ Metrics/CyclomaticComplexity:
60
+ Max: 17
26
61
 
27
62
  Metrics/MethodLength:
28
63
  Exclude:
29
64
  - spec/**/*
30
65
 
66
+ # Naming stuff
67
+ #
31
68
  Naming:
32
69
  Enabled: false
33
70
 
71
+ # Style stuff
72
+ #
73
+ Style/AccessorGrouping:
74
+ Enabled: true
75
+
76
+ Style/AsciiComments:
77
+ Enabled: false
78
+
79
+ Style/ArrayCoercion:
80
+ Enabled: true
81
+
82
+ Style/BisectedAttrAccessor:
83
+ Enabled: true
84
+
85
+ Style/CaseLikeIf:
86
+ Enabled: true
87
+
88
+ Style/ExponentialNotation:
89
+ Enabled: true
90
+
91
+ Style/ExplicitBlockArgument:
92
+ Enabled: false
93
+
94
+ Style/HashAsLastArrayItem:
95
+ Enabled: true
96
+
97
+ Style/HashEachMethods:
98
+ Enabled: true
99
+
100
+ Style/HashLikeCase:
101
+ Enabled: true
102
+
103
+ Style/HashTransformKeys:
104
+ Enabled: true
105
+
106
+ Style/HashTransformValues:
107
+ Enabled: true
108
+
34
109
  Style/RegexpLiteral:
35
110
  Enabled: false
111
+
112
+ Style/RedundantAssignment:
113
+ Enabled: true
114
+
115
+ Style/RedundantFetchBlock:
116
+ Enabled: true
117
+
118
+ Style/RedundantFileExtensionInRequire:
119
+ Enabled: true
120
+
121
+ Style/RedundantRegexpCharacterClass:
122
+ Enabled: true
123
+
124
+ Style/RedundantRegexpEscape:
125
+ Enabled: true
126
+
127
+ Style/SlicingWithRange:
128
+ Enabled: false
@@ -28,7 +28,7 @@ Metrics/MethodLength:
28
28
 
29
29
  # Offense count: 7
30
30
  Metrics/PerceivedComplexity:
31
- Max: 14
31
+ Max: 16
32
32
 
33
33
  # Offense count: 3
34
34
  Style/ClassVars:
@@ -9,27 +9,33 @@ after_success:
9
9
  - bundle exec danger
10
10
 
11
11
  rvm:
12
- - 2.5.7
13
- - 2.6.5
14
- - 2.7.0
12
+ - 2.5.8
13
+ - 2.6.6
14
+ - 2.7.2
15
15
  env:
16
- - GRAPE_VERSION=1.3.0 MODEL_PARSER=grape-swagger-entity
17
- - GRAPE_VERSION=1.3.0 MODEL_PARSER=grape-swagger-representable
18
- - GRAPE_VERSION=1.3.0
16
+ - GRAPE_VERSION=1.3.3
17
+ - GRAPE_VERSION=1.4.0
18
+ - GRAPE_VERSION=1.5.0 MODEL_PARSER=grape-swagger-entity
19
+ - GRAPE_VERSION=1.5.0 MODEL_PARSER=grape-swagger-representable
20
+ - GRAPE_VERSION=1.5.0
19
21
  - GRAPE_VERSION=HEAD
20
22
 
21
23
  jobs:
22
24
  fast_finish: true
23
25
 
24
26
  include:
25
- - rvm: 2.4.9
27
+ - rvm: 2.4.10
26
28
  env:
27
29
  - rvm: ruby-head
28
30
  env:
29
31
  - rvm: jruby-head
30
32
  env:
33
+ - rvm: truffleruby-head
34
+ env:
35
+ script: bundle exec rake spec
31
36
 
32
37
  allow_failures:
33
- - rvm: 2.4.9
38
+ - rvm: 2.4.10
34
39
  - rvm: ruby-head
35
40
  - rvm: jruby-head
41
+ - rvm: truffleruby-head
@@ -3,13 +3,67 @@
3
3
  #### Features
4
4
 
5
5
  * Your contribution here.
6
- * [#777](https://github.com/ruby-grape/grape-swagger/pull/777): Make usage of grape >= 1.3, rack >= 2.1 - [@LeFnord](https://github.com/LeFnord).
7
- * [#775](https://github.com/ruby-grape/grape-swagger/pull/775): Add in token_owner support to param hidden procs - [@urkle](https://github.com/urkle).
8
6
 
9
7
  #### Fixes
10
8
 
11
9
  * Your contribution here.
12
10
 
11
+
12
+ ### 1.3.1 (November 1, 2020)
13
+
14
+ #### Features
15
+
16
+ * [#813](https://github.com/ruby-grape/grape-swagger/pull/813): Handle multiple presents - [@AntoineGuestin](https://github.com/AntoineGuestin).
17
+
18
+ #### Fixes
19
+
20
+ * [#811](https://github.com/ruby-grape/grape-swagger/pull/811): Fixes #809: supports utf8 route names - [@LeFnord](https://github.com/LeFnord).
21
+
22
+
23
+ ### 1.3.0 (September 3, 2020)
24
+
25
+ #### Features
26
+
27
+ * [#804](https://github.com/ruby-grape/grape-swagger/pull/804): Don't overwrite model description with the route description - [@Bhacaz](https://github.com/Bhacaz).
28
+
29
+
30
+ ### 1.2.1 (July 15, 2020)
31
+
32
+ #### Fixes
33
+
34
+ * [#801](https://github.com/ruby-grape/grape-swagger/pull/801): Fixes behaviour after grape upgrade to 1.4.0 - [@LeFnord](https://github.com/LeFnord).
35
+
36
+
37
+ ### 1.2.0 (July 1, 2020)
38
+
39
+ #### Features
40
+
41
+ * [#794](https://github.com/ruby-grape/grape-swagger/pull/794): Allow `entity_name` to be inherited, fixes issue #659 - [@urkle](https://github.com/urkle).
42
+ * [#793](https://github.com/ruby-grape/grape-swagger/pull/793): Features/inheritance and discriminator - [@MaximeRDY](https://github.com/MaximeRDY).
43
+
44
+ #### Fixes
45
+
46
+ * [#798](https://github.com/ruby-grape/grape-swagger/pull/798): Modify full entity name separator - [@GarrettB71](https://github.com/GarrettB71).
47
+ * [#796](https://github.com/ruby-grape/grape-swagger/pull/796): Support grape 1.4.0 - [@thedanielhanke](https://github.com/thedanielhanke).
48
+
49
+
50
+ ### 1.1.0 (April 20, 2020)
51
+
52
+ #### Features
53
+
54
+ * [#785](https://github.com/ruby-grape/grape-swagger/pull/785): Add extensions for params - [@MaximeRDY](https://github.com/MaximeRDY).
55
+ * [#782](https://github.com/ruby-grape/grape-swagger/pull/782): Allow passing class name as string for rake task initializer - [@misdoro](https://github.com/misdoro).
56
+ * [#786](https://github.com/ruby-grape/grape-swagger/pull/786): Use full entity name as a default - [@mrexox](https://github.com/mrexox).
57
+
58
+
59
+ ### 1.0.0 (February 10, 2020)
60
+
61
+ #### Features
62
+
63
+ * [#777](https://github.com/ruby-grape/grape-swagger/pull/777): Make usage of grape >= 1.3, rack >= 2.1 - [@LeFnord](https://github.com/LeFnord).
64
+ * [#775](https://github.com/ruby-grape/grape-swagger/pull/775): Add in token_owner support to param hidden procs - [@urkle](https://github.com/urkle).
65
+
66
+
13
67
  ### 0.34.2 (January 20, 2020)
14
68
 
15
69
  #### Fixes
@@ -42,10 +96,6 @@
42
96
  * [#743](https://github.com/ruby-grape/grape-swagger/pull/743): CI: use 2.4.6, 2.5.5 - [@olleolleolle](https://github.com/olleolleolle).
43
97
  * [#737](https://github.com/ruby-grape/grape-swagger/pull/737): Add swagger endpoint guard to both doc endpoints - [@urkle](https://github.com/urkle).
44
98
 
45
- #### Changes
46
-
47
- * [#749](https://github.com/ruby-grape/grape-swagger/pull/749) Drop support for Ruby 2.3 and below - [@LeFnord](https://github.com/LeFnord).
48
-
49
99
 
50
100
  ### 0.32.1 (December 7, 2018)
51
101
 
data/Gemfile CHANGED
@@ -6,7 +6,7 @@ ruby RUBY_VERSION
6
6
 
7
7
  gemspec
8
8
 
9
- gem 'grape', case version = ENV['GRAPE_VERSION'] || '>= 1.3.0'
9
+ gem 'grape', case version = ENV['GRAPE_VERSION'] || '>= 1.5.0'
10
10
  when 'HEAD'
11
11
  { git: 'https://github.com/ruby-grape/grape' }
12
12
  else
@@ -14,24 +14,29 @@ gem 'grape', case version = ENV['GRAPE_VERSION'] || '>= 1.3.0'
14
14
  end
15
15
 
16
16
  gem ENV['MODEL_PARSER'] if ENV.key?('MODEL_PARSER')
17
+
17
18
  group :development, :test do
18
19
  gem 'bundler'
19
20
  gem 'grape-entity'
20
21
  gem 'pry', platforms: [:mri]
21
22
  gem 'pry-byebug', platforms: [:mri]
22
23
 
23
- gem 'rack', '~> 2.1'
24
+ gem 'rack', '~> 2.2'
24
25
  gem 'rack-cors'
25
26
  gem 'rack-test'
26
27
  gem 'rake'
27
28
  gem 'rdoc'
28
29
  gem 'rspec', '~> 3.9'
29
- gem 'rubocop', '~> 0.79', require: false
30
+ gem 'rubocop', '~> 1.0', require: false
30
31
  end
31
32
 
32
33
  group :test do
33
34
  gem 'coveralls_reborn', require: false
34
- gem 'grape-swagger-entity'
35
+
35
36
  gem 'ruby-grape-danger', '~> 0.1.1', require: false
36
37
  gem 'simplecov', require: false
38
+
39
+ unless ENV['MODEL_PARSER'] == 'grape-swagger-entity'
40
+ gem 'grape-swagger-entity', git: 'https://github.com/ruby-grape/grape-swagger-entity'
41
+ end
37
42
  end
data/README.md CHANGED
@@ -43,16 +43,16 @@ This screenshot is based on the [Hussars](https://github.com/LeFnord/hussars) sa
43
43
 
44
44
  The following versions of grape, grape-entity and grape-swagger can currently be used together.
45
45
 
46
- grape-swagger | swagger spec | grape | grape-entity | representable |
47
- --------------|--------------|-------------------------|--------------|---------------|
48
- 0.10.5 | 1.2 | >= 0.10.0 ... <= 0.14.0 | < 0.5.0 | n/a |
49
- 0.11.0 | 1.2 | >= 0.16.2 | < 0.5.0 | n/a |
50
- 0.25.2 | 2.0 | >= 0.14.0 ... <= 0.18.0 | <= 0.6.0 | >= 2.4.1 |
51
- 0.26.0 | 2.0 | >= 0.16.2 ... <= 1.1.0 | <= 0.6.1 | >= 2.4.1 |
52
- 0.27.0 | 2.0 | >= 0.16.2 ... <= 1.1.0 | >= 0.5.0 | >= 2.4.1 |
53
- 0.32.0 | 2.0 | >= 0.16.2 | >= 0.5.0 | >= 2.4.1 |
54
- 0.34.0 | 2.0 | >= 0.16.2 ... < 1.3.0 | >= 0.5.0 | >= 2.4.1 |
55
- 1.0.0 | 2.0 | >= 1.3.0 | >= 0.5.0 | >= 2.4.1 |
46
+ | grape-swagger | swagger spec | grape | grape-entity | representable |
47
+ | ------------- | ------------ | ----------------------- | ------------ | ------------- |
48
+ | 0.10.5 | 1.2 | >= 0.10.0 ... <= 0.14.0 | < 0.5.0 | n/a |
49
+ | 0.11.0 | 1.2 | >= 0.16.2 | < 0.5.0 | n/a |
50
+ | 0.25.2 | 2.0 | >= 0.14.0 ... <= 0.18.0 | <= 0.6.0 | >= 2.4.1 |
51
+ | 0.26.0 | 2.0 | >= 0.16.2 ... <= 1.1.0 | <= 0.6.1 | >= 2.4.1 |
52
+ | 0.27.0 | 2.0 | >= 0.16.2 ... <= 1.1.0 | >= 0.5.0 | >= 2.4.1 |
53
+ | 0.32.0 | 2.0 | >= 0.16.2 | >= 0.5.0 | >= 2.4.1 |
54
+ | 0.34.0 | 2.0 | >= 0.16.2 ... < 1.3.0 | >= 0.5.0 | >= 2.4.1 |
55
+ | >= 1.0.0 | 2.0 | >= 1.3.0 | >= 0.5.0 | >= 2.4.1 |
56
56
 
57
57
 
58
58
  ## Swagger-Spec <a name="swagger-spec"></a>
@@ -458,6 +458,7 @@ add_swagger_documentation \
458
458
  * [Response examples documentation](#response-examples)
459
459
  * [Response headers documentation](#response-headers)
460
460
  * [Adding root element to responses](#response-root)
461
+ * [Multiple present Response](#multiple-response)
461
462
 
462
463
  #### Swagger Header Parameters <a name="headers"></a>
463
464
 
@@ -859,10 +860,11 @@ get '/thing', failure: [
859
860
  end
860
861
  ```
861
862
 
862
- By adding a `model` key, e.g. this would be taken.
863
+ By adding a `model` key, e.g. this would be taken. Setting an empty string will act like an empty body.
863
864
  ```ruby
864
865
  get '/thing', failure: [
865
866
  { code: 400, message: 'General error' },
867
+ { code: 403, message: 'Forbidden error', model: '' },
866
868
  { code: 422, message: 'Invalid parameter entry', model: Entities::ApiError }
867
869
  ] do
868
870
  # ...
@@ -1084,6 +1086,20 @@ or, for more definitions:
1084
1086
  route_setting :x_def, [{ for: 422, other: 'stuff' }, { for: 200, some: 'stuff' }]
1085
1087
  ```
1086
1088
 
1089
+ - `params` extension, add a `x` key to the `documentation` hash :
1090
+ ```ruby
1091
+ requires :foo, type: String, documentation: { x: { some: 'stuff' } }
1092
+ ```
1093
+ this would generate:
1094
+ ```json
1095
+ {
1096
+ "in": "formData",
1097
+ "name": "foo",
1098
+ "type": "string",
1099
+ "required": true,
1100
+ "x-some": "stuff"
1101
+ }
1102
+ ```
1087
1103
 
1088
1104
  #### Response examples documentation <a name="response-examples"></a>
1089
1105
 
@@ -1247,6 +1263,75 @@ The result will look like following:
1247
1263
  }
1248
1264
  }
1249
1265
  ```
1266
+ #### Multiple present Response <a name="multiple-response"></a>
1267
+
1268
+ You can specify a custom multiple response by using the `as` key:
1269
+ ```ruby
1270
+ desc 'Multiple response',
1271
+ success: [
1272
+ { model: Entities::EnumValues, as: :gender },
1273
+ { model: Entities::Something, as: :somethings }
1274
+ ]
1275
+ end
1276
+
1277
+ get '/things' do
1278
+ ...
1279
+ end
1280
+ ```
1281
+ The result will look like following:
1282
+ ```
1283
+ "responses": {
1284
+ "200": {
1285
+ "description": "Multiple response",
1286
+ "schema":{
1287
+ "type":"object",
1288
+ "properties":{
1289
+ "gender":{
1290
+ "$ref":"#/definitions/EnumValues"
1291
+ },
1292
+ "somethings":{
1293
+ "$ref":"#/definitions/Something"
1294
+ }
1295
+ }
1296
+ }
1297
+ }
1298
+ }
1299
+ ```
1300
+ You can also specify if the response is an array, with the `is_array` key:
1301
+ ```ruby
1302
+ desc 'Multiple response with array',
1303
+ success: [
1304
+ { model: Entities::EnumValues, as: :gender },
1305
+ { model: Entities::Something, as: :somethings, is_array: true }
1306
+ ]
1307
+ end
1308
+
1309
+ get '/things' do
1310
+ ...
1311
+ end
1312
+ ```
1313
+ The result will look like following:
1314
+ ```
1315
+ "responses": {
1316
+ "200": {
1317
+ "description": "Multiple response with array",
1318
+ "schema":{
1319
+ "type":"object",
1320
+ "properties":{
1321
+ "gender":{
1322
+ "$ref":"#/definitions/EnumValues"
1323
+ },
1324
+ "somethings":{
1325
+ "type":"array",
1326
+ "items":{
1327
+ "$ref":"#/definitions/Something"
1328
+ }
1329
+ }
1330
+ }
1331
+ }
1332
+ }
1333
+ }
1334
+ ```
1250
1335
 
1251
1336
  ## Using Grape Entities <a name="grape-entity"></a>
1252
1337
 
@@ -1367,6 +1452,94 @@ module API
1367
1452
  end
1368
1453
  ```
1369
1454
 
1455
+ #### Inheritance with allOf and discriminator
1456
+ ```ruby
1457
+ module Entities
1458
+ class Pet < Grape::Entity
1459
+ expose :type, documentation: {
1460
+ type: 'string',
1461
+ is_discriminator: true,
1462
+ required: true
1463
+ }
1464
+ expose :name, documentation: {
1465
+ type: 'string',
1466
+ required: true
1467
+ }
1468
+ end
1469
+
1470
+ class Cat < Pet
1471
+ expose :huntingSkill, documentation: {
1472
+ type: 'string',
1473
+ description: 'The measured skill for hunting',
1474
+ default: 'lazy',
1475
+ values: %w[
1476
+ clueless
1477
+ lazy
1478
+ adventurous
1479
+ aggressive
1480
+ ]
1481
+ }
1482
+ end
1483
+ end
1484
+ ```
1485
+
1486
+ Should generate this definitions:
1487
+ ```JSON
1488
+ {
1489
+ "definitions": {
1490
+ "Pet": {
1491
+ "type": "object",
1492
+ "discriminator": "petType",
1493
+ "properties": {
1494
+ "name": {
1495
+ "type": "string"
1496
+ },
1497
+ "petType": {
1498
+ "type": "string"
1499
+ }
1500
+ },
1501
+ "required": [
1502
+ "name",
1503
+ "petType"
1504
+ ]
1505
+ },
1506
+ "Cat": {
1507
+ "description": "A representation of a cat",
1508
+ "allOf": [
1509
+ {
1510
+ "$ref": "#/definitions/Pet"
1511
+ },
1512
+ {
1513
+ "type": "object",
1514
+ "properties": {
1515
+ "huntingSkill": {
1516
+ "type": "string",
1517
+ "description": "The measured skill for hunting",
1518
+ "default": "lazy",
1519
+ "enum": [
1520
+ "clueless",
1521
+ "lazy",
1522
+ "adventurous",
1523
+ "aggressive"
1524
+ ]
1525
+ },
1526
+ "petType": {
1527
+ "type": "string",
1528
+ "enum": ["Cat"]
1529
+ }
1530
+ },
1531
+ "required": [
1532
+ "huntingSkill",
1533
+ "petType"
1534
+ ]
1535
+ }
1536
+ ]
1537
+ }
1538
+ }
1539
+ }
1540
+ ```
1541
+
1542
+
1370
1543
 
1371
1544
 
1372
1545
  ## Securing the Swagger UI <a name="oauth"></a>
@@ -1486,13 +1659,19 @@ end
1486
1659
 
1487
1660
  ## Rake Tasks <a name="rake"></a>
1488
1661
 
1489
- Add these lines to your Rakefile, and initialize the Task class with your Api class – be sure your Api class is available.
1662
+ Add these lines to your Rakefile, and initialize the Task class with your Api class.
1490
1663
 
1491
1664
  ```ruby
1492
1665
  require 'grape-swagger/rake/oapi_tasks'
1493
1666
  GrapeSwagger::Rake::OapiTasks.new(::Api::Base)
1494
1667
  ```
1495
1668
 
1669
+ You may initialize with the class name as a string if the class is not yet loaded at the time Rakefile is parsed:
1670
+ ```ruby
1671
+ require 'grape-swagger/rake/oapi_tasks'
1672
+ GrapeSwagger::Rake::OapiTasks.new('::Api::Base')
1673
+ ```
1674
+
1496
1675
  #### OpenApi/Swagger Documentation
1497
1676
 
1498
1677
  ```