rspec-openapi 0.3.8 → 0.3.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +1 -0
- data/CHANGELOG.md +25 -0
- data/README.md +3 -0
- data/lib/rspec/openapi.rb +2 -1
- data/lib/rspec/openapi/default_schema.rb +1 -0
- data/lib/rspec/openapi/record_builder.rb +1 -0
- data/lib/rspec/openapi/schema_builder.rb +14 -2
- data/lib/rspec/openapi/version.rb +1 -1
- data/test.png +0 -0
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e2d47641978a7e3644aefc735a5ff71495bd12ab22d3371ff386d5733226afea
|
4
|
+
data.tar.gz: ccd481a8593efa2a9d0db0cc10a7bb751df1cefac913b44aa93cdc70e7309d0b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '097a157b4b7c17a1bef1aeb949d41507e09aa72f43dba5158b4a50b0659e44470b59e29d4609d24f04f4936a43e867a4e85834c0cdaa6ddde1096d304d194530'
|
7
|
+
data.tar.gz: eb1a0c743fb8b64edf56d5a67165ef77afc6c0b48317c0bdfcda7449b1322591fd1c0539b9c4c5992efbab26c6fb3928ec156bcfa137200dce4535b35e0d85b6
|
data/.github/workflows/test.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,28 @@
|
|
1
|
+
## v0.3.13
|
2
|
+
|
3
|
+
* Avoid crashing when there's no request made in a spec
|
4
|
+
[#19](https://github.com/k0kubun/rspec-openapi/pull/19)
|
5
|
+
|
6
|
+
## v0.3.12
|
7
|
+
|
8
|
+
* Generate `nullable: true` for null fields in schema
|
9
|
+
[#18](https://github.com/k0kubun/rspec-openapi/pull/18)
|
10
|
+
|
11
|
+
## v0.3.11
|
12
|
+
|
13
|
+
* Show a filename as an `example` for `ActionDispatch::Http::UploadedFile`
|
14
|
+
[#17](https://github.com/k0kubun/rspec-openapi/pull/17)
|
15
|
+
|
16
|
+
## v0.3.10
|
17
|
+
|
18
|
+
* Add `info.version`
|
19
|
+
[#16](https://github.com/k0kubun/rspec-openapi/pull/16)
|
20
|
+
|
21
|
+
## v0.3.9
|
22
|
+
|
23
|
+
* Initial support for multipart/form-data
|
24
|
+
[#12](https://github.com/k0kubun/rspec-openapi/pull/12)
|
25
|
+
|
1
26
|
## v0.3.8
|
2
27
|
|
3
28
|
* Generate `type: 'number', format: 'float'` instead of `type: 'float'` for Float
|
data/README.md
CHANGED
@@ -111,6 +111,9 @@ RSpec::OpenAPI.path = 'doc/schema.yaml'
|
|
111
111
|
# Disable generating `example`
|
112
112
|
RSpec::OpenAPI.enable_example = false
|
113
113
|
|
114
|
+
# Change `info.version`
|
115
|
+
RSpec::OpenAPI.application_version = '1.0.0'
|
116
|
+
|
114
117
|
# Generate a comment on top of a schema file
|
115
118
|
RSpec::OpenAPI.comment = <<~EOS
|
116
119
|
This file is auto-generated by rspec-openapi https://github.com/k0kubun/rspec-openapi
|
data/lib/rspec/openapi.rb
CHANGED
@@ -6,8 +6,9 @@ module RSpec::OpenAPI
|
|
6
6
|
@comment = nil
|
7
7
|
@enable_example = true
|
8
8
|
@description_builder = -> (example) { example.description }
|
9
|
+
@application_version = '1.0.0'
|
9
10
|
|
10
11
|
class << self
|
11
|
-
attr_accessor :path, :comment, :enable_example, :description_builder
|
12
|
+
attr_accessor :path, :comment, :enable_example, :description_builder, :application_version
|
12
13
|
end
|
13
14
|
end
|
@@ -72,7 +72,7 @@ class << RSpec::OpenAPI::SchemaBuilder = Object.new
|
|
72
72
|
content: {
|
73
73
|
normalize_content_type(record.request_content_type) => {
|
74
74
|
schema: build_property(record.request_params),
|
75
|
-
example: (record.request_params if example_enabled?),
|
75
|
+
example: (build_example(record.request_params) if example_enabled?),
|
76
76
|
}.compact
|
77
77
|
}
|
78
78
|
}
|
@@ -108,8 +108,10 @@ class << RSpec::OpenAPI::SchemaBuilder = Object.new
|
|
108
108
|
{ type: 'array' }
|
109
109
|
when Hash
|
110
110
|
{ type: 'object' }
|
111
|
+
when ActionDispatch::Http::UploadedFile
|
112
|
+
{ type: 'string', format: 'binary' }
|
111
113
|
when NilClass
|
112
|
-
{
|
114
|
+
{ nullable: true }
|
113
115
|
else
|
114
116
|
raise NotImplementedError, "type detection is not implemented for: #{value.inspect}"
|
115
117
|
end
|
@@ -124,6 +126,16 @@ class << RSpec::OpenAPI::SchemaBuilder = Object.new
|
|
124
126
|
end
|
125
127
|
end
|
126
128
|
|
129
|
+
def build_example(value)
|
130
|
+
return nil if value.nil?
|
131
|
+
value = value.dup
|
132
|
+
value.each do |key, v|
|
133
|
+
if v.is_a?(ActionDispatch::Http::UploadedFile)
|
134
|
+
value[key] = v.original_filename
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
127
139
|
def normalize_path(path)
|
128
140
|
path.gsub(%r|/:([^:/]+)|, '/{\1}')
|
129
141
|
end
|
data/test.png
ADDED
Binary file
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-openapi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Takashi Kokubun
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-02-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionpack
|
@@ -66,6 +66,7 @@ files:
|
|
66
66
|
- lib/rspec/openapi/schema_merger.rb
|
67
67
|
- lib/rspec/openapi/version.rb
|
68
68
|
- rspec-openapi.gemspec
|
69
|
+
- test.png
|
69
70
|
homepage: https://github.com/k0kubun/rspec-openapi
|
70
71
|
licenses:
|
71
72
|
- MIT
|
@@ -73,7 +74,7 @@ metadata:
|
|
73
74
|
homepage_uri: https://github.com/k0kubun/rspec-openapi
|
74
75
|
source_code_uri: https://github.com/k0kubun/rspec-openapi
|
75
76
|
changelog_uri: https://github.com/k0kubun/rspec-openapi/blob/master/CHANGELOG.md
|
76
|
-
post_install_message:
|
77
|
+
post_install_message:
|
77
78
|
rdoc_options: []
|
78
79
|
require_paths:
|
79
80
|
- lib
|
@@ -88,8 +89,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
88
89
|
- !ruby/object:Gem::Version
|
89
90
|
version: '0'
|
90
91
|
requirements: []
|
91
|
-
rubygems_version: 3.
|
92
|
-
signing_key:
|
92
|
+
rubygems_version: 3.2.6
|
93
|
+
signing_key:
|
93
94
|
specification_version: 4
|
94
95
|
summary: Generate OpenAPI schema from RSpec request specs
|
95
96
|
test_files: []
|