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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 398dab24d8afcf002fff3be85c3e47c2b83688904d2b3577e071ad790398caf0
|
|
4
|
+
data.tar.gz: 071ad3e3c2b9d15e6f4aa60fcf09f8fef2260f43e35e9c6a69af04071da2d6a6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
-
|
|
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 = {}
|
data/lib/openapi_ruby/version.rb
CHANGED