openapi-ruby 2.2.1 → 2.3.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8dfe417a1a5864710883f37f364361850908925c15f4bde8c97a2cce5568040b
4
- data.tar.gz: 1cae3cd37db70840d39afe38d49dabe7e136c3b5801d0485a0618cbd674c7427
3
+ metadata.gz: '0192eda7d50aeced42bcb97c08b150e147bf4da29beabd5f50d507093b89d7f1'
4
+ data.tar.gz: 21e7c12d78f74e7340ede68b5b1cfef72c5564e6e24a1caf9d63c9d819aececf
5
5
  SHA512:
6
- metadata.gz: 10c973884753f494a4917b88ca87ccdabdd408e06b365665a576cc0cf8940891f8656c8e657e9e873ca2b4c42dad4b6b172dfbe8a1e84203a192a16c6c8f1282
7
- data.tar.gz: f41d3b6d56b26aaef013572733bf360a066abfb8cf1be4df4af0583cb23a685d0bc09d58c27b816229b7ae23b2dbd0a07d75e0a6ad211ad9e2d3b3ae7c6075d0
6
+ metadata.gz: a1656c5d6fc9c042c4a2fd1fc9406378430589c87c8a545a05b3eb493c9ebed1cb4238e7ed5053f05c23e8c22bcd0fffd7932fe42aebde48f299eb0ab570edef
7
+ data.tar.gz: 363f1dea3ab2c8b40bba3c3969117db68017a0cb29d6b53a1b16249585703ed6dd7bd57fc8e78b247a61c1668b737e4929f9ef19f14a19dcf9951336e3710b3f
@@ -84,8 +84,8 @@ module OpenapiRuby
84
84
  end
85
85
  end
86
86
 
87
- def response(status_code, description, &block)
88
- response_ctx = @operation.response(status_code, description)
87
+ def response(status_code, description, hidden: false, &block)
88
+ response_ctx = @operation.response(status_code, description, hidden: hidden)
89
89
  operation = @operation
90
90
 
91
91
  @example_group.context "response #{status_code} #{description}" do
@@ -65,11 +65,11 @@ module OpenapiRuby
65
65
  existing_scopes = existing._component_scopes
66
66
  existing_scopes_set = existing._component_scopes_explicitly_set
67
67
 
68
- # Skip when exactly one side has explicitly configured scopes — during initial
68
+ # Skip when scopes haven't been explicitly configured yet — during initial
69
69
  # loading, components are registered with empty default scopes before the Loader
70
- # assigns inferred scopes. The unconfigured side may get scopes later via
71
- # component_scopes, which unregisters/re-registers and retriggers this check.
72
- next if new_scopes_set != existing_scopes_set
70
+ # assigns inferred scopes. Only check for duplicates when both sides have
71
+ # explicitly set their scopes.
72
+ next unless new_scopes_set && existing_scopes_set
73
73
 
74
74
  if scopes_overlap?(new_scopes, existing_scopes)
75
75
  raise DuplicateComponentError,
@@ -55,7 +55,16 @@ module OpenapiRuby
55
55
  end
56
56
 
57
57
  def request_body(attributes = {})
58
- @request_body_definition = deep_stringify(attributes)
58
+ stringified = deep_stringify(attributes)
59
+
60
+ # Shorthand: if schema is provided without content, wrap it in
61
+ # content: { "application/json" => { schema: ... } }
62
+ if stringified["schema"] && !stringified["content"]
63
+ schema = stringified.delete("schema")
64
+ stringified["content"] = {"application/json" => {"schema" => schema}}
65
+ end
66
+
67
+ @request_body_definition = stringified
59
68
  end
60
69
 
61
70
  def request_body_example(value:, name: "example", summary: nil)
@@ -64,8 +73,8 @@ module OpenapiRuby
64
73
  @request_examples << entry
65
74
  end
66
75
 
67
- def response(status_code, description, &block)
68
- ctx = ResponseContext.new(status_code, description)
76
+ def response(status_code, description, hidden: false, &block)
77
+ ctx = ResponseContext.new(status_code, description, hidden: hidden)
69
78
  ctx.produces(*@produces_list) if @produces_list.any?
70
79
  ctx.instance_eval(&block) if block
71
80
  @responses[status_code.to_s] = ctx
@@ -84,6 +93,7 @@ module OpenapiRuby
84
93
 
85
94
  result["responses"] = {}
86
95
  @responses.each do |code, ctx|
96
+ next if ctx.hidden
87
97
  result["responses"][code] = ctx.to_openapi
88
98
  end
89
99
 
@@ -3,11 +3,12 @@
3
3
  module OpenapiRuby
4
4
  module DSL
5
5
  class ResponseContext
6
- attr_reader :status_code, :description, :schema_definition, :headers, :examples, :links
6
+ attr_reader :status_code, :description, :schema_definition, :headers, :examples, :links, :hidden
7
7
 
8
- def initialize(status_code, description)
8
+ def initialize(status_code, description, hidden: false)
9
9
  @status_code = status_code.to_s
10
10
  @description = description
11
+ @hidden = hidden
11
12
  @schema_definition = nil
12
13
  @headers = {}
13
14
  @examples = {}
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module OpenapiRuby
4
- VERSION = "2.2.1"
4
+ VERSION = "2.3.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openapi-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.1
4
+ version: 2.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Morten Hartvig