rspec-openapi 0.18.3 → 0.18.4
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 +4 -4
- data/.github/workflows/test.yml +1 -1
- data/Gemfile +4 -0
- data/README.md +10 -0
- data/lib/rspec/openapi/extractors/rails.rb +2 -2
- data/lib/rspec/openapi/record.rb +1 -0
- data/lib/rspec/openapi/record_builder.rb +2 -0
- data/lib/rspec/openapi/result_recorder.rb +1 -1
- data/lib/rspec/openapi/schema_builder.rb +5 -1
- data/lib/rspec/openapi/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ec34ef0e56eb4c46221d956120a836d20addbfa8d636807effad4b93cf5ac8f8
|
4
|
+
data.tar.gz: 8b2c33feefc0f7173e6f31a09c66c9824b2f3f6124a24c6f56f59f7f5ff3e938
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e2e12be8f18ac6e3c6641bb3b128bad631c120f4400148f999b758b1b2820b44dd047569036c1adc4393b001a438f2595aacf5869540411ec077c054a6b8d4c3
|
7
|
+
data.tar.gz: 347a1c54c418ad9957b3137b2d7db8c0c74496b473cdaf9f14dc9e4dab0205340e510317c324ff68494e237b27a369642d7cba2687b6eaa88318a70387557f37
|
data/.github/workflows/test.yml
CHANGED
@@ -38,7 +38,7 @@ jobs:
|
|
38
38
|
- run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
|
39
39
|
name: codecov-action@v4 workaround
|
40
40
|
- name: Upload coverage reports
|
41
|
-
uses: codecov/codecov-action@
|
41
|
+
uses: codecov/codecov-action@v5
|
42
42
|
if: matrix.coverage == 'coverage'
|
43
43
|
with:
|
44
44
|
fail_ci_if_error: true
|
data/Gemfile
CHANGED
@@ -11,8 +11,12 @@ if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.0.0')
|
|
11
11
|
gem 'hanami', ENV['HANAMI_VERSION'] || '2.1.0'
|
12
12
|
gem 'hanami-controller', ENV['HANAMI_VERSION'] || '2.1.0'
|
13
13
|
gem 'hanami-router', ENV['HANAMI_VERSION'] || '2.1.0'
|
14
|
+
|
15
|
+
gem 'dry-logger', '1.0.3'
|
14
16
|
end
|
15
17
|
|
18
|
+
gem 'concurrent-ruby', '1.3.4'
|
19
|
+
|
16
20
|
gem 'roda'
|
17
21
|
|
18
22
|
gem 'rails-dom-testing', '~> 2.2'
|
data/README.md
CHANGED
@@ -122,8 +122,18 @@ RSpec::OpenAPI.path = -> (example) {
|
|
122
122
|
end
|
123
123
|
}
|
124
124
|
|
125
|
+
# Change the default title of the generated schema
|
125
126
|
RSpec::OpenAPI.title = 'OpenAPI Documentation'
|
126
127
|
|
128
|
+
# Or generate individual titles for your partial schema files, given an RSpec example
|
129
|
+
RSpec::OpenAPI.title = -> (example) {
|
130
|
+
case example.file_path
|
131
|
+
when %r[spec/requests/api/v1/] then 'API v1 Documentation'
|
132
|
+
when %r[spec/requests/api/v2/] then 'API v2 Documentation'
|
133
|
+
else 'OpenAPI Documentation'
|
134
|
+
end
|
135
|
+
}
|
136
|
+
|
127
137
|
# Disable generating `example`
|
128
138
|
RSpec::OpenAPI.enable_example = false
|
129
139
|
|
@@ -12,10 +12,10 @@ class << RSpec::OpenAPI::Extractors::Rails = Object.new
|
|
12
12
|
|
13
13
|
route, path = find_rails_route(fixed_request)
|
14
14
|
|
15
|
-
raise "No route matched for #{fixed_request.request_method} #{fixed_request.path_info}" if route.nil?
|
16
|
-
|
17
15
|
return RSpec::OpenAPI::Extractors::Rack.request_attributes(request, example) unless path
|
18
16
|
|
17
|
+
raise "No route matched for #{fixed_request.request_method} #{fixed_request.path_info}" if route.nil?
|
18
|
+
|
19
19
|
metadata = example.metadata[:openapi] || {}
|
20
20
|
summary = metadata[:summary] || RSpec::OpenAPI.summary_builder.call(example)
|
21
21
|
tags = metadata[:tags] || RSpec::OpenAPI.tags_builder.call(example)
|
data/lib/rspec/openapi/record.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
RSpec::OpenAPI::Record = Struct.new(
|
4
|
+
:title, # @param [String] - "API Documentation - Statuses"
|
4
5
|
:http_method, # @param [String] - "GET"
|
5
6
|
:path, # @param [String] - "/v1/status/:id"
|
6
7
|
:path_params, # @param [Hash] - {:controller=>"v1/statuses", :action=>"create", :id=>"1"}
|
@@ -11,6 +11,7 @@ class << RSpec::OpenAPI::RecordBuilder = Object.new
|
|
11
11
|
request, response = extractor.request_response(context)
|
12
12
|
return if request.nil?
|
13
13
|
|
14
|
+
title = RSpec::OpenAPI.title.then { |t| t.is_a?(Proc) ? t.call(example) : t }
|
14
15
|
path, summary, tags, operation_id, required_request_params, raw_path_params, description, security, deprecated =
|
15
16
|
extractor.request_attributes(request, example)
|
16
17
|
|
@@ -19,6 +20,7 @@ class << RSpec::OpenAPI::RecordBuilder = Object.new
|
|
19
20
|
request_headers, response_headers = extract_headers(request, response)
|
20
21
|
|
21
22
|
RSpec::OpenAPI::Record.new(
|
23
|
+
title: title,
|
22
24
|
http_method: request.method,
|
23
25
|
path: path,
|
24
26
|
path_params: raw_path_params,
|
@@ -16,7 +16,7 @@ class RSpec::OpenAPI::ResultRecorder
|
|
16
16
|
puts "WARNING: Unable to load #{config_file}: #{e}"
|
17
17
|
end
|
18
18
|
|
19
|
-
title =
|
19
|
+
title = records.first.title
|
20
20
|
RSpec::OpenAPI::SchemaFile.new(path).edit do |spec|
|
21
21
|
schema = RSpec::OpenAPI::DefaultSchema.build(title)
|
22
22
|
schema[:info].merge!(RSpec::OpenAPI.info)
|
@@ -36,7 +36,7 @@ class << RSpec::OpenAPI::SchemaBuilder = Object.new
|
|
36
36
|
security: record.security,
|
37
37
|
deprecated: record.deprecated ? true : nil,
|
38
38
|
parameters: build_parameters(record),
|
39
|
-
requestBody: http_method
|
39
|
+
requestBody: include_nil_request_body?(http_method) ? nil : build_request_body(record),
|
40
40
|
responses: {
|
41
41
|
record.status.to_s => response,
|
42
42
|
},
|
@@ -48,6 +48,10 @@ class << RSpec::OpenAPI::SchemaBuilder = Object.new
|
|
48
48
|
|
49
49
|
private
|
50
50
|
|
51
|
+
def include_nil_request_body?(http_method)
|
52
|
+
%w[delete get].include?(http_method)
|
53
|
+
end
|
54
|
+
|
51
55
|
def enrich_with_required_keys(obj)
|
52
56
|
obj[:required] = obj[:properties]&.keys || []
|
53
57
|
obj
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-openapi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.18.
|
4
|
+
version: 0.18.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Takashi Kokubun
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2025-02-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: actionpack
|
@@ -109,7 +109,7 @@ licenses:
|
|
109
109
|
metadata:
|
110
110
|
homepage_uri: https://github.com/exoego/rspec-openapi
|
111
111
|
source_code_uri: https://github.com/exoego/rspec-openapi
|
112
|
-
changelog_uri: https://github.com/exoego/rspec-openapi/releases/tag/v0.18.
|
112
|
+
changelog_uri: https://github.com/exoego/rspec-openapi/releases/tag/v0.18.4
|
113
113
|
rubygems_mfa_required: 'true'
|
114
114
|
post_install_message:
|
115
115
|
rdoc_options: []
|