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

Hanami support #202

Merged
merged 18 commits into from
Apr 1, 2024
Merged

Hanami support #202

merged 18 commits into from
Apr 1, 2024

Conversation

AlexeyMatskevich
Copy link
Contributor

As part of this MR, I implemented initial support for Hanami version 2.

Basically I provided a Hanami application, which is a re-implementation of the Rails application, with the only difference that instead of rails engine, I provided hanami slice.

I wrote tests for hanami similarly to the tests for rails.

I have not implemented the tests on minitest as I don't know it.

If you would be interested we could finalise this MR, infuse, and after that within the new MRs I would sea implement the rest of the features.

Of the things that aren't working right now, I can see

  1. it doesn't work to define id as a parameter, respectively describe it in openapi and merge all similar queries such as /table/1, /table/2.
  2. As a consequence of the first point, different answers at different id, are in different descriptions, a grouping problem.
  3. No tags
  4. Summury is generated in a different way from rails

Key changes:

  1. Moved all test apps to spec/apps
  2. Removed the use of index_by, as it is part of activesupport

Copy link
Owner

@exoego exoego left a comment

Choose a reason for hiding this comment

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

Awesome 🥇
The change itself LGTM.
Could you fix conflicts?

@exoego exoego changed the title Hanami Hanami support Mar 28, 2024
Aleksei added 2 commits March 31, 2024 15:06
# Conflicts:
#	lib/rspec/openapi/schema_merger.rb
#	spec/apps/rails/app/controllers/additional_properties_controller.rb
#	spec/apps/rails/app/controllers/masters/extensions_controller.rb
#	spec/apps/rails/app/controllers/pages_controller.rb
#	spec/integration_tests/rails_test.rb
#	spec/integration_tests/roda_test.rb
#	spec/requests/rails_spec.rb
#	spec/requests/roda_spec.rb
Copy link

@github-advanced-security github-advanced-security bot left a comment

Choose a reason for hiding this comment

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

Rubocop found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.

Copy link

codecov bot commented Mar 31, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.12%. Comparing base (cb4ac86) to head (8b2579f).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #202      +/-   ##
==========================================
+ Coverage   97.10%   97.12%   +0.01%     
==========================================
  Files          15       15              
  Lines         518      521       +3     
  Branches      126      126              
==========================================
+ Hits          503      506       +3     
  Misses         15       15              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


header_value = request.get_header(['HTTP', header_key].join('_')) ||
request.get_header(header_key) ||
request.get_header(header_key.to_s)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I found one problem with the new edits - https://github.com/exoego/rspec-openapi/pull/198/files#diff-a79ceb062f9ec26b6203f0b7541bd0a9b1cc2ebf3370cac3da9039f4f11dc1a7R56 - Rack test seems to send strings instead of characters in headers, so because of this edit, headers can no longer be detected.

@exoego
Copy link
Owner

exoego commented Apr 1, 2024

@AlexeyMatskevich
The job for Ruby 2.7 is failing at bundle install step: https://github.com/exoego/rspec-openapi/actions/runs/8498580117/job/23302368385?pr=202

It appears that Hanami 2.0 dropped Ruby 2.7 support https://github.com/hanami/hanami/blob/main/CHANGELOG.md#changed-14

Please install Hanami v1.x when Ruby 2.7, or exclude Hanami test when Ruby 2.7.
Either is fine.

@AlexeyMatskevich
Copy link
Contributor Author

Hanami version 1 and version 2 are essentially two different frameworks, they are not compatible, so I would prefer to just exclude the tests for version 2.7, but I don't see how to implement that yet.

Comment on lines +11 to +13
include SpecHelper

describe 'yaml output' do
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
include SpecHelper
describe 'yaml output' do
include SpecHelper
# Hanami 2.0 support Ruby 3.0+
skip if RUBY_VERSION < '3.0.0'
describe 'yaml output' do

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think I've succeeded

@exoego
Copy link
Owner

exoego commented Apr 1, 2024

Thanks!

@exoego exoego merged commit c426320 into exoego:master Apr 1, 2024
13 checks passed
@exoego exoego added the enhancement New feature or request label Apr 1, 2024
@exoego exoego mentioned this pull request Apr 1, 2024
@AlexeyMatskevich AlexeyMatskevich deleted the hanami branch April 1, 2024 15:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants