open_api_annotator 0.6.1 → 0.6.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dde2d52c30c7150fb7545c2f596c0e4efb03d34b681e3425e8756d42d7fb4cba
4
- data.tar.gz: f642b9b214e53220e18cf68902ea5551982b2442605efafdd3db49dc1dd2b281
3
+ metadata.gz: a53663269a69d9eca0b1148da5698071fcfeba3d2457f4614c3e76303bb28aa9
4
+ data.tar.gz: 3c1db3245019f65a0f1936cb47911c717cf9b1a024d362c2ea916621dca78418
5
5
  SHA512:
6
- metadata.gz: a977753c408743b9b632bdad47a5f953f7db1ec0ecf88789da40119a10b22e1b4dd386f653d78c02c768ab5790d7f8953f2a0dbbccf8d630aa5ef8863305ddb3
7
- data.tar.gz: '029cdffd9e9105a742ba3756e7fc927be2d0ea09d744587bb0c322f1c18945048be0e533d2822a9e258862a6f6d92b23802ff0d033df845509b0457881785cf5'
6
+ metadata.gz: 24b7421c28a82949a4e89fa68c1f5e12e97d48d19c8f0a45e104405af6b7636a0f5cb9fed57f1f01dbff7afbe3e5a9a714f743a90e8898ca42f285479de6d1d8
7
+ data.tar.gz: d686bed20207c8c59b89b5481aa9c2dad353d4a04b537da660e72246e27b362c72ab550a5b1fa8cffe82446d50e34c3f4577b6fe2db888197a1f9ff27581e25c
@@ -4,13 +4,19 @@ jobs:
4
4
  test:
5
5
  strategy:
6
6
  matrix:
7
- ruby: ["3.0", "3.1", "3.2"]
7
+ ruby: ["3.3", "3.4", "4.0"]
8
8
  gemfile: [Gemfile]
9
9
  include:
10
- - ruby: "3.2"
10
+ - ruby: "3.3"
11
+ gemfile: "gemfiles/rails-8.0.gemfile"
12
+ - ruby: "3.3"
13
+ gemfile: "gemfiles/rails-7.2.gemfile"
14
+ - ruby: "3.3"
15
+ gemfile: "gemfiles/rails-7.1.gemfile"
16
+ - ruby: "3.3"
17
+ gemfile: "gemfiles/rails-7.0.gemfile"
18
+ - ruby: "4.0"
11
19
  gemfile: "gemfiles/rails-7.0.gemfile"
12
- - ruby: "3.2"
13
- gemfile: "gemfiles/rails-6.1.gemfile"
14
20
 
15
21
  env:
16
22
  BUNDLE_GEMFILE: "${{ matrix.gemfile }}"
@@ -23,7 +29,3 @@ jobs:
23
29
  ruby-version: ${{ matrix.ruby }}
24
30
  bundler-cache: true
25
31
  - run: bundle exec rake
26
- - name: Send coverage
27
- uses: paambaati/codeclimate-action@v5
28
- env:
29
- CC_TEST_REPORTER_ID: 921d046db793707b7d0c0d1305970a137fdf98fbc6ceeb6c355c44757040244f
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 3.2.2
1
+ 4.0.9
data/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  ## Not released yet
2
2
 
3
+ ## 0.6.2
4
+
5
+ - Fix `rake api_spec` raising `NoMethodError` on Rails 7.0 or later https://github.com/wantedly/open_api_annotator/pull/20
6
+ - Fix `$ref` of `belongs_to` with `serializer:` option being an array like `#/components/schemas/["User"]` https://github.com/wantedly/open_api_annotator/pull/20
7
+ - Skip `has_many` annotated with a non-array type (e.g. `type: User`) or an empty array with a warning, instead of raising an error or emitting a broken `$ref` https://github.com/wantedly/open_api_annotator/pull/20
8
+ - Require open_api >= 0.6.3 https://github.com/wantedly/open_api_annotator/pull/20
9
+ - Bump Ruby and Rails https://github.com/wantedly/open_api_annotator/pull/20
10
+ - Supported Rubies: 3.3, 3.4, 4.0
11
+ - Supported Rails: 7.0, 7.1, 7.2, 8.0, 8.1
12
+
3
13
  ## 0.6.1
4
14
 
5
15
  - Reflect ownership transfer https://github.com/wantedly/open_api_annotator/pull/18
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # OpenApiAnnotator [![Gem Version](https://badge.fury.io/rb/open_api_annotator.svg)](https://badge.fury.io/rb/open_api_annotator) [![Build Status](https://travis-ci.org/wantedly/open_api_annotator.svg?branch=master)](https://travis-ci.org/wantedly/open_api_annotator) [![Maintainability](https://api.codeclimate.com/v1/badges/8be7a273496459c62190/maintainability)](https://codeclimate.com/github/wantedly/open_api_annotator/maintainability) [![Test Coverage](https://api.codeclimate.com/v1/badges/8be7a273496459c62190/test_coverage)](https://codeclimate.com/github/wantedly/open_api_annotator/test_coverage)
1
+ # OpenApiAnnotator [![Gem Version](https://badge.fury.io/rb/open_api_annotator.svg)](https://badge.fury.io/rb/open_api_annotator) [![Build Status](https://travis-ci.org/wantedly/open_api_annotator.svg?branch=master)](https://travis-ci.org/wantedly/open_api_annotator)
2
2
 
3
3
  OpenApiAnnotator realizes to generate OpenAPI spec by annotating to controllers and serializers.
4
4
  If you use ActiveModelSerializer, this is the best way to generate OpenAPI spec.
@@ -5,4 +5,4 @@ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
5
5
  # Specify your gem's dependencies in open_api_annotator.gemspec
6
6
  gemspec path: '..'
7
7
 
8
- gem 'railties', '~> 6.1.0'
8
+ gem 'railties', '~> 7.1.0'
@@ -0,0 +1,8 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in open_api_annotator.gemspec
6
+ gemspec path: '..'
7
+
8
+ gem 'railties', '~> 7.2.0'
@@ -0,0 +1,8 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in open_api_annotator.gemspec
6
+ gemspec path: '..'
7
+
8
+ gem 'railties', '~> 8.0.0'
@@ -56,8 +56,12 @@ module OpenApiAnnotator
56
56
  properties = {}
57
57
  serializer.open_api_has_many_associations.each do |association|
58
58
  next unless association.valid?
59
- content = association.type.first
60
- return unless content
59
+ # Calling `first` on a non-array type (e.g. an ActiveRecord model) would run a query
60
+ content = association.type.first if association.type.is_a?(Array)
61
+ unless content
62
+ warn "Skipped #{serializer.name}##{association.name}: type of has_many should be an array with one element, but got #{association.type}."
63
+ next
64
+ end
61
65
  content_name = content.try(:name) || content.to_s
62
66
  properties[association.name.to_sym] = OpenApi::Schema.new(
63
67
  type: "array",
@@ -140,7 +140,7 @@ module OpenApiAnnotator
140
140
  def find_all
141
141
  @routes ||= Rails.application.routes.routes.routes.map do |route|
142
142
  parameters = []
143
- path = PathResolver.new.resolve(route.path.ast, parameters)
143
+ path = PathResolver.new.resolve(route.path.spec, parameters)
144
144
  controller = route.requirements[:controller]
145
145
  action = route.requirements[:action]
146
146
  Route.new(http_verb: route.verb, path: path, controller_name: controller, action_name: action, parameters: parameters)
@@ -77,7 +77,7 @@ module OpenApiAnnotator
77
77
  reflection.is_a?(ActiveModel::Serializer::BelongsToReflection)
78
78
  }.map do |reflection|
79
79
  serializer_class = reflection.options[:serializer]
80
- type = serializer_class ? [serializer_class.open_api_resource_name] : reflection.options[:type]
80
+ type = serializer_class ? serializer_class.open_api_resource_name : reflection.options[:type]
81
81
  Association.new(reflection.name.to_sym, type, reflection.options[:nullable])
82
82
  end
83
83
  end
@@ -1,3 +1,3 @@
1
1
  module OpenApiAnnotator
2
- VERSION = "0.6.1"
2
+ VERSION = "0.6.2"
3
3
  end
@@ -21,14 +21,13 @@ Gem::Specification.new do |spec|
21
21
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
22
  spec.require_paths = ["lib"]
23
23
 
24
- spec.add_dependency "open_api", ">= 0.5.0"
24
+ spec.add_dependency "open_api", ">= 0.6.3"
25
25
  spec.add_dependency "active_model_serializers", "~> 0.10.0"
26
26
 
27
- rails_versions = ['>= 5.0', '< 7.2']
27
+ rails_versions = ['>= 5.0', '< 8.2']
28
28
  spec.add_dependency "actionpack", rails_versions
29
29
  spec.add_dependency "railties", rails_versions
30
30
 
31
- spec.add_development_dependency "bundler", "~> 2.0"
32
31
  spec.add_development_dependency "rake", "~> 13.0"
33
32
  spec.add_development_dependency "rspec", "~> 3.0"
34
33
  spec.add_development_dependency "pry"
metadata CHANGED
@@ -1,15 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: open_api_annotator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kent Nagata
8
8
  - Wantedly, Inc.
9
- autorequire:
10
9
  bindir: exe
11
10
  cert_chain: []
12
- date: 2023-11-10 00:00:00.000000000 Z
11
+ date: 1980-01-02 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: open_api
@@ -17,14 +16,14 @@ dependencies:
17
16
  requirements:
18
17
  - - ">="
19
18
  - !ruby/object:Gem::Version
20
- version: 0.5.0
19
+ version: 0.6.3
21
20
  type: :runtime
22
21
  prerelease: false
23
22
  version_requirements: !ruby/object:Gem::Requirement
24
23
  requirements:
25
24
  - - ">="
26
25
  - !ruby/object:Gem::Version
27
- version: 0.5.0
26
+ version: 0.6.3
28
27
  - !ruby/object:Gem::Dependency
29
28
  name: active_model_serializers
30
29
  requirement: !ruby/object:Gem::Requirement
@@ -48,7 +47,7 @@ dependencies:
48
47
  version: '5.0'
49
48
  - - "<"
50
49
  - !ruby/object:Gem::Version
51
- version: '7.2'
50
+ version: '8.2'
52
51
  type: :runtime
53
52
  prerelease: false
54
53
  version_requirements: !ruby/object:Gem::Requirement
@@ -58,7 +57,7 @@ dependencies:
58
57
  version: '5.0'
59
58
  - - "<"
60
59
  - !ruby/object:Gem::Version
61
- version: '7.2'
60
+ version: '8.2'
62
61
  - !ruby/object:Gem::Dependency
63
62
  name: railties
64
63
  requirement: !ruby/object:Gem::Requirement
@@ -68,7 +67,7 @@ dependencies:
68
67
  version: '5.0'
69
68
  - - "<"
70
69
  - !ruby/object:Gem::Version
71
- version: '7.2'
70
+ version: '8.2'
72
71
  type: :runtime
73
72
  prerelease: false
74
73
  version_requirements: !ruby/object:Gem::Requirement
@@ -78,21 +77,7 @@ dependencies:
78
77
  version: '5.0'
79
78
  - - "<"
80
79
  - !ruby/object:Gem::Version
81
- version: '7.2'
82
- - !ruby/object:Gem::Dependency
83
- name: bundler
84
- requirement: !ruby/object:Gem::Requirement
85
- requirements:
86
- - - "~>"
87
- - !ruby/object:Gem::Version
88
- version: '2.0'
89
- type: :development
90
- prerelease: false
91
- version_requirements: !ruby/object:Gem::Requirement
92
- requirements:
93
- - - "~>"
94
- - !ruby/object:Gem::Version
95
- version: '2.0'
80
+ version: '8.2'
96
81
  - !ruby/object:Gem::Dependency
97
82
  name: rake
98
83
  requirement: !ruby/object:Gem::Requirement
@@ -184,8 +169,10 @@ files:
184
169
  - Rakefile
185
170
  - bin/console
186
171
  - bin/setup
187
- - gemfiles/rails-6.1.gemfile
188
172
  - gemfiles/rails-7.0.gemfile
173
+ - gemfiles/rails-7.1.gemfile
174
+ - gemfiles/rails-7.2.gemfile
175
+ - gemfiles/rails-8.0.gemfile
189
176
  - lib/open_api_annotator.rb
190
177
  - lib/open_api_annotator/association.rb
191
178
  - lib/open_api_annotator/attribute.rb
@@ -209,7 +196,6 @@ homepage: https://github.com/wantedly/open_api_annotator
209
196
  licenses:
210
197
  - MIT
211
198
  metadata: {}
212
- post_install_message:
213
199
  rdoc_options: []
214
200
  require_paths:
215
201
  - lib
@@ -224,8 +210,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
224
210
  - !ruby/object:Gem::Version
225
211
  version: '0'
226
212
  requirements: []
227
- rubygems_version: 3.4.10
228
- signing_key:
213
+ rubygems_version: 4.0.20
229
214
  specification_version: 4
230
215
  summary: OpenApi spec generation by bottom-up.
231
216
  test_files: []