grape-swagger 1.1.0 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/.github/dependabot.yml +14 -0
  3. data/.github/workflows/rubocop.yml +26 -0
  4. data/.github/workflows/ruby.yml +32 -0
  5. data/.rubocop.yml +65 -2
  6. data/.rubocop_todo.yml +1 -1
  7. data/CHANGELOG.md +50 -0
  8. data/Gemfile +8 -3
  9. data/README.md +182 -13
  10. data/UPGRADING.md +34 -0
  11. data/grape-swagger.gemspec +4 -4
  12. data/lib/grape-swagger.rb +7 -4
  13. data/lib/grape-swagger/doc_methods.rb +65 -62
  14. data/lib/grape-swagger/doc_methods/build_model_definition.rb +53 -2
  15. data/lib/grape-swagger/doc_methods/data_type.rb +4 -4
  16. data/lib/grape-swagger/doc_methods/format_data.rb +2 -2
  17. data/lib/grape-swagger/doc_methods/operation_id.rb +2 -2
  18. data/lib/grape-swagger/doc_methods/parse_params.rb +20 -4
  19. data/lib/grape-swagger/endpoint.rb +83 -32
  20. data/lib/grape-swagger/errors.rb +2 -0
  21. data/lib/grape-swagger/model_parsers.rb +2 -2
  22. data/lib/grape-swagger/rake/oapi_tasks.rb +2 -0
  23. data/lib/grape-swagger/version.rb +1 -1
  24. data/spec/issues/427_entity_as_string_spec.rb +1 -1
  25. data/spec/issues/430_entity_definitions_spec.rb +7 -5
  26. data/spec/issues/537_enum_values_spec.rb +1 -0
  27. data/spec/issues/776_multiple_presents_spec.rb +59 -0
  28. data/spec/issues/809_utf8_routes_spec.rb +55 -0
  29. data/spec/lib/data_type_spec.rb +12 -0
  30. data/spec/lib/format_data_spec.rb +24 -0
  31. data/spec/lib/move_params_spec.rb +2 -2
  32. data/spec/spec_helper.rb +1 -1
  33. data/spec/support/empty_model_parser.rb +3 -2
  34. data/spec/support/mock_parser.rb +1 -2
  35. data/spec/support/model_parsers/entity_parser.rb +8 -8
  36. data/spec/support/model_parsers/mock_parser.rb +24 -8
  37. data/spec/support/model_parsers/representable_parser.rb +8 -8
  38. data/spec/support/namespace_tags.rb +3 -0
  39. data/spec/swagger_v2/api_swagger_v2_hide_param_spec.rb +1 -1
  40. data/spec/swagger_v2/api_swagger_v2_mounted_spec.rb +1 -0
  41. data/spec/swagger_v2/api_swagger_v2_param_type_body_spec.rb +2 -2
  42. data/spec/swagger_v2/api_swagger_v2_response_with_headers_spec.rb +4 -2
  43. data/spec/swagger_v2/api_swagger_v2_response_with_models_spec.rb +53 -0
  44. data/spec/swagger_v2/api_swagger_v2_spec.rb +1 -0
  45. data/spec/swagger_v2/boolean_params_spec.rb +1 -0
  46. data/spec/swagger_v2/float_api_spec.rb +1 -0
  47. data/spec/swagger_v2/inheritance_and_discriminator_spec.rb +57 -0
  48. data/spec/swagger_v2/namespace_tags_prefix_spec.rb +1 -0
  49. data/spec/swagger_v2/param_multi_type_spec.rb +2 -0
  50. data/spec/swagger_v2/param_type_spec.rb +3 -0
  51. data/spec/swagger_v2/param_values_spec.rb +6 -0
  52. data/spec/swagger_v2/{params_array_collection_fromat_spec.rb → params_array_collection_format_spec.rb} +0 -0
  53. data/spec/swagger_v2/params_example_spec.rb +40 -0
  54. data/spec/swagger_v2/reference_entity_spec.rb +74 -29
  55. data/spec/swagger_v2/security_requirement_spec.rb +2 -2
  56. data/spec/swagger_v2/simple_mounted_api_spec.rb +3 -0
  57. metadata +27 -13
  58. data/.travis.yml +0 -35
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: beb6baac3bba57a4fd27f01c8129fbd128c0c88426f1408784f1e77ef870c65a
4
- data.tar.gz: 88234909ace085c8b63f0534630ae8856eb15d383bee856c9fcc57079d0060a1
3
+ metadata.gz: 2fa0c33214a157ed16d147edc9813bbb6d745498947d211c2eff21ce86b023a6
4
+ data.tar.gz: 27c475b099a28f9b8610ded30906edf1a974825153348d8d590abba13688f29d
5
5
  SHA512:
6
- metadata.gz: 3b50e2b60fb3d4a1876bac4587f740c27a624c02726153746dc79e76fb1a233d04a3b1b15844bf65a337484d551ac6ea84b04c85c1537138dfc4327149cbb654
7
- data.tar.gz: 32a0e9014bf782a0f5a5417a307bf9325986d7d9df662e73174525792e9103d2a3ec3c4f8b3d7fbdc72829d7514ba299dd62adb361085020f37b104f9a29ee25
6
+ metadata.gz: d01c3d660f905522d943bebf2e5a609231bba1938b0cc02c49908048a691a0f0f1baa184ec2fed63d8a72280a92f3aa208273ce64b2bada90b09725cff71b080
7
+ data.tar.gz: 1316664cfc4ec624311e891cd5c4bc106739bc3be9cb363bac02acccaa5e282a9fc1f9012ca590313fef8b74a5d6930a0afda371c05657b271e5ddfaf9e502d4
@@ -0,0 +1,14 @@
1
+ # To get started with Dependabot version updates, you'll need to specify which
2
+ # package ecosystems to update and where the package manifests are located.
3
+ # Please see the documentation for all configuration options:
4
+ # https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5
+
6
+ version: 2
7
+ updates:
8
+ - package-ecosystem: "bundler" # See documentation for possible values
9
+ directory: "/" # Location of package manifests
10
+ schedule:
11
+ interval: "weekly"
12
+ day: "friday"
13
+ assignees:
14
+ - "LeFnord"
@@ -0,0 +1,26 @@
1
+ name: Rubocop
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - '*'
7
+ pull_request:
8
+ branches:
9
+ - '*'
10
+
11
+ jobs:
12
+ rubocop:
13
+ name: Rubocop
14
+ runs-on: ubuntu-latest
15
+ steps:
16
+ - uses: actions/checkout@v2
17
+ - uses: actions/setup-ruby@v1
18
+ with:
19
+ ruby-version: '3.0'
20
+ - run: gem install rubocop --no-doc
21
+ - run: rubocop --format progress --format json --out rubocop.json
22
+ id: rubocop
23
+ - uses: duderman/rubocop-annotate-action@v0.1.0
24
+ with:
25
+ path: rubocop.json
26
+ if: ${{ failure() }}
@@ -0,0 +1,32 @@
1
+ name: Ruby
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - '*'
7
+ pull_request:
8
+ branches:
9
+ - '*'
10
+
11
+ jobs:
12
+ rspec:
13
+ runs-on: ubuntu-latest
14
+ strategy:
15
+ matrix:
16
+ ruby-version: ['2.6', '2.7', '3.0']
17
+ grape-version: [1.5.3, 1.4.0, 1.3.3]
18
+ model-parser: [grape-swagger-entity, grape-swagger-representable, '']
19
+
20
+ steps:
21
+ - uses: actions/checkout@v2
22
+ - name: Set up Ruby
23
+ uses: ruby/setup-ruby@473e4d8fe5dd94ee328fdfca9f8c9c7afc9dae5e
24
+ with:
25
+ ruby-version: ${{ matrix.ruby-version }}
26
+ GRAPE_VERSION: ${{ matrix.grape-version }}
27
+ MODEL_PARSER: ${{ matrix.model-parser }}
28
+ bundler-cache: true
29
+ - name: Run rspec
30
+ run: bundle exec rspec
31
+ - name: Run rubocop
32
+ run: bundle exec rubocop
data/.rubocop.yml CHANGED
@@ -4,13 +4,18 @@ AllCops:
4
4
  Exclude:
5
5
  - vendor/**/*
6
6
  - example/**/*
7
- TargetRubyVersion: 2.7
7
+ NewCops: enable
8
+ TargetRubyVersion: 3.0
9
+ SuggestExtensions: false
8
10
 
9
11
  # Layout stuff
10
12
  #
11
13
  Layout/EmptyLinesAroundArguments:
12
14
  Enabled: false
13
15
 
16
+ Layout/EmptyLinesAroundAttributeAccessor:
17
+ Enabled: true
18
+
14
19
  Layout/FirstHashElementIndentation:
15
20
  EnforcedStyle: consistent
16
21
 
@@ -24,6 +29,19 @@ Layout/SpaceAroundMethodCallOperator:
24
29
 
25
30
  # Lint stuff
26
31
  #
32
+ Lint/ConstantDefinitionInBlock:
33
+ Exclude:
34
+ - spec/**/*
35
+
36
+ Lint/DeprecatedOpenSSLConstant:
37
+ Enabled: true
38
+
39
+ Lint/DuplicateElsifCondition:
40
+ Enabled: true
41
+
42
+ Lint/MixedRegexpCaptureTypes:
43
+ Enabled: true
44
+
27
45
  Lint/RaiseException:
28
46
  Enabled: true
29
47
 
@@ -37,7 +55,10 @@ Metrics/BlockLength:
37
55
  - spec/**/*
38
56
 
39
57
  Metrics/ClassLength:
40
- Max: 300
58
+ Max: 350
59
+
60
+ Metrics/CyclomaticComplexity:
61
+ Max: 17
41
62
 
42
63
  Metrics/MethodLength:
43
64
  Exclude:
@@ -50,12 +71,36 @@ Naming:
50
71
 
51
72
  # Style stuff
52
73
  #
74
+ Style/AccessorGrouping:
75
+ Enabled: true
76
+
77
+ Style/AsciiComments:
78
+ Enabled: false
79
+
80
+ Style/ArrayCoercion:
81
+ Enabled: true
82
+
83
+ Style/BisectedAttrAccessor:
84
+ Enabled: true
85
+
86
+ Style/CaseLikeIf:
87
+ Enabled: true
88
+
53
89
  Style/ExponentialNotation:
54
90
  Enabled: true
55
91
 
92
+ Style/ExplicitBlockArgument:
93
+ Enabled: false
94
+
95
+ Style/HashAsLastArrayItem:
96
+ Enabled: true
97
+
56
98
  Style/HashEachMethods:
57
99
  Enabled: true
58
100
 
101
+ Style/HashLikeCase:
102
+ Enabled: true
103
+
59
104
  Style/HashTransformKeys:
60
105
  Enabled: true
61
106
 
@@ -64,3 +109,21 @@ Style/HashTransformValues:
64
109
 
65
110
  Style/RegexpLiteral:
66
111
  Enabled: false
112
+
113
+ Style/RedundantAssignment:
114
+ Enabled: true
115
+
116
+ Style/RedundantFetchBlock:
117
+ Enabled: true
118
+
119
+ Style/RedundantFileExtensionInRequire:
120
+ Enabled: true
121
+
122
+ Style/RedundantRegexpCharacterClass:
123
+ Enabled: true
124
+
125
+ Style/RedundantRegexpEscape:
126
+ Enabled: true
127
+
128
+ Style/SlicingWithRange:
129
+ Enabled: false
data/.rubocop_todo.yml CHANGED
@@ -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:
data/CHANGELOG.md CHANGED
@@ -9,6 +9,56 @@
9
9
  * Your contribution here.
10
10
 
11
11
 
12
+ ### 1.4.0 (March 20, 2021)
13
+
14
+ #### Features
15
+
16
+ * [#818](https://github.com/ruby-grape/grape-swagger/pull/818): Adds ruby 3.0 support - [@LeFnord](https://github.com/LeFnord).
17
+ * [#815](https://github.com/ruby-grape/grape-swagger/pull/815): Add required for multiple presents - [@MaximeRDY](https://github.com/MaximeRDY).
18
+
19
+ #### Fixes
20
+
21
+ * [#822](https://github.com/ruby-grape/grape-swagger/pull/822): Corrected the related parameter lookup on request params - [@Jack12816](https://github.com/Jack12816).
22
+
23
+
24
+ ### 1.3.1 (November 1, 2020)
25
+
26
+ #### Features
27
+
28
+ * [#813](https://github.com/ruby-grape/grape-swagger/pull/813): Handle multiple presents - [@AntoineGuestin](https://github.com/AntoineGuestin).
29
+
30
+ #### Fixes
31
+
32
+ * [#811](https://github.com/ruby-grape/grape-swagger/pull/811): Fixes #809: supports utf8 route names - [@LeFnord](https://github.com/LeFnord).
33
+
34
+
35
+ ### 1.3.0 (September 3, 2020)
36
+
37
+ #### Features
38
+
39
+ * [#804](https://github.com/ruby-grape/grape-swagger/pull/804): Don't overwrite model description with the route description - [@Bhacaz](https://github.com/Bhacaz).
40
+
41
+
42
+ ### 1.2.1 (July 15, 2020)
43
+
44
+ #### Fixes
45
+
46
+ * [#801](https://github.com/ruby-grape/grape-swagger/pull/801): Fixes behaviour after grape upgrade to 1.4.0 - [@LeFnord](https://github.com/LeFnord).
47
+
48
+
49
+ ### 1.2.0 (July 1, 2020)
50
+
51
+ #### Features
52
+
53
+ * [#794](https://github.com/ruby-grape/grape-swagger/pull/794): Allow `entity_name` to be inherited, fixes issue #659 - [@urkle](https://github.com/urkle).
54
+ * [#793](https://github.com/ruby-grape/grape-swagger/pull/793): Features/inheritance and discriminator - [@MaximeRDY](https://github.com/MaximeRDY).
55
+
56
+ #### Fixes
57
+
58
+ * [#798](https://github.com/ruby-grape/grape-swagger/pull/798): Modify full entity name separator - [@GarrettB71](https://github.com/GarrettB71).
59
+ * [#796](https://github.com/ruby-grape/grape-swagger/pull/796): Support grape 1.4.0 - [@thedanielhanke](https://github.com/thedanielhanke).
60
+
61
+
12
62
  ### 1.1.0 (April 20, 2020)
13
63
 
14
64
  #### Features
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,6 +14,7 @@ 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'
@@ -26,12 +27,16 @@ group :development, :test do
26
27
  gem 'rake'
27
28
  gem 'rdoc'
28
29
  gem 'rspec', '~> 3.9'
29
- gem 'rubocop', '~> 0.82', 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>
@@ -451,6 +451,7 @@ add_swagger_documentation \
451
451
  * [Collection Format](#collection-format)
452
452
  * [Hiding parameters](#hiding-parameters)
453
453
  * [Setting a Swagger default value](#default-value)
454
+ * [Example parameter value](#param-example)
454
455
  * [Response documentation](#response)
455
456
  * [Changing default status codes](#change-status)
456
457
  * [File response](#file-response)
@@ -458,6 +459,7 @@ add_swagger_documentation \
458
459
  * [Response examples documentation](#response-examples)
459
460
  * [Response headers documentation](#response-headers)
460
461
  * [Adding root element to responses](#response-root)
462
+ * [Multiple present Response](#multiple-response)
461
463
 
462
464
  #### Swagger Header Parameters <a name="headers"></a>
463
465
 
@@ -768,8 +770,6 @@ params do
768
770
  end
769
771
  ```
770
772
 
771
- The example parameter will populate the Swagger UI with the example value, and can be used for optional or required parameters.
772
-
773
773
  Grape uses the option `default` to set a default value for optional parameters. This is different in that Grape will set your parameter to the provided default if the parameter is omitted, whereas the example value above will only set the value in the UI itself. This will set the Swagger `defaultValue` to the provided value. Note that the example value will override the Grape default value.
774
774
 
775
775
  ```ruby
@@ -779,6 +779,16 @@ params do
779
779
  end
780
780
  ```
781
781
 
782
+ #### Example parameter value <a name="param-example"></a>
783
+
784
+ The example parameter will populate the Swagger UI with the example value, and can be used for optional or required parameters.
785
+
786
+ ```ruby
787
+ params do
788
+ requires :id, type: Integer, documentation: { example: 123 }
789
+ optional :name, type String, documentation: { example: 'Buddy Guy' }
790
+ end
791
+ ```
782
792
 
783
793
  #### Expose nested namespace as standalone route
784
794
 
@@ -859,10 +869,11 @@ get '/thing', failure: [
859
869
  end
860
870
  ```
861
871
 
862
- By adding a `model` key, e.g. this would be taken.
872
+ By adding a `model` key, e.g. this would be taken. Setting an empty string will act like an empty body.
863
873
  ```ruby
864
874
  get '/thing', failure: [
865
875
  { code: 400, message: 'General error' },
876
+ { code: 403, message: 'Forbidden error', model: '' },
866
877
  { code: 422, message: 'Invalid parameter entry', model: Entities::ApiError }
867
878
  ] do
868
879
  # ...
@@ -1261,6 +1272,76 @@ The result will look like following:
1261
1272
  }
1262
1273
  }
1263
1274
  ```
1275
+ #### Multiple present Response <a name="multiple-response"></a>
1276
+
1277
+ You can specify a custom multiple response by using the `as` key:
1278
+ ```ruby
1279
+ desc 'Multiple response',
1280
+ success: [
1281
+ { model: Entities::EnumValues, as: :gender },
1282
+ { model: Entities::Something, as: :somethings }
1283
+ ]
1284
+ end
1285
+
1286
+ get '/things' do
1287
+ ...
1288
+ end
1289
+ ```
1290
+ The result will look like following:
1291
+ ```
1292
+ "responses": {
1293
+ "200": {
1294
+ "description": "Multiple response",
1295
+ "schema":{
1296
+ "type":"object",
1297
+ "properties":{
1298
+ "gender":{
1299
+ "$ref":"#/definitions/EnumValues"
1300
+ },
1301
+ "somethings":{
1302
+ "$ref":"#/definitions/Something"
1303
+ }
1304
+ }
1305
+ }
1306
+ }
1307
+ }
1308
+ ```
1309
+ You can also specify if the response is an array, with the `is_array` key:
1310
+ ```ruby
1311
+ desc 'Multiple response with array',
1312
+ success: [
1313
+ { model: Entities::EnumValues, as: :gender },
1314
+ { model: Entities::Something, as: :somethings, is_array: true, required: true }
1315
+ ]
1316
+ end
1317
+
1318
+ get '/things' do
1319
+ ...
1320
+ end
1321
+ ```
1322
+ The result will look like following:
1323
+ ```
1324
+ "responses": {
1325
+ "200": {
1326
+ "description": "Multiple response with array",
1327
+ "schema":{
1328
+ "type":"object",
1329
+ "properties":{
1330
+ "gender":{
1331
+ "$ref":"#/definitions/EnumValues"
1332
+ },
1333
+ "somethings":{
1334
+ "type":"array",
1335
+ "items":{
1336
+ "$ref":"#/definitions/Something"
1337
+ }
1338
+ }
1339
+ },
1340
+ "required": ["somethings"]
1341
+ }
1342
+ }
1343
+ }
1344
+ ```
1264
1345
 
1265
1346
  ## Using Grape Entities <a name="grape-entity"></a>
1266
1347
 
@@ -1381,6 +1462,94 @@ module API
1381
1462
  end
1382
1463
  ```
1383
1464
 
1465
+ #### Inheritance with allOf and discriminator
1466
+ ```ruby
1467
+ module Entities
1468
+ class Pet < Grape::Entity
1469
+ expose :type, documentation: {
1470
+ type: 'string',
1471
+ is_discriminator: true,
1472
+ required: true
1473
+ }
1474
+ expose :name, documentation: {
1475
+ type: 'string',
1476
+ required: true
1477
+ }
1478
+ end
1479
+
1480
+ class Cat < Pet
1481
+ expose :huntingSkill, documentation: {
1482
+ type: 'string',
1483
+ description: 'The measured skill for hunting',
1484
+ default: 'lazy',
1485
+ values: %w[
1486
+ clueless
1487
+ lazy
1488
+ adventurous
1489
+ aggressive
1490
+ ]
1491
+ }
1492
+ end
1493
+ end
1494
+ ```
1495
+
1496
+ Should generate this definitions:
1497
+ ```JSON
1498
+ {
1499
+ "definitions": {
1500
+ "Pet": {
1501
+ "type": "object",
1502
+ "discriminator": "petType",
1503
+ "properties": {
1504
+ "name": {
1505
+ "type": "string"
1506
+ },
1507
+ "petType": {
1508
+ "type": "string"
1509
+ }
1510
+ },
1511
+ "required": [
1512
+ "name",
1513
+ "petType"
1514
+ ]
1515
+ },
1516
+ "Cat": {
1517
+ "description": "A representation of a cat",
1518
+ "allOf": [
1519
+ {
1520
+ "$ref": "#/definitions/Pet"
1521
+ },
1522
+ {
1523
+ "type": "object",
1524
+ "properties": {
1525
+ "huntingSkill": {
1526
+ "type": "string",
1527
+ "description": "The measured skill for hunting",
1528
+ "default": "lazy",
1529
+ "enum": [
1530
+ "clueless",
1531
+ "lazy",
1532
+ "adventurous",
1533
+ "aggressive"
1534
+ ]
1535
+ },
1536
+ "petType": {
1537
+ "type": "string",
1538
+ "enum": ["Cat"]
1539
+ }
1540
+ },
1541
+ "required": [
1542
+ "huntingSkill",
1543
+ "petType"
1544
+ ]
1545
+ }
1546
+ ]
1547
+ }
1548
+ }
1549
+ }
1550
+ ```
1551
+
1552
+
1384
1553
 
1385
1554
 
1386
1555
  ## Securing the Swagger UI <a name="oauth"></a>