jsapi 2.1.2 → 3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (139) hide show
  1. checksums.yaml +4 -4
  2. data/lib/jsapi/client/base.rb +182 -0
  3. data/lib/jsapi/client/exceptions.rb +45 -0
  4. data/lib/jsapi/client/request.rb +204 -0
  5. data/lib/jsapi/client/response.rb +120 -0
  6. data/lib/jsapi/client/session/base.rb +61 -0
  7. data/lib/jsapi/client/session/logger.rb +52 -0
  8. data/lib/jsapi/client/session/single_request.rb +16 -0
  9. data/lib/jsapi/client/session/test/class_methods.rb +49 -0
  10. data/lib/jsapi/client/session/test/response.rb +56 -0
  11. data/lib/jsapi/client/session/test/spy.rb +43 -0
  12. data/lib/jsapi/client/session/test.rb +17 -0
  13. data/lib/jsapi/client/session.rb +6 -0
  14. data/lib/jsapi/client.rb +7 -0
  15. data/lib/jsapi/configuration.rb +2 -2
  16. data/lib/jsapi/controller/authentication/credentials/http/bearer.rb +5 -12
  17. data/lib/jsapi/controller/authentication/credentials.rb +4 -4
  18. data/lib/jsapi/controller/authentication.rb +3 -3
  19. data/lib/jsapi/controller/methods.rb +43 -77
  20. data/lib/jsapi/controller/parameters.rb +6 -6
  21. data/lib/jsapi/controller/response.rb +7 -7
  22. data/lib/jsapi/{meta/definitions.rb → definition/api.rb} +62 -40
  23. data/lib/jsapi/{meta → definition}/callable/symbol_evaluator.rb +1 -1
  24. data/lib/jsapi/{meta → definition}/callable/symbol_sequence_evaluator.rb +1 -1
  25. data/lib/jsapi/{meta → definition}/callable.rb +1 -1
  26. data/lib/jsapi/{meta → definition}/callback/base.rb +5 -5
  27. data/lib/jsapi/{meta → definition}/callback/reference.rb +1 -1
  28. data/lib/jsapi/{meta → definition}/callback.rb +1 -1
  29. data/lib/jsapi/{meta → definition}/contact.rb +1 -1
  30. data/lib/jsapi/{meta → definition}/content.rb +11 -11
  31. data/lib/jsapi/{meta → definition}/defaults.rb +1 -1
  32. data/lib/jsapi/{meta → definition}/example/base.rb +1 -1
  33. data/lib/jsapi/{meta → definition}/example/builder.rb +4 -4
  34. data/lib/jsapi/{meta → definition}/example/reference.rb +1 -1
  35. data/lib/jsapi/{meta → definition}/example.rb +1 -1
  36. data/lib/jsapi/{meta → definition}/existence.rb +1 -1
  37. data/lib/jsapi/{meta → definition}/external_documentation.rb +1 -1
  38. data/lib/jsapi/{meta → definition}/header/base.rb +1 -1
  39. data/lib/jsapi/{meta → definition}/header/reference.rb +1 -1
  40. data/lib/jsapi/{meta → definition}/header.rb +1 -1
  41. data/lib/jsapi/{meta → definition}/info.rb +1 -1
  42. data/lib/jsapi/{meta → definition}/license.rb +1 -1
  43. data/lib/jsapi/{meta → definition}/link/base.rb +1 -1
  44. data/lib/jsapi/{meta → definition}/link/reference.rb +1 -1
  45. data/lib/jsapi/{meta → definition}/link.rb +1 -1
  46. data/lib/jsapi/{meta → definition}/model/attributes/class_methods.rb +1 -1
  47. data/lib/jsapi/{meta → definition}/model/attributes/frozen_error.rb +1 -1
  48. data/lib/jsapi/{meta → definition}/model/attributes/type_caster.rb +2 -2
  49. data/lib/jsapi/{meta → definition}/model/attributes.rb +1 -1
  50. data/lib/jsapi/{meta → definition}/model/base.rb +1 -1
  51. data/lib/jsapi/{meta → definition}/model/reference.rb +11 -11
  52. data/lib/jsapi/{meta → definition}/model/wrappable.rb +3 -3
  53. data/lib/jsapi/{meta → definition}/model/wrapper.rb +5 -5
  54. data/lib/jsapi/{meta → definition}/oauth_flow.rb +1 -1
  55. data/lib/jsapi/{meta → definition}/openapi/extensions.rb +1 -1
  56. data/lib/jsapi/{meta → definition}/openapi/path_item.rb +5 -5
  57. data/lib/jsapi/{meta → definition}/openapi/version.rb +2 -2
  58. data/lib/jsapi/{meta → definition}/openapi.rb +1 -1
  59. data/lib/jsapi/{meta → definition}/operation.rb +108 -62
  60. data/lib/jsapi/{meta → definition}/parameter/base.rb +11 -11
  61. data/lib/jsapi/{meta → definition}/parameter/reference.rb +5 -5
  62. data/lib/jsapi/{meta → definition}/parameter/wrapper.rb +2 -2
  63. data/lib/jsapi/{meta → definition}/parameter.rb +1 -1
  64. data/lib/jsapi/{meta → definition}/path.rb +1 -1
  65. data/lib/jsapi/{meta → definition}/pathname.rb +1 -1
  66. data/lib/jsapi/{meta → definition}/property.rb +2 -2
  67. data/lib/jsapi/{meta → definition}/reference_error.rb +1 -1
  68. data/lib/jsapi/{meta → definition}/request_body/base.rb +1 -1
  69. data/lib/jsapi/{meta → definition}/request_body/reference.rb +1 -1
  70. data/lib/jsapi/{meta → definition}/request_body/wrapper.rb +2 -2
  71. data/lib/jsapi/{meta → definition}/request_body.rb +1 -1
  72. data/lib/jsapi/{meta → definition}/rescue_handler.rb +1 -1
  73. data/lib/jsapi/{meta → definition}/response/base.rb +4 -4
  74. data/lib/jsapi/{meta → definition}/response/reference.rb +1 -1
  75. data/lib/jsapi/{meta → definition}/response/wrapper.rb +17 -5
  76. data/lib/jsapi/{meta → definition}/response.rb +1 -1
  77. data/lib/jsapi/{meta → definition}/schema/additional_properties.rb +2 -2
  78. data/lib/jsapi/{meta → definition}/schema/array.rb +2 -2
  79. data/lib/jsapi/{meta → definition}/schema/base.rb +1 -1
  80. data/lib/jsapi/{meta → definition}/schema/boolean.rb +1 -1
  81. data/lib/jsapi/{meta → definition}/schema/boundary.rb +1 -1
  82. data/lib/jsapi/{meta → definition}/schema/conversion.rb +1 -1
  83. data/lib/jsapi/{meta → definition}/schema/discriminator.rb +1 -1
  84. data/lib/jsapi/{meta → definition}/schema/integer.rb +1 -1
  85. data/lib/jsapi/{meta → definition}/schema/number.rb +1 -1
  86. data/lib/jsapi/{meta → definition}/schema/numeric.rb +1 -1
  87. data/lib/jsapi/{meta → definition}/schema/object.rb +13 -13
  88. data/lib/jsapi/{meta → definition}/schema/reference.rb +1 -1
  89. data/lib/jsapi/{meta → definition}/schema/string.rb +1 -1
  90. data/lib/jsapi/{meta → definition}/schema/validation/base.rb +1 -1
  91. data/lib/jsapi/{meta → definition}/schema/validation/enum.rb +1 -1
  92. data/lib/jsapi/{meta → definition}/schema/validation/max_items.rb +1 -1
  93. data/lib/jsapi/{meta → definition}/schema/validation/max_length.rb +1 -1
  94. data/lib/jsapi/{meta → definition}/schema/validation/maximum.rb +1 -1
  95. data/lib/jsapi/{meta → definition}/schema/validation/min_items.rb +1 -1
  96. data/lib/jsapi/{meta → definition}/schema/validation/min_length.rb +1 -1
  97. data/lib/jsapi/{meta → definition}/schema/validation/minimum.rb +1 -1
  98. data/lib/jsapi/{meta → definition}/schema/validation/multiple_of.rb +1 -1
  99. data/lib/jsapi/{meta → definition}/schema/validation/pattern.rb +1 -1
  100. data/lib/jsapi/{meta → definition}/schema/wrapper.rb +18 -4
  101. data/lib/jsapi/{meta → definition}/schema.rb +5 -5
  102. data/lib/jsapi/{meta → definition}/security_requirement.rb +1 -1
  103. data/lib/jsapi/{meta → definition}/security_scheme/api_key.rb +1 -1
  104. data/lib/jsapi/{meta → definition}/security_scheme/base.rb +1 -1
  105. data/lib/jsapi/{meta → definition}/security_scheme/http/basic.rb +1 -1
  106. data/lib/jsapi/{meta → definition}/security_scheme/http/bearer.rb +1 -1
  107. data/lib/jsapi/{meta → definition}/security_scheme/http/other.rb +1 -1
  108. data/lib/jsapi/{meta → definition}/security_scheme/http.rb +1 -1
  109. data/lib/jsapi/{meta → definition}/security_scheme/mutual_tls.rb +1 -1
  110. data/lib/jsapi/{meta → definition}/security_scheme/oauth2.rb +1 -1
  111. data/lib/jsapi/{meta → definition}/security_scheme/open_id_connect.rb +1 -1
  112. data/lib/jsapi/{meta → definition}/security_scheme.rb +1 -1
  113. data/lib/jsapi/{meta → definition}/server.rb +24 -1
  114. data/lib/jsapi/{meta → definition}/server_variable.rb +1 -1
  115. data/lib/jsapi/{meta → definition}/tag.rb +1 -1
  116. data/lib/jsapi/definition.rb +33 -0
  117. data/lib/jsapi/dsl/{definitions.rb → api.rb} +48 -48
  118. data/lib/jsapi/dsl/base.rb +7 -7
  119. data/lib/jsapi/dsl/class_methods.rb +34 -32
  120. data/lib/jsapi/dsl/examples.rb +1 -1
  121. data/lib/jsapi/dsl/operation.rb +9 -7
  122. data/lib/jsapi/dsl/parameter.rb +1 -1
  123. data/lib/jsapi/dsl/path.rb +8 -6
  124. data/lib/jsapi/dsl/response.rb +5 -5
  125. data/lib/jsapi/dsl/schema.rb +17 -17
  126. data/lib/jsapi/dsl/shared_operation_methods.rb +11 -26
  127. data/lib/jsapi/dsl.rb +2 -2
  128. data/lib/jsapi/model/errors.rb +3 -3
  129. data/lib/jsapi/status/code.rb +20 -0
  130. data/lib/jsapi/support/messages.rb +27 -0
  131. data/lib/jsapi/support.rb +3 -0
  132. data/lib/jsapi/version.rb +1 -1
  133. data/lib/jsapi.rb +3 -3
  134. metadata +115 -102
  135. data/lib/jsapi/jsonify_error.rb +0 -17
  136. data/lib/jsapi/messages.rb +0 -19
  137. data/lib/jsapi/meta.rb +0 -38
  138. /data/lib/jsapi/{meta → definition}/model.rb +0 -0
  139. /data/lib/jsapi/{meta → definition}/schema/validation.rb +0 -0
@@ -1,13 +1,20 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Jsapi
4
- module Meta
5
- class Definitions < Model::Base
4
+ module Definition
5
+ # Raised when no operation with the specified name is found.
6
+ class OperationNotFound < StandardError
7
+ def initialize(operation_name)
8
+ super("operation not found: #{operation_name}")
9
+ end
10
+ end
11
+
12
+ class API < Model::Base
6
13
  include OpenAPI::Extensions
7
14
 
8
15
  ##
9
16
  # :attr: base_path
10
- # The base path of the API.
17
+ # The base path of the \API.
11
18
  #
12
19
  # Applies to \OpenAPI 2.0.
13
20
  attribute :base_path, Pathname
@@ -46,7 +53,7 @@ module Jsapi
46
53
 
47
54
  ##
48
55
  # :attr: host
49
- # The host serving the API.
56
+ # The host serving the \API.
50
57
  #
51
58
  # Applies to \OpenAPI 2.0.
52
59
  attribute :host, String
@@ -108,7 +115,7 @@ module Jsapi
108
115
 
109
116
  ##
110
117
  # :attr: schemes
111
- # The transfer protocols supported by the API. Can contain one or more of:
118
+ # The transfer protocols supported by the \API. Can contain one or more of:
112
119
  #
113
120
  # - <code>"http"</code>
114
121
  # - <code>"https"</code>
@@ -132,7 +139,7 @@ module Jsapi
132
139
 
133
140
  ##
134
141
  # :attr: servers
135
- # The servers providing the API.
142
+ # The servers providing the \API.
136
143
  #
137
144
  # Applies to \OpenAPI 3.0 and higher.
138
145
  attribute :servers, [Server]
@@ -145,7 +152,7 @@ module Jsapi
145
152
  # The class to which this instance is assigned.
146
153
  attr_reader :owner
147
154
 
148
- # The +Definitions+ instance from which this instance inherits.
155
+ # The +API+ instance from which this instance inherits.
149
156
  attr_reader :parent
150
157
 
151
158
  def initialize(keywords = {})
@@ -155,8 +162,8 @@ module Jsapi
155
162
  included = keywords.delete(:include)
156
163
  super(keywords)
157
164
 
158
- Array(included).each do |definitions|
159
- include(definitions)
165
+ Array(included).each do |api|
166
+ include(api)
160
167
  end
161
168
  @parent&.inherited(self)
162
169
  end
@@ -188,12 +195,12 @@ module Jsapi
188
195
  end
189
196
  end
190
197
 
191
- # Returns an array containing itself and all of the +Definitions+ instances
198
+ # Returns an array containing itself and all of the +API+ instances
192
199
  # inherited or included.
193
200
  def ancestors
194
201
  @ancestors ||= [self].tap do |ancestors|
195
- [@included_definitions, @parent].flatten.each do |definitions|
196
- ancestors.push(*definitions.ancestors) if definitions
202
+ [@included_apis, @parent].flatten.each do |api|
203
+ ancestors.push(*api.ancestors) if api
197
204
  end
198
205
  end.uniq
199
206
  end
@@ -229,8 +236,8 @@ module Jsapi
229
236
 
230
237
  cache_path_attribute(arg, name) do
231
238
  arg.ancestors.lazy.filter_map do |pathname|
232
- ancestors.lazy.filter_map do |definitions|
233
- definitions.path(pathname)&.public_send(name).presence
239
+ ancestors.lazy.filter_map do |api|
240
+ api.path(pathname)&.public_send(name).presence
234
241
  end.first
235
242
  end.first
236
243
  end
@@ -255,8 +262,8 @@ module Jsapi
255
262
 
256
263
  cache_path_attribute(arg, name) do
257
264
  arg.ancestors.flat_map do |pathname|
258
- ancestors.filter_map do |definitions|
259
- definitions.path(pathname)&.send(name)
265
+ ancestors.filter_map do |api|
266
+ api.path(pathname)&.send(name)
260
267
  end
261
268
  end.reduce({}, &:reverse_merge).presence
262
269
  end
@@ -280,8 +287,8 @@ module Jsapi
280
287
 
281
288
  cache_path_attribute(arg, name) do
282
289
  arg.ancestors.filter_map do |pathname|
283
- ancestors.filter_map do |definitions|
284
- definitions.path(pathname)&.send(name)
290
+ ancestors.filter_map do |api|
291
+ api.path(pathname)&.send(name)
285
292
  end
286
293
  end.flatten.uniq.presence
287
294
  end
@@ -298,7 +305,8 @@ module Jsapi
298
305
  cached_attributes[:security_requirements]
299
306
  end
300
307
 
301
- # Returns the operation with the specified name.
308
+ # Returns the operation with the specified name or +nil+ if no such
309
+ # operation is found.
302
310
  def find_operation(name = nil)
303
311
  name = name&.to_s
304
312
 
@@ -313,6 +321,15 @@ module Jsapi
313
321
  end
314
322
  end
315
323
 
324
+ # Like +find_operation+, except that it raises an OperationNotFound error
325
+ # when no such operation is found.
326
+ def find_operation!(name = nil)
327
+ operation = find_operation(name)
328
+ return operation if operation
329
+
330
+ raise OperationNotFound.new(name)
331
+ end
332
+
316
333
  ##
317
334
  # :method: find_example
318
335
  # Returns the reusable example with the specified name.
@@ -344,17 +361,17 @@ module Jsapi
344
361
  end
345
362
  end
346
363
 
347
- # Includes +definitions+.
348
- def include(definitions)
349
- if circular_dependency?(definitions)
364
+ # Includes +api+.
365
+ def include(api)
366
+ if circular_dependency?(api)
350
367
  raise ArgumentError,
351
368
  'detected circular dependency between ' \
352
369
  "#{owner.inspect} and " \
353
- "#{definitions.owner.inspect}"
370
+ "#{api.owner.inspect}"
354
371
  end
355
372
 
356
- (@included_definitions ||= []) << definitions
357
- definitions.included(self)
373
+ (@included_apis ||= []) << api
374
+ api.included(self)
358
375
  invalidate_ancestors
359
376
  self
360
377
  end
@@ -497,37 +514,42 @@ module Jsapi
497
514
  end
498
515
 
499
516
  # Returns the first RescueHandler capable to handle +exception+, or nil
500
- # if no one could be found.
517
+ # if no one is found.
501
518
  def rescue_handler_for(exception)
502
519
  cached_attributes[:rescue_handlers].find { |r| r.match?(exception) }
503
520
  end
504
521
 
522
+ # Returns the server with the specified name or +nil+ if no such server is present.
523
+ def server(name)
524
+ cached_attributes[:servers].find { |server| server.name == name } unless name.nil?
525
+ end
526
+
505
527
  protected
506
528
 
507
- # The +Definitions+ instances that directly inherit from this instance.
529
+ # The +API+ instances that directly inherit from this instance.
508
530
  attr_reader :children
509
531
 
510
- # The +Definitions+ instances that directly include this instance.
511
- attr_reader :dependent_definitions
532
+ # The +API+ instances that directly include this instance.
533
+ attr_reader :dependent_apis
512
534
 
513
- # The +Definitions+ instances included.
514
- attr_reader :included_definitions
535
+ # The +API+ instances included.
536
+ attr_reader :included_apis
515
537
 
516
538
  def attribute_changed(*) # :nodoc:
517
539
  invalidate_attributes
518
540
  super
519
541
  end
520
542
 
521
- # Invoked whenever it is included in another +Definitions+ instance.
522
- def included(definitions)
523
- (@dependent_definitions ||= []) << definitions
543
+ # Invoked whenever it is included in another +API+ instance.
544
+ def included(api)
545
+ (@dependent_apis ||= []) << api
524
546
  end
525
547
 
526
548
  # rubocop:disable Lint/MissingSuper
527
549
 
528
- # Invoked whenever it is inherited by another +Definitions+ instance.
529
- def inherited(definitions)
530
- (@children ||= []) << definitions
550
+ # Invoked whenever it is inherited by another +API+ instance.
551
+ def inherited(api)
552
+ (@children ||= []) << api
531
553
  end
532
554
 
533
555
  # rubocop:enable Lint/MissingSuper
@@ -592,9 +614,9 @@ module Jsapi
592
614
 
593
615
  def circular_dependency?(other)
594
616
  return true if other == self
595
- return false unless other.included_definitions&.any?
617
+ return false unless other.included_apis&.any?
596
618
 
597
- other.included_definitions.any? { |included| circular_dependency?(included) }
619
+ other.included_apis.any? { |included| circular_dependency?(included) }
598
620
  end
599
621
 
600
622
  def default_operation_name
@@ -616,7 +638,7 @@ module Jsapi
616
638
  end
617
639
 
618
640
  def each_descendant(&block)
619
- [*@children, *dependent_definitions].each(&block)
641
+ [*@children, *dependent_apis].each(&block)
620
642
  nil
621
643
  end
622
644
 
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Jsapi
4
- module Meta
4
+ module Definition
5
5
  module Callable
6
6
  class SymbolEvaluator
7
7
  attr_reader :symbol
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Jsapi
4
- module Meta
4
+ module Definition
5
5
  module Callable
6
6
  class SymbolSequenceEvaluator
7
7
  attr_reader :symbols
@@ -4,7 +4,7 @@ require_relative 'callable/symbol_evaluator'
4
4
  require_relative 'callable/symbol_sequence_evaluator'
5
5
 
6
6
  module Jsapi
7
- module Meta
7
+ module Definition
8
8
  module Callable
9
9
  class << self
10
10
  def from(arg)
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Jsapi
4
- module Meta
4
+ module Definition
5
5
  module Parameter; end
6
6
  class Operation < Model::Base; end
7
7
 
@@ -50,13 +50,13 @@ module Jsapi
50
50
 
51
51
  # Returns a hash representing the \OpenAPI path item object that describes
52
52
  # the operations.
53
- def to_openapi(version, definitions)
53
+ def to_openapi(version, api)
54
54
  OpenAPI::PathItem.new(
55
55
  operations.values,
56
56
  description: description,
57
57
  summary: summary,
58
58
  parameters: parameters
59
- ).to_openapi(version, definitions)
59
+ ).to_openapi(version, api)
60
60
  end
61
61
  end
62
62
 
@@ -76,9 +76,9 @@ module Jsapi
76
76
  end
77
77
 
78
78
  # Returns a hash representing the \OpenAPI callback object.
79
- def to_openapi(version, definitions)
79
+ def to_openapi(version, api)
80
80
  expressions.transform_values do |operations|
81
- operations.to_openapi(version, definitions)
81
+ operations.to_openapi(version, api)
82
82
  end
83
83
  end
84
84
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Jsapi
4
- module Meta
4
+ module Definition
5
5
  module Callback
6
6
  # Refers a reusable callback.
7
7
  class Reference < Model::Reference; end
@@ -4,7 +4,7 @@ require_relative 'callback/base'
4
4
  require_relative 'callback/reference'
5
5
 
6
6
  module Jsapi
7
- module Meta
7
+ module Definition
8
8
  module Callback
9
9
  class << self
10
10
  # Creates a Base or Reference.
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Jsapi
4
- module Meta
4
+ module Definition
5
5
  # Specifies a contact.
6
6
  class Contact < Model::Base
7
7
  include OpenAPI::Extensions
@@ -1,20 +1,20 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Jsapi
4
- module Meta
4
+ module Definition
5
5
  # Specifies the content of a request body or response.
6
6
  class Content < Model::Base
7
7
  include OpenAPI::Extensions
8
8
 
9
9
  class Wrapper < Model::Wrapper
10
10
  def schema
11
- @schema ||= Schema.wrap(super, definitions)
11
+ @schema ||= Schema.wrap(super, api)
12
12
  end
13
13
  end
14
14
 
15
15
  include Model::Wrappable
16
16
 
17
- delegate_missing_to :schema
17
+ delegate_missing_to :schema, allow_nil: true
18
18
 
19
19
  ##
20
20
  # :attr: examples
@@ -33,20 +33,20 @@ module Jsapi
33
33
  add_example(value: keywords.delete(:example)) if keywords.key?(:example)
34
34
  keywords[:ref] = keywords.delete(:schema) if keywords.key?(:schema)
35
35
 
36
- @schema = Schema.new(keywords)
36
+ @schema = Schema.new(keywords) if keywords[:type] || keywords[:ref]
37
37
  end
38
38
 
39
39
  # Returns the data value of the first example.
40
- def example_data_value(definitions, locale: nil)
40
+ def example_data_value(api, locale: nil)
41
41
  examples
42
42
  .values.first
43
- &.resolve(definitions)
44
- &.data_value(builder: example_builder(definitions, locale))
43
+ &.resolve(api)
44
+ &.data_value(builder: example_builder(api, locale))
45
45
  end
46
46
 
47
47
  # Returns a hash representing the \OpenAPI media type object describing
48
48
  # the content. Applies to \OpenAPI 3.0 and higher.
49
- def to_openapi(version, definitions = nil, locale: nil, media_type: nil)
49
+ def to_openapi(version, api = nil, locale: nil, media_type: nil)
50
50
  version = OpenAPI::Version.from(version)
51
51
  example_builder = nil
52
52
 
@@ -59,7 +59,7 @@ module Jsapi
59
59
  end,
60
60
  examples:
61
61
  examples.transform_values do |example|
62
- example_builder ||= example_builder(definitions, locale)
62
+ example_builder ||= example_builder(api, locale)
63
63
  example.to_openapi(version, builder: example_builder)
64
64
  end.presence
65
65
  )
@@ -67,8 +67,8 @@ module Jsapi
67
67
 
68
68
  private
69
69
 
70
- def example_builder(definitions, locale)
71
- Example::Builder.new(schema, definitions, locale: locale) if definitions.present?
70
+ def example_builder(api, locale)
71
+ Example::Builder.new(schema, api, locale: locale) if api.present?
72
72
  end
73
73
  end
74
74
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Jsapi
4
- module Meta
4
+ module Definition
5
5
  # Holds the default values for a particular Schema type.
6
6
  class Defaults < Model::Base
7
7
  ##
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Jsapi
4
- module Meta
4
+ module Definition
5
5
  module Example
6
6
  # Specifies an example.
7
7
  class Base < Model::Base
@@ -1,16 +1,16 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Jsapi
4
- module Meta
4
+ module Definition
5
5
  module Example
6
6
  class Builder # :nodoc:
7
- def initialize(schema, definitions, locale: nil)
8
- @schema = Schema.wrap(schema, definitions)
7
+ def initialize(schema, api, locale: nil)
8
+ @schema = Schema.wrap(schema, api)
9
9
  @locale = locale
10
10
  end
11
11
 
12
12
  def generate_json(object, omit: nil)
13
- raise ArgumentError, Messages.invalid_value(
13
+ raise ArgumentError, Support::Messages.invalid_value(
14
14
  name: 'omit',
15
15
  value: omit,
16
16
  valid_values: %i[empty nil]
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Jsapi
4
- module Meta
4
+ module Definition
5
5
  module Example
6
6
  # Refers a reusable example.
7
7
  class Reference < Model::Reference; end
@@ -5,7 +5,7 @@ require_relative 'example/builder'
5
5
  require_relative 'example/reference'
6
6
 
7
7
  module Jsapi
8
- module Meta
8
+ module Definition
9
9
  module Example
10
10
  class << self
11
11
  # Creates a Base or Reference.
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Jsapi
4
- module Meta
4
+ module Definition
5
5
  # Combines the presence concepts of the +#present?+ method and \JSON \Schema
6
6
  # by four levels of existence.
7
7
  class Existence
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Jsapi
4
- module Meta
4
+ module Definition
5
5
  # Specifies an external documentation.
6
6
  class ExternalDocumentation < Model::Base
7
7
  include OpenAPI::Extensions
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Jsapi
4
- module Meta
4
+ module Definition
5
5
  module Header
6
6
  # Specifies an HTTP header.
7
7
  class Base < Model::Base
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Jsapi
4
- module Meta
4
+ module Definition
5
5
  module Header
6
6
  # Refers a reusable header.
7
7
  class Reference < Model::Reference; end
@@ -4,7 +4,7 @@ require_relative 'header/base'
4
4
  require_relative 'header/reference'
5
5
 
6
6
  module Jsapi
7
- module Meta
7
+ module Definition
8
8
  module Header
9
9
  class << self
10
10
  # Creates a Base or Reference.
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Jsapi
4
- module Meta
4
+ module Definition
5
5
  # Specifies metadata about an API.
6
6
  class Info < Model::Base
7
7
  include OpenAPI::Extensions
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Jsapi
4
- module Meta
4
+ module Definition
5
5
  # Specifies a license.
6
6
  class License < Model::Base
7
7
  include OpenAPI::Extensions
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Jsapi
4
- module Meta
4
+ module Definition
5
5
  module Link
6
6
  # Specifies a link.
7
7
  class Base < Model::Base
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Jsapi
4
- module Meta
4
+ module Definition
5
5
  module Link
6
6
  # Refers a reusable link.
7
7
  class Reference < Model::Reference; end
@@ -4,7 +4,7 @@ require_relative 'link/base'
4
4
  require_relative 'link/reference'
5
5
 
6
6
  module Jsapi
7
- module Meta
7
+ module Definition
8
8
  module Link
9
9
  class << self
10
10
  # Creates a Base or Reference.
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Jsapi
4
- module Meta
4
+ module Definition
5
5
  module Model
6
6
  module Attributes
7
7
  module ClassMethods
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Jsapi
4
- module Meta
4
+ module Definition
5
5
  module Model
6
6
  module Attributes
7
7
  # Raised when trying to modify a frozen attribute.
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Jsapi
4
- module Meta
4
+ module Definition
5
5
  module Model
6
6
  module Attributes
7
7
  class TypeCaster
@@ -43,7 +43,7 @@ module Jsapi
43
43
  casted_value = @caster.call(value)
44
44
  return casted_value unless @values&.exclude?(casted_value)
45
45
 
46
- raise ArgumentError, Messages.invalid_value(
46
+ raise ArgumentError, Support::Messages.invalid_value(
47
47
  name: @name,
48
48
  value: casted_value,
49
49
  valid_values: @values
@@ -5,7 +5,7 @@ require_relative 'attributes/type_caster'
5
5
  require_relative 'attributes/class_methods'
6
6
 
7
7
  module Jsapi
8
- module Meta
8
+ module Definition
9
9
  module Model
10
10
  module Attributes
11
11
  def self.included(base) # :nodoc:
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Jsapi
4
- module Meta
4
+ module Definition
5
5
  module Model
6
6
  # The base meta model class.
7
7
  class Base