Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@ jobs:
test:
strategy:
matrix:
ruby: ["3.0", "3.1", "3.2"]
ruby: ["3.3", "3.4", "4.0"]
gemfile: [Gemfile]
include:
- ruby: "3.2"
- ruby: "3.3"
gemfile: "gemfiles/rails-8.0.gemfile"
- ruby: "3.3"
gemfile: "gemfiles/rails-7.2.gemfile"
- ruby: "3.3"
gemfile: "gemfiles/rails-7.1.gemfile"
- ruby: "3.3"
gemfile: "gemfiles/rails-7.0.gemfile"
- ruby: "3.2"
gemfile: "gemfiles/rails-6.1.gemfile"

env:
BUNDLE_GEMFILE: "${{ matrix.gemfile }}"
Expand All @@ -23,7 +27,3 @@ jobs:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
- run: bundle exec rake
- name: Send coverage
uses: paambaati/codeclimate-action@v5
env:
CC_TEST_REPORTER_ID: 921d046db793707b7d0c0d1305970a137fdf98fbc6ceeb6c355c44757040244f
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.2.2
4.0.9
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
## Not released yet

## 0.6.2

- Fix `rake api_spec` raising `NoMethodError` on Rails 7.0 or later https://github.com/wantedly/open_api_annotator/pull/20
- Require open_api >= 0.6.3 https://github.com/wantedly/open_api_annotator/pull/20
- Bump Ruby and Rails https://github.com/wantedly/open_api_annotator/pull/20
- Supported Rubies: 3.3, 3.4, 4.0
- Supported Rails: 7.0, 7.1, 7.2, 8.0, 8.1

## 0.6.1

- Reflect ownership transfer https://github.com/wantedly/open_api_annotator/pull/18
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# 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)
# 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)

OpenApiAnnotator realizes to generate OpenAPI spec by annotating to controllers and serializers.
If you use ActiveModelSerializer, this is the best way to generate OpenAPI spec.
Expand Down
2 changes: 1 addition & 1 deletion gemfiles/rails-6.1.gemfile → gemfiles/rails-7.1.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
# Specify your gem's dependencies in open_api_annotator.gemspec
gemspec path: '..'

gem 'railties', '~> 6.1.0'
gem 'railties', '~> 7.1.0'
8 changes: 8 additions & 0 deletions gemfiles/rails-7.2.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
source "https://rubygems.org"

git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }

# Specify your gem's dependencies in open_api_annotator.gemspec
gemspec path: '..'

gem 'railties', '~> 7.2.0'
8 changes: 8 additions & 0 deletions gemfiles/rails-8.0.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
source "https://rubygems.org"

git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }

# Specify your gem's dependencies in open_api_annotator.gemspec
gemspec path: '..'

gem 'railties', '~> 8.0.0'
2 changes: 1 addition & 1 deletion lib/open_api_annotator/paths_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ class RoutesFinder
def find_all
@routes ||= Rails.application.routes.routes.routes.map do |route|
parameters = []
path = PathResolver.new.resolve(route.path.ast, parameters)
path = PathResolver.new.resolve(route.path.spec, parameters)
controller = route.requirements[:controller]
action = route.requirements[:action]
Route.new(http_verb: route.verb, path: path, controller_name: controller, action_name: action, parameters: parameters)
Expand Down
2 changes: 1 addition & 1 deletion lib/open_api_annotator/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module OpenApiAnnotator
VERSION = "0.6.1"
VERSION = "0.6.2"
end
5 changes: 2 additions & 3 deletions open_api_annotator.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,13 @@ Gem::Specification.new do |spec|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
spec.require_paths = ["lib"]

spec.add_dependency "open_api", ">= 0.5.0"
spec.add_dependency "open_api", ">= 0.6.3"
spec.add_dependency "active_model_serializers", "~> 0.10.0"

rails_versions = ['>= 5.0', '< 7.2']
rails_versions = ['>= 5.0', '< 8.2']
spec.add_dependency "actionpack", rails_versions
spec.add_dependency "railties", rails_versions

spec.add_development_dependency "bundler", "~> 2.0"
spec.add_development_dependency "rake", "~> 13.0"
spec.add_development_dependency "rspec", "~> 3.0"
spec.add_development_dependency "pry"
Expand Down
36 changes: 35 additions & 1 deletion spec/open_api_annotator/routes_finder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
let(:journey_route) { double(:journey_route) }

before do
allow(path).to receive(:ast).and_return(double(:ast))
allow(path).to receive(:spec).and_return(double(:spec))
allow(journey_route).to receive(:path).and_return(path)
allow(journey_route).to receive(:verb).and_return("GET")
allow(journey_route).to receive(:requirements).and_return({ controller: "/api/v1/books", action: "show" })
Expand All @@ -36,6 +36,40 @@
)
end
end

describe "#find_all with routes drawn by Rails" do
subject { described_class.new.find_all }

let(:rails_application) { double(:rails_application) }
let(:route_set) do
ActionDispatch::Routing::RouteSet.new.tap do |route_set|
route_set.draw do
get "/api/v1/books/:book_id/authors/:id", to: "api/v1/authors#show"
end
# Rails 7.0+ wraps Pattern#ast in Journey::Ast and clears it on eager_load!, while Pattern#spec survives both
route_set.eager_load!
end
end

before do
allow(Rails).to receive(:application).and_return(rails_application)
allow(rails_application).to receive(:routes).and_return(route_set)
end

it "resolves path and parameters from the route" do
is_expected.to match(
[
OpenApiAnnotator::Route.new(
http_verb: "GET",
path: "/api/v1/books/{book_id}/authors/{id}",
controller_name: "api/v1/authors",
action_name: "show",
parameters: [{ name: "book_id" }, { name: "id" }]
)
]
)
end
end
end

RSpec.describe OpenApiAnnotator::PathResolver do
Expand Down
Loading