rswag-specs 2.3.1 → 2.3.2
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 540d37d1a9a9e90a4b062f65239029fdd9fcdcfec4622eb68ec4f90ec4eebab9
|
4
|
+
data.tar.gz: 9180d18a4a0d8ba624c42a38376270bdb0885da77f007cf001be3128d5929d66
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4da3cd01812d9d8b8d8e28a4f35400cabcae133efd3192864eaa4820a9210c82dd78b35e353abaf74856d6f822fbf3f3eac94fa2c3dbe461f7b3167a129f7e6d
|
7
|
+
data.tar.gz: f4e261ec8b205d949058e8a124964250cfcef4a26ff93c59fa8fb269acc0e0b9c565e2b0bac2ae8071a92146d69a685b902bf11e6939282a27abe1c13cdbd1a9
|
@@ -19,7 +19,11 @@ RSpec.describe '<%= controller_path %>', type: :request do
|
|
19
19
|
<% end -%>
|
20
20
|
|
21
21
|
after do |example|
|
22
|
-
example.metadata[:response][:
|
22
|
+
example.metadata[:response][:content] = {
|
23
|
+
'application/json' => {
|
24
|
+
example: JSON.parse(response.body, symbolize_names: true)
|
25
|
+
}
|
26
|
+
}
|
23
27
|
end
|
24
28
|
run_test!
|
25
29
|
end
|
data/lib/rswag/route_parser.rb
CHANGED
@@ -11,7 +11,7 @@ module Rswag
|
|
11
11
|
def routes
|
12
12
|
::Rails.application.routes.routes.select do |route|
|
13
13
|
route.defaults[:controller] == controller
|
14
|
-
end.each_with_object({}) do |
|
14
|
+
end.each_with_object({}) do |route, tree|
|
15
15
|
path = path_from(route)
|
16
16
|
verb = verb_from(route)
|
17
17
|
tree[path] ||= { params: params_from(route), actions: {} }
|
@@ -72,7 +72,10 @@ module Rswag
|
|
72
72
|
def examples(example = nil)
|
73
73
|
return super() if example.nil?
|
74
74
|
|
75
|
-
metadata[:response][:
|
75
|
+
metadata[:response][:content] =
|
76
|
+
example.each_with_object({}) do |(mime, example_object), memo|
|
77
|
+
memo[mime] = { example: example_object }
|
78
|
+
end
|
76
79
|
end
|
77
80
|
|
78
81
|
def run_test!(&block)
|
@@ -118,7 +118,8 @@ module Rswag
|
|
118
118
|
|
119
119
|
def build_query_string_part(param, value)
|
120
120
|
name = param[:name]
|
121
|
-
|
121
|
+
type = param[:type] || param.dig(:schema, :type)
|
122
|
+
return "#{name}=#{value}" unless type&.to_sym == :array
|
122
123
|
|
123
124
|
case param[:collectionFormat]
|
124
125
|
when :ssv
|
@@ -56,9 +56,10 @@ module Rswag
|
|
56
56
|
is_hash = value.is_a?(Hash)
|
57
57
|
if is_hash && value.dig(:parameters)
|
58
58
|
schema_param = value.dig(:parameters)&.find { |p| (p[:in] == :body || p[:in] == :formData) && p[:schema] }
|
59
|
-
mime_list = value.dig(:consumes)
|
59
|
+
mime_list = value.dig(:consumes) || doc[:consumes]
|
60
60
|
if value && schema_param && mime_list
|
61
61
|
value[:requestBody] = { content: {} } unless value.dig(:requestBody, :content)
|
62
|
+
value[:requestBody][:required] = true if schema_param[:required]
|
62
63
|
mime_list.each do |mime|
|
63
64
|
value[:requestBody][:content][mime] = { schema: schema_param[:schema] }
|
64
65
|
end
|
@@ -129,13 +130,14 @@ module Rswag
|
|
129
130
|
end
|
130
131
|
|
131
132
|
def upgrade_content!(mime_list, target_node)
|
132
|
-
target_node.merge!(content: {})
|
133
133
|
schema = target_node[:schema]
|
134
134
|
return if mime_list.empty? || schema.nil?
|
135
|
+
target_node[:content] ||= {}
|
136
|
+
target_node.merge!(content: {})
|
135
137
|
|
136
138
|
mime_list.each do |mime_type|
|
137
139
|
# TODO upgrade to have content-type specific schema
|
138
|
-
target_node[:content][mime_type]
|
140
|
+
(target_node[:content][mime_type] ||= {}).merge!(schema: schema)
|
139
141
|
end
|
140
142
|
end
|
141
143
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rswag-specs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.3.
|
4
|
+
version: 2.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Richie Morris
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2021-01-28 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activesupport
|
@@ -66,8 +66,9 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '2.2'
|
69
|
-
description: Simplify API integration testing with a succinct rspec DSL and generate
|
70
|
-
|
69
|
+
description: 'Simplify API integration testing with a succinct rspec DSL and generate
|
70
|
+
OpenAPI specification files directly from your rspecs. More about the OpenAPI initiative
|
71
|
+
here: http://spec.openapis.org/'
|
71
72
|
email:
|
72
73
|
- domaindrivendev@gmail.com
|
73
74
|
executables: []
|
@@ -115,6 +116,6 @@ requirements: []
|
|
115
116
|
rubygems_version: 3.0.6
|
116
117
|
signing_key:
|
117
118
|
specification_version: 4
|
118
|
-
summary:
|
119
|
-
|
119
|
+
summary: An OpenAPI-based (formerly called Swagger) DSL for rspec-rails & accompanying
|
120
|
+
rake task for generating OpenAPI specification files
|
120
121
|
test_files: []
|