openapi-ruby 2.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8dfe417a1a5864710883f37f364361850908925c15f4bde8c97a2cce5568040b
4
- data.tar.gz: 1cae3cd37db70840d39afe38d49dabe7e136c3b5801d0485a0618cbd674c7427
3
+ metadata.gz: 398dab24d8afcf002fff3be85c3e47c2b83688904d2b3577e071ad790398caf0
4
+ data.tar.gz: 071ad3e3c2b9d15e6f4aa60fcf09f8fef2260f43e35e9c6a69af04071da2d6a6
5
5
  SHA512:
6
- metadata.gz: 10c973884753f494a4917b88ca87ccdabdd408e06b365665a576cc0cf8940891f8656c8e657e9e873ca2b4c42dad4b6b172dfbe8a1e84203a192a16c6c8f1282
7
- data.tar.gz: f41d3b6d56b26aaef013572733bf360a066abfb8cf1be4df4af0583cb23a685d0bc09d58c27b816229b7ae23b2dbd0a07d75e0a6ad211ad9e2d3b3ae7c6075d0
6
+ metadata.gz: 7745b15a5b56b12b9a7c2b24ddfe761d37faea4835114722960dbc575bd2ae386780284a2791a1b57d08374cad5a8f5079ff410cefcbedce521c719bc892ab81
7
+ data.tar.gz: a6baddb8b5850f6b273506f04fa9e8917338431c3d08ab698f710fa791b7c99e4f4ad5b861c298ca08b9b156342606ca760efb7720d7d1a735f6197faee4807d
@@ -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
@@ -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.0"
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.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Morten Hartvig