rspec-openapi 0.3.7 → 0.3.12

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: 31d1b980670f03ab900ae31ecd241ce6a2b44edfbbc79839c9dc948c22ffa6b0
4
- data.tar.gz: 51eead9afb87f8303cdb1d5b4fcb8331bfc01f534127c038be1394e6e598d9dc
3
+ metadata.gz: 727ee90aa68d99aa8748b948fc70449163127e0ea0d0b1bfd5eadc5a1cbc8c2c
4
+ data.tar.gz: 2d9746ec612b49af4c9482ffe608489e4ac55416aeed8e774ae642cf62af77ce
5
5
  SHA512:
6
- metadata.gz: ddd8900e0365e487f42411e3cbfc7a8c23d33cdd0376da9d705311e8ba7e5c8d95e97859a8b10e0e1b5f83da2e6a1e4166993adc6a8dddb704cc3949a02eae7a
7
- data.tar.gz: 3bd25b3e5d2ce70c0961d3bcd471d0c6ff6d36e5bc2a7d72fd43f594f698a56a38774bc0d298a936987db54eca6995f098817adbabf232433dc4f2f26232f4f9
6
+ metadata.gz: 3af2e86ba1321f7ab8cade64796a6e13a7f39f3d3363212dc6e93a550a2615d5fbed13e239dc2a78d54d757d4d0ed875a636af9c45a65d4b891731772ddeab91
7
+ data.tar.gz: daa2a965e6b8b0c2e53fded5ae6de2980c277712b3230077d71ba39e6da977e2fb8fbd5995e13a018595473c034c0154e017b69a7e22e16bad555b3d14a67d6f
@@ -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
@@ -1,3 +1,28 @@
1
+ ## v0.3.12
2
+
3
+ * Generate `nullable: true` for null fields in schema
4
+ [#18](https://github.com/k0kubun/rspec-openapi/pull/18)
5
+
6
+ ## v0.3.11
7
+
8
+ * Show a filename as an `example` for `ActionDispatch::Http::UploadedFile`
9
+ [#17](https://github.com/k0kubun/rspec-openapi/pull/17)
10
+
11
+ ## v0.3.10
12
+
13
+ * Add `info.version`
14
+ [#16](https://github.com/k0kubun/rspec-openapi/pull/16)
15
+
16
+ ## v0.3.9
17
+
18
+ * Initial support for multipart/form-data
19
+ [#12](https://github.com/k0kubun/rspec-openapi/pull/12)
20
+
21
+ ## v0.3.8
22
+
23
+ * Generate `type: 'number', format: 'float'` instead of `type: 'float'` for Float
24
+ [#11](https://github.com/k0kubun/rspec-openapi/issues/11)
25
+
1
26
  ## v0.3.7
2
27
 
3
28
  * Classify tag names and remove controller names from summary in Rails
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
@@ -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
@@ -72,14 +72,15 @@ 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
  }
79
79
  end
80
80
 
81
81
  def build_property(value)
82
- property = { type: build_type(value) }
82
+ property = build_type(value)
83
+
83
84
  case value
84
85
  when Array
85
86
  property[:items] = build_property(value.first)
@@ -96,19 +97,21 @@ class << RSpec::OpenAPI::SchemaBuilder = Object.new
96
97
  def build_type(value)
97
98
  case value
98
99
  when String
99
- 'string'
100
- when Float
101
- 'float'
100
+ { type: 'string' }
102
101
  when Integer
103
- 'integer'
102
+ { type: 'integer' }
103
+ when Float
104
+ { type: 'number', format: 'float' }
104
105
  when TrueClass, FalseClass
105
- 'boolean'
106
+ { type: 'boolean' }
106
107
  when Array
107
- 'array'
108
+ { type: 'array' }
108
109
  when Hash
109
- 'object'
110
+ { type: 'object' }
111
+ when ActionDispatch::Http::UploadedFile
112
+ { type: 'string', format: 'binary' }
110
113
  when NilClass
111
- 'null'
114
+ { nullable: true }
112
115
  else
113
116
  raise NotImplementedError, "type detection is not implemented for: #{value.inspect}"
114
117
  end
@@ -123,6 +126,16 @@ class << RSpec::OpenAPI::SchemaBuilder = Object.new
123
126
  end
124
127
  end
125
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
+
126
139
  def normalize_path(path)
127
140
  path.gsub(%r|/:([^:/]+)|, '/{\1}')
128
141
  end
@@ -1,5 +1,5 @@
1
1
  module RSpec
2
2
  module OpenAPI
3
- VERSION = '0.3.7'
3
+ VERSION = '0.3.12'
4
4
  end
5
5
  end
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.7
4
+ version: 0.3.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takashi Kokubun
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-10-23 00:00:00.000000000 Z
11
+ date: 2021-01-27 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
@@ -88,7 +89,7 @@ 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.2
92
+ rubygems_version: 3.2.6
92
93
  signing_key:
93
94
  specification_version: 4
94
95
  summary: Generate OpenAPI schema from RSpec request specs