Skip to content

OAS version 3 #5

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

Draft
wants to merge 61 commits into
base: master
Choose a base branch
from
Draft

OAS version 3 #5

wants to merge 61 commits into from

Conversation

krasnoukhov
Copy link
Member

@krasnoukhov krasnoukhov commented May 19, 2025

aadityataparia and others added 30 commits December 3, 2018 15:45
- Untrack Gemfile.lock
- Move `inch` gem from Gemfile to development dependency in gemspec

Details:
https://yehudakatz.com/2010/12/16/clarifying-the-roles-of-the-gemspec-and-gemfile/
…pmark#458)

* Allow response_body_formatter config to format "binary" responses

Following this issue on Rack's repository:
[Fix incorrect MockResponse#body String encoding](rack/rack#1486), it looks like we can expect, from now on, that Rack's `response_body` encoding will be `Encoding::ASCII_8BIT`:

> I think the response body should probably always be ASCII-8BIT. Rack
can't really know anything about the encoding of the bytes that users
want to send. At the end of the day, it's just bytes written to the
socket, and I don't think Rack should have any opinion about the
encoding the user sends.

Therefore, `rspec_api_documentation` cannot rely on
`response_body.encoding` to determine whether the response is binary
data or not. This line becomes incorrect:

https://github.com/zipmark/rspec_api_documentation/blob/81e5c563ce6787f143cf775c64e2bd08c35d3585/lib/rspec_api_documentation/client_base.rb#L90-L91

The real fix would be to figure out a better way to define whether a
string is binary or not, but I believe this is a bit outside the scope of my
knowledge.

In this PR, I'm focusing on giving any application using the
`rspec_api_documentation` the choice on how to process the
response_body, and particularly on how to detect binary data, while not
altering `rspec_api_documentation`'s default behaviour.

As an additional benefit, this change would allow an application to
display friendlier responses in the documentation for some binary types.

For example, PNG data:

```rb
Proc.new do |content_type, response_body|
  # http://www.libpng.org/pub/png/spec/1.2/PNG-Rationale.html#R.PNG-file-signature
  if response_body[0,8] == "\x89PNG\r\n\u001A\n"
    "<img src=\"data:image/png;base64,#{Base64.strict_encode64(response_body)}\" />"
  elsif content_type =~ /application\/.*json/
    JSON.pretty_generate(JSON.parse(response_body))
  else
    response_body
  end
end
```

* Update README.md

Co-Authored-By: Benjamin Fleischer <[email protected]>
This change is part of preliminary efforts at attempting to refresh
the Continuous Integration setup, by supporting recent Ruby version and
updating dependencies.

To be honest, I don't know what benefits the Thin server brings to the table.
I tried digging in the code, but the commit that introduced it does not
tell me much: cdeea8b.

What I know however is that I have troubles running the specs locally,
getting a timeout on this line:

https://github.com/zipmark/rspec_api_documentation/blob/560c3bdc7bd5581e7c223334390221ecfc910be8/spec/http_test_client_spec.rb#L16

However, letting Capybara handle its server details, as shown in this PR,
does not seem to have any negative impact (spec is still green, and fairly fast).
> `root`: deprecated key `sudo` (The key \`sudo\` has no effect anymore.)
* Test more recent versions of Ruby on Travis

Added:
- 2.4.9 (reached end-of-life but may temporarily help in incremental debugging)
- 2.5.8
- 2.6.6

Did not add 2.7.x yet because it introduces *a lot* of warnings.

Did not remove any past version yet because until decided otherwise,
they should be supported by the gem. (I would recommend a major version
bump when those versions get dropped.)

The idea is that developments from now on should be future-proof, and
changes should be tested on current versions of Ruby.

* Update WebMock to latest 2.x version

Updating to WebMock 2.x means that:

> require 'webmock' does not enable WebMock anymore. gem 'webmock' can
now be safely added to a Gemfile and no http client libs will be
modified when it's loaded. Call WebMock.enable! to enable WebMock.
>
> Please note that require 'webmock/rspec', require 'webmock/test_unit',
require 'webmock/minitest' and require 'webmock/cucumber' still do
enable WebMock.

Source: [WebMock's
CHANGELOG.md](https://github.com/bblimke/webmock/blob/master/CHANGELOG.md#200).

As rspec_api_documentation is very much tied to RSpec, I saw no problem
with replacing all instances of `require 'webmock'` with `require
'webmock/rspec'`.

* Update WebMock dependency to 3.2.0

3.2.0 introduced another breaking change that had to be addressed:

[Automatically disable WebMock after rspec suite](bblimke/webmock#731)

As the example app_spec.rb in features/oauth2_mac_client.feature is supposed to be a stand-alone spec file, it made sense, to me, to `require "webmock/rspec"`.
Does that make any sense?

* Bump WebMock dev dependency to 3.5.0

This introduces Ruby 2.6 support and should get the test suite to run on that version of Ruby.

* Try using WebMock 3.8.3

Let's see how this goes on Travis.
> ### Why is Gemnasium.com closed?
> Gemnasium was acquired by GitLab in January 2018. Since May 15, 2018, the services provided by Gemnasium are no longer available.

[Source.](https://docs.gitlab.com/ee/user/project/import/gemnasium.html#why-is-gemnasiumcom-closed)
Why:
Trying run the specs on vanilla machine produces error:
```
resource.rb:10:in `block in define_action: undefined method extract_options! for ["/path"]:Array (NoMethodError)
```
Why:
Trying to run specs with the old version using `bundle exec rspec` leads to an error:
```
tried to create Proc object without a block
faraday-0.9.2/lib/faraday/options.rb:153:in new:
tried to create Proc object without a block (ArgumentError)
...
../http_test_client.rb:2:in require
```
Why:
Fixes error when running specs `bundle exec (/home/m/.rbenv/versions/3.1.0/bin/rspec)
bundle exec rspec spec/dsl_spec.rb`
```
NoMethodError:
undefined method `stringify_keys for {:name=>"Friday Order"}:Hash
...
dsl/endpoint.rb:171:in `block in extra_params
```
Why:
Given specs fails on expecting `description` field being empty while
in current version it contains capitalised version of `name` attribute.
```
       expected: [{:required=>false, :name=>"description", :description=>nil, :properties_description=>"optional"}]
            got: [{:required=>false, :name=>"description", :description=>"Description", :properties_description=>"optional"}]
```
Bumps [actions/checkout](https://github.com/actions/checkout) from 2 to 4.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](actions/checkout@v2...v4)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>
Updates the requirements on [rack-oauth2](https://github.com/nov/rack-oauth2) to permit the latest version.
- [Release notes](https://github.com/nov/rack-oauth2/releases)
- [Changelog](https://github.com/nov/rack-oauth2/blob/main/CHANGELOG.md)
- [Commits](nov/rack-oauth2@v1.2.2...v1.12.0)

---
updated-dependencies:
- dependency-name: rack-oauth2
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <[email protected]>
Updates the requirements on [rspec](https://github.com/rspec/rspec-metagem) to permit the latest version.
- [Commits](rspec/rspec-metagem@v3.4.0...v3.13.0)

---
updated-dependencies:
- dependency-name: rspec
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>
bf4 and others added 30 commits April 25, 2024 12:45
…/actions/checkout-4

Bump actions/checkout from 2 to 4 [ci skip]
…auth2-tw-1.12.0

Update rack-oauth2 requirement from ~> 1.2.2 to ~> 1.12.0 [ci skip]
…tw-3.13.0

Update rspec requirement from ~> 3.4.0 to ~> 3.13.0 [ci skip]
…tw-0.14.14

Update aruba requirement from ~> 0.13.0 to ~> 0.14.14 [ci skip]
Updates the requirements on [contracts](https://github.com/egonSchiele/contracts.ruby) to permit the latest version.
- [Changelog](https://github.com/egonSchiele/contracts.ruby/blob/master/CHANGELOG.markdown)
- [Commits](egonSchiele/contracts.ruby@v0.13.0...v0.17)

---
updated-dependencies:
- dependency-name: contracts
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <[email protected]>
…cts-tw-0.17

Update contracts requirement from ~> 0.13.0 to ~> 0.17 [ci skip]
Updates the requirements on [multi_json](https://github.com/intridea/multi_json) to permit the latest version.
- [Changelog](https://github.com/intridea/multi_json/blob/master/CHANGELOG.md)
- [Commits](intridea/multi_json@v1.11.2...v1.15.0)

---
updated-dependencies:
- dependency-name: multi_json
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <[email protected]>
Updates the requirements on [rspec-its](https://github.com/rspec/rspec-its) to permit the latest version.
- [Changelog](https://github.com/rspec/rspec-its/blob/main/Changelog.md)
- [Commits](rspec/rspec-its@v1.2.0...v1.3.0)

---
updated-dependencies:
- dependency-name: rspec-its
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <[email protected]>
…json-tw-1.15.0

Update multi_json requirement from ~> 1.11.2 to ~> 1.15.0 [ci skip]
Updates the requirements on [capybara](https://github.com/teamcapybara/capybara) to permit the latest version.
- [Changelog](https://github.com/teamcapybara/capybara/blob/master/History.md)
- [Commits](teamcapybara/capybara@2.6.2...3.39.2)

---
updated-dependencies:
- dependency-name: capybara
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <[email protected]>
…ra-tw-3.39.2

Update capybara requirement from ~> 2.6.2 to ~> 3.39.2 [ci skip]
…its-tw-1.3.0

Update rspec-its requirement from ~> 1.2.0 to ~> 1.3.0 [ci skip]
Updates the requirements on [rake](https://github.com/ruby/rake) to permit the latest version.
- [Release notes](https://github.com/ruby/rake/releases)
- [Changelog](https://github.com/ruby/rake/blob/master/History.rdoc)
- [Commits](ruby/rake@v10.5.0...v13.2.1)

---
updated-dependencies:
- dependency-name: rake
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <[email protected]>
Updates the requirements on [sinatra](https://github.com/sinatra/sinatra) to permit the latest version.
- [Changelog](https://github.com/sinatra/sinatra/blob/main/CHANGELOG.md)
- [Commits](sinatra/sinatra@v1.4.7...v2.0.8.1)

---
updated-dependencies:
- dependency-name: sinatra
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <[email protected]>
…a-tw-2.0.8

Update sinatra requirement from ~> 1.4.7 to ~> 2.0.8 [ci skip]
Updates the requirements on [gherkin](https://github.com/cucumber/cucumber) to permit the latest version.
- [Release notes](https://github.com/cucumber/cucumber/releases)
- [Commits](cucumber/common@react/v3.2.0...gherkin/v9.0.0)

---
updated-dependencies:
- dependency-name: gherkin
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <[email protected]>
…w-13.2.1

Update rake requirement from ~> 10.5.0 to ~> 13.2.1 [ci skip]
Updates the requirements on [webmock](https://github.com/bblimke/webmock) to permit the latest version.
- [Changelog](https://github.com/bblimke/webmock/blob/master/CHANGELOG.md)
- [Commits](bblimke/webmock@v3.8.3...v3.23.0)

---
updated-dependencies:
- dependency-name: webmock
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <[email protected]>
…k-tw-3.23.0

Update webmock requirement from ~> 3.8.3 to ~> 3.23.0 [ci skip]
…n-tw-9.0.0

Update gherkin requirement from ~> 3.2.0 to ~> 9.0.0 [ci skip]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants