Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v3.0.0 #714

Open
wants to merge 29 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
8fdb4f3
cleanup: Drop support for OpenAPI (Swagger) v2
romanblanco Jan 18, 2023
3186118
cleanup: Drop Rspec v2 support
romanblanco Jan 12, 2023
60431b1
Set swagger formatter as default for task
hashrocketeer May 5, 2023
62c0b7a
fix: correct mistage after conflict resolving
romanblanco Nov 10, 2023
80042cc
upgrade to ruby 3.0.6 and rails 7.0.4.3 in local dev
Zarthus Apr 12, 2023
0f97c42
upgrade workflow versions
Zarthus May 3, 2023
b165836
latest rails version for 7
Zarthus May 3, 2023
f286c87
remove ruby < 2.x deprecation warnings
Zarthus Jun 2, 2023
51cc7a5
cleanup: remove condition for deprecated Rails version
romanblanco Nov 10, 2023
2304440
drop using #send
kwstannard Feb 11, 2021
33d4abe
fix unpassed query params
kwstannard Sep 3, 2021
a3abbeb
fix for falsey param values
kwstannard Aug 29, 2022
ac25323
revert: removed option to use :getter
romanblanco Nov 13, 2023
cf90435
Merge pull request #693 from romanblanco/rebased-396-2
romanblanco Nov 13, 2023
39eb87d
fix README for new request_* pattern
kwstannard Nov 13, 2023
8806834
Merge pull request #694 from CredSimple/v3
romanblanco Nov 13, 2023
75a7f4e
Merge branch 'master' into v3
romanblanco Nov 13, 2023
d6407b8
fix: correct scheme path
romanblanco Nov 13, 2023
afd429f
Merge branch 'master' into v3
romanblanco Nov 28, 2023
05e84ee
Merge branch 'master' into v3
romanblanco Dec 15, 2023
089e540
Merge branch 'master' into v3
romanblanco Dec 15, 2023
aa79074
cleanup: Remove code for deprecation
romanblanco Dec 16, 2023
7dd1e2e
docs: update CHANGELOG.md
romanblanco Dec 16, 2023
cf66567
docs: note EOL date for Ruby
romanblanco Dec 16, 2023
6ea2da9
fix: rebranding Swagger to OpenAPI
romanblanco Dec 16, 2023
34e8928
remove: remove deprecation warnings mocks in tests
romanblanco Dec 17, 2023
d13b972
cleanup: remove unnecessary RAILS_VERSION constant
romanblanco Dec 18, 2023
b675303
Merge branch 'master' into v3
romanblanco Dec 19, 2023
6184a79
ci: allow misspelled words
romanblanco Dec 19, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/ISSUE_TEMPLATE/bug_report.md
Expand Up @@ -29,6 +29,5 @@ The version of are you using for:
* Ruby:

## Relates to which version of OAS (OpenAPI Specification)
- [ ] OAS2
- [ ] OAS3
- [ ] OAS3.1
1 change: 0 additions & 1 deletion .github/ISSUE_TEMPLATE/feature_request.md
Expand Up @@ -24,6 +24,5 @@ A clear and concise description of any alternative solutions or features you've
Add any other context or screenshots about the feature request here.

## Relates to which version of OAS (OpenAPI Specification)
- [ ] OAS2
- [ ] OAS3
- [ ] OAS3.1
1 change: 0 additions & 1 deletion .github/pull_request_template.md
Expand Up @@ -9,7 +9,6 @@ A clear and concise description of what the solution is.
* [ANOTHER LINK TO RELEVANT OPEN API SPECS PAGE](https://spec.openapis.org/oas/v3.1.0#schema)

### The changes I made are compatible with:
- [ ] OAS2
- [ ] OAS3
- [ ] OAS3.1

Expand Down
14 changes: 2 additions & 12 deletions .github/workflows/ruby.yml
Expand Up @@ -11,18 +11,8 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
ruby: [2.6, 2.7, 3.0, 3.1] # 2.6 is EOL March 31, 2022; kept for information only
rails: [5.2.6, 6.1.4.4, 7.0.1] # 5.2 EOL in 01 Jun 2022; kept for information only
exclude:
# excludes Rails 5.2.x on Ruby 3.0 and on 3.1
# Note that 6.0.x should also exclude 3.0 and 3.1 but we're not testing it.
- rails: 5.2.6
ruby: 3.0
- rails: 5.2.6
ruby: 3.1
# Rails 7.0.1 requires >= 2.7.0, so excluding 2.6
- rails: 7.0.1
ruby: 2.6
ruby: [3.0, 3.1, 3.2] # 3.0 EOL is 2024-03-31
rails: [6.1.4.4, 7.0.4.3]
env:
RAILS_VERSION: ${{ matrix.rails }}

Expand Down
2 changes: 1 addition & 1 deletion .ruby-version
@@ -1 +1 @@
2.7.6
3.0.6
20 changes: 19 additions & 1 deletion CHANGELOG.md
Expand Up @@ -4,6 +4,24 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [3.0.0]

### Fixed

- Dropped using #send (https://github.com/rswag/rswag/pull/396)

### Added

### Changed

- Drop support for OpenAPI v2 (Swagger) (https://github.com/rswag/rswag/pull/574)
- Drop Rspec V2 support (https://github.com/rswag/rswag/pull/636)
- upgrade to ruby 3.0.6 and rails 7.0.4.3 in local dev (https://github.com/rswag/rswag/pull/625)

### Documentation

- fix README for new request_* pattern (https://github.com/rswag/rswag/pull/694)

## [Unreleased]

### Added
Expand All @@ -18,7 +36,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

### Documentation

- Added more details about config swagger format [#698](https://github.com/rswag/rswag/pull/698)
- Added more details about config swagger format (https://github.com/rswag/rswag/pull/698)

## [2.13.0]

Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
@@ -1,5 +1,5 @@
FROM ruby:2.7
ENV RAILS_VERSION 7.0.3.1
FROM ruby:3.0
ENV RAILS_VERSION 7.0.4.3

RUN apt-get update -qq && apt-get install -y nodejs npm
# Bugfix for https://github.com/rubyjs/mini_racer/issues/220#issuecomment-1010724771
Expand Down
6 changes: 1 addition & 5 deletions Gemfile
Expand Up @@ -17,11 +17,7 @@ when '6', '7'
gem 'sqlite3', '~> 1.4.1'
end

case RUBY_VERSION.split('.').first
when '3'
gem 'net-smtp', require: false
end

gem 'net-smtp', require: false
gem 'rswag-api', path: './rswag-api'
gem 'rswag-ui', path: './rswag-ui'

Expand Down
195 changes: 92 additions & 103 deletions README.md

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions cspell.json
Expand Up @@ -21,6 +21,7 @@
"appuser",
"autoload",
"autoloadable",
"BOOKOFGREG",
"byebug",
"cacher",
"codegen",
Expand All @@ -42,6 +43,8 @@
"rdoc",
"rdoctask",
"rswag",
"rubygems",
"RUBYGEMS",
"srand",
"scrollbars",
"stylesheet",
Expand Down
Expand Up @@ -4,11 +4,11 @@
# This is used by the Swagger middleware to serve requests for API descriptions
# NOTE: If you're using rswag-specs to generate Swagger, you'll need to ensure
# that it's configured to generate files in the same folder
c.openapi_root = Rails.root.to_s + '/swagger'
c.openapi_root = Rails.root.to_s + '/openapi'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rails.root is a Pathname, so it's better to do this:

c.openapi_root = Rails.root.join('openapi').to_s


# Inject a lambda function to alter the returned Swagger prior to serialization
# Inject a lambda function to alter the returned OpenAPI prior to serialization
# The function will have access to the rack env for the current request
# For example, you could leverage this to dynamically assign the "host" property
#
#c.swagger_filter = lambda { |swagger, env| swagger['host'] = env['HTTP_HOST'] }
#c.openapi_filter = lambda { |swagger, env| swagger['host'] = env['HTTP_HOST'] }
end
22 changes: 0 additions & 22 deletions rswag-api/lib/rswag/api.rb
Expand Up @@ -4,34 +4,12 @@

module Rswag
module Api
RENAMED_METHODS = {
swagger_root: :openapi_root
}.freeze
private_constant :RENAMED_METHODS

def self.configure
yield(config)
end

def self.config
@config ||= Configuration.new
end

def self.deprecator
@deprecator ||= ActiveSupport::Deprecation.new('3.0', 'rswag-api')
end

Configuration.class_eval do
RENAMED_METHODS.each do |old_name, new_name|
define_method("#{old_name}=") do |*args, &block|
public_send("#{new_name}=", *args, &block)
end
end
end

Api.deprecator.deprecate_methods(
Configuration,
RENAMED_METHODS.to_h { |old_name, new_name| ["#{old_name}=".to_sym, "#{new_name}=".to_sym] }
)
end
end
10 changes: 1 addition & 9 deletions rswag-api/lib/rswag/api/configuration.rb
@@ -1,18 +1,10 @@
module Rswag
module Api
class Configuration
attr_accessor :openapi_root, :swagger_filter, :swagger_headers
attr_accessor :openapi_root, :openapi_filter, :openapi_headers

def resolve_openapi_root(env)
path_params = env['action_dispatch.request.path_parameters'] || {}

if path_params.key?(:swagger_root)
Rswag::Api.deprecator.warn(
'swagger_root is deprecated and will be removed from rswag-api 3.0 (use openapi_root instead)'
)
return path_params[:swagger_root]
end

path_params[:openapi_root] || openapi_root
end
end
Expand Down
14 changes: 7 additions & 7 deletions rswag-api/lib/rswag/api/middleware.rb
Expand Up @@ -19,11 +19,11 @@ def call(env)
return @app.call(env) unless filename.start_with? openapi_root.to_s

if env['REQUEST_METHOD'] == 'GET' && File.file?(filename)
swagger = parse_file(filename)
@config.swagger_filter.call(swagger, env) unless @config.swagger_filter.nil?
openapi = parse_file(filename)
@config.openapi_filter.call(openapi, env) unless @config.openapi_filter.nil?
mime = Rack::Mime.mime_type(::File.extname(path), 'text/plain')
headers = { 'Content-Type' => mime }.merge(@config.swagger_headers || {})
body = unload_swagger(filename, swagger)
headers = { 'Content-Type' => mime }.merge(@config.openapi_headers || {})
body = unload_openapi(filename, openapi)

return [
'200',
Expand Down Expand Up @@ -53,11 +53,11 @@ def load_json(filename)
JSON.parse(File.read(filename))
end

def unload_swagger(filename, swagger)
def unload_openapi(filename, openapi)
if /\.ya?ml$/ === filename
YAML.dump(swagger)
YAML.dump(openapi)
else
JSON.dump(swagger)
JSON.dump(openapi)
end
end
end
Expand Down
13 changes: 0 additions & 13 deletions rswag-api/spec/lib/rswag/api/configuration_spec.rb
Expand Up @@ -4,17 +4,4 @@

RSpec.describe Rswag::Api::Configuration do
subject(:configuration) { described_class.new }

describe '#swagger_root=' do
it 'is deprecated' do
allow(Rswag::Api.deprecator).to receive(:warn)
configuration.swagger_root = 'foobar'
expect(subject.openapi_root).to eq('foobar')
expect(Rswag::Api.deprecator).to(
have_received(:warn)
.with('swagger_root= is deprecated and will be removed from rswag-api 3.0 (use openapi_root= instead)',
any_args)
)
end
end
end
12 changes: 12 additions & 0 deletions rswag-api/spec/rswag/api/fixtures/openapi/v1/openapi.yml
@@ -0,0 +1,12 @@
openapi: 3.0.0
info:
version: 1.0.0
title: API V1
description: A sample API to illustrate OpenAPI concepts
paths:
/list:
get:
description: Returns a list of stuff
responses:
'200':
description: Successful response
5 changes: 0 additions & 5 deletions rswag-api/spec/rswag/api/fixtures/swagger/v1/swagger.yml

This file was deleted.