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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0d269feb84050ecb4ccc68924f76ae57ff4404521c22dc6cc004a177a579138b
4
- data.tar.gz: 7df64e4c1ec76e652039e952b66d10322d3fa56f9a8af125da7872bade8ae2ad
3
+ metadata.gz: e2d47641978a7e3644aefc735a5ff71495bd12ab22d3371ff386d5733226afea
4
+ data.tar.gz: ccd481a8593efa2a9d0db0cc10a7bb751df1cefac913b44aa93cdc70e7309d0b
5
5
  SHA512:
6
- metadata.gz: bbb3af75f12db96f24941fb6f14112fa860ff98a23b44fecb9a2efb87974dfdb68d11afa113cedea15761dd59b33a621357a1e829613c61235338bf436d09965
7
- data.tar.gz: 552c01a691716245c43c186cc913e26578d287c54e005633901da94e286694e1b83f47a0a438aebd18a0b6b8a1b6d7cb3dd1afe21faef87dae3765613ebef57f
6
+ metadata.gz: '097a157b4b7c17a1bef1aeb949d41507e09aa72f43dba5158b4a50b0659e44470b59e29d4609d24f04f4936a43e867a4e85834c0cdaa6ddde1096d304d194530'
7
+ data.tar.gz: eb1a0c743fb8b64edf56d5a67165ef77afc6c0b48317c0bdfcda7449b1322591fd1c0539b9c4c5992efbab26c6fb3928ec156bcfa137200dce4535b35e0d85b6
@@ -19,6 +19,7 @@ jobs:
19
19
  - ruby:2.5
20
20
  - ruby:2.6
21
21
  - ruby:2.7
22
+ - ruby:3.0
22
23
  steps:
23
24
  - uses: actions/checkout@v2
24
25
  - name: bundle install
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
@@ -4,6 +4,7 @@ class << RSpec::OpenAPI::DefaultSchema = Object.new
4
4
  openapi: '3.0.3',
5
5
  info: {
6
6
  title: title,
7
+ version: RSpec::OpenAPI.application_version,
7
8
  },
8
9
  paths: {},
9
10
  }.freeze
@@ -13,6 +13,7 @@ class << RSpec::OpenAPI::RecordBuilder = Object.new
13
13
  request = context.request
14
14
  response = context.response
15
15
  end
16
+ return if request.nil?
16
17
 
17
18
  # Generate `path` and `summary` in a framework-friendly manner when possible
18
19
  if rails?
@@ -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
- { type: 'null' }
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
@@ -1,5 +1,5 @@
1
1
  module RSpec
2
2
  module OpenAPI
3
- VERSION = '0.3.8'
3
+ VERSION = '0.3.13'
4
4
  end
5
5
  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.8
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: 2020-11-13 00:00:00.000000000 Z
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.1.4
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: []