-
Notifications
You must be signed in to change notification settings - Fork 64
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
Hanami support #202
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
e1cf5a0
Add rails-dom-testing to dependency
AlexeyMatskevich da4bcb7
Apply linter offences
AlexeyMatskevich 9d12c46
Add rails-dom-testing to gemfile
5b7266a
Move test applications to \specs\apps
0629d97
Add hanami to test apps
cd84b7d
Make Hanami load in the tests
d58641a
Re-implement rails app in hanami version
1e7dc00
Don't use rails methods in schema_merger
ba09e53
Returns the correct content type in hanami
2c25ed3
Rack test doesn't do upcase for headers
bd2dbfb
Initial openapi docs for hanami
3edc089
Remove binding
90c1dff
Remove empty space in rails openapi
016eff5
Merge branch 'master' into hanami
4007dd1
Adopt openapi deprecated function to hanami version
d220ef8
Run rubocop
6ccdbad
Apply github rubocop bot offences
8b2579f
Skip hanami on ruby 2
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.env | ||
log/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
web: bundle exec hanami server |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# frozen_string_literal: true | ||
|
||
require "hanami/rake_tasks" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# auto_register: false | ||
# frozen_string_literal: true | ||
|
||
require 'hanami/action' | ||
|
||
class HanamiTest::Action < Hanami::Action | ||
class RecordNotFound < StandardError; end | ||
end |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# frozen_string_literal: true | ||
|
||
module HanamiTest | ||
module Actions | ||
module Extensions | ||
class Create < HanamiTest::Action | ||
def handle(_request, response) | ||
response.body = [{ name: 'my-ext-1' }].to_json | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# frozen_string_literal: true | ||
|
||
module HanamiTest | ||
module Actions | ||
module Extensions | ||
class Index < HanamiTest::Action | ||
def handle(_request, response) | ||
response.body = { message: 'created' }.to_json | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# frozen_string_literal: true | ||
|
||
module HanamiTest | ||
module Actions | ||
module Images | ||
class Index < HanamiTest::Action | ||
format :json | ||
|
||
def handle(_request, response) | ||
list = [ | ||
{ | ||
name: 'file.png', | ||
tags: [], # Keep this empty to check empty array is accepted | ||
}, | ||
] | ||
|
||
response.body = list.to_json | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# frozen_string_literal: true | ||
|
||
module HanamiTest | ||
module Actions | ||
module Images | ||
class Show < HanamiTest::Action | ||
def handle(_request, response) | ||
png = 'iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAAAAADhZOFXAAAADklEQVQIW2P4DwUMlDEA98A/wTjPQBoAAAAASUVORK5CYII=' | ||
.unpack('m').first | ||
|
||
response.format = :png | ||
response.body = png | ||
response.headers.merge!( | ||
{ | ||
'Content-Type' => 'image/png', | ||
'Content-Disposition' => 'inline', | ||
} | ||
) | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# frozen_string_literal: true | ||
|
||
module HanamiTest | ||
module Actions | ||
module Images | ||
class Upload < HanamiTest::Action | ||
# format :form | ||
|
||
def handle(_request, response) | ||
png = 'iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAAAAADhZOFXAAAADklEQVQIW2P4DwUMlDEA98A/wTjPQBoAAAAASUVORK5CYII=' | ||
.unpack('m').first | ||
|
||
response.format = :png | ||
response.body = png | ||
response.headers.merge!( | ||
{ | ||
'Content-Type' => 'image/png', | ||
'Content-Disposition' => 'inline', | ||
} | ||
) | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# frozen_string_literal: true | ||
|
||
module HanamiTest | ||
module Actions | ||
module Images | ||
class UploadMultiple < HanamiTest::Action | ||
# format :multipart | ||
|
||
def handle(_request, response) | ||
png = 'iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAAAAADhZOFXAAAADklEQVQIW2P4DwUMlDEA98A/wTjPQBoAAAAASUVORK5CYII=' | ||
.unpack('m').first | ||
|
||
response.format = :png | ||
response.body = png | ||
response.headers.merge!( | ||
{ | ||
'Content-Type' => 'image/png', | ||
'Content-Disposition' => 'inline', | ||
} | ||
) | ||
end | ||
end | ||
end | ||
end | ||
end |
23 changes: 23 additions & 0 deletions
23
spec/apps/hanami/app/actions/images/upload_multiple_nested.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# frozen_string_literal: true | ||
|
||
module HanamiTest | ||
module Actions | ||
module Images | ||
class UploadMultipleNested < HanamiTest::Action | ||
def handle(_request, response) | ||
png = 'iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAAAAADhZOFXAAAADklEQVQIW2P4DwUMlDEA98A/wTjPQBoAAAAASUVORK5CYII=' | ||
.unpack('m').first | ||
|
||
response.format = :png | ||
response.body = png | ||
response.headers.merge!( | ||
{ | ||
'Content-Type' => 'image/png', | ||
'Content-Disposition' => 'inline', | ||
} | ||
) | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# frozen_string_literal: true | ||
|
||
module HanamiTest | ||
module Actions | ||
module Images | ||
class UploadNested < HanamiTest::Action | ||
def handle(_request, response) | ||
png = 'iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAAAAADhZOFXAAAADklEQVQIW2P4DwUMlDEA98A/wTjPQBoAAAAASUVORK5CYII=' | ||
.unpack('m').first | ||
|
||
response.format = :png | ||
response.body = png | ||
response.headers.merge!( | ||
{ | ||
'Content-Type' => 'image/png', | ||
'Content-Disposition' => 'inline', | ||
} | ||
) | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# frozen_string_literal: true | ||
|
||
module HanamiTest | ||
module Actions | ||
module SecretItems | ||
class Index < HanamiTest::Action | ||
format :json | ||
|
||
def handle(_request, response) | ||
response.body = { items: ['secrets'] }.to_json | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# frozen_string_literal: true | ||
|
||
module HanamiTest | ||
module Actions | ||
module Tables | ||
class Create < TableAction | ||
format :json | ||
|
||
def handle(request, response) | ||
if request.params[:name].blank? || request.params[:name] == 'some_invalid_name' | ||
response.status = 422 | ||
response.body = { error: 'invalid name parameter' }.to_json | ||
else | ||
response.status = 201 | ||
response.body = find_table.to_json | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# frozen_string_literal: true | ||
|
||
module HanamiTest | ||
module Actions | ||
module Tables | ||
class Destroy < TableAction | ||
def handle(request, response) | ||
response.format = :json | ||
if request.params[:no_content] | ||
response.status = 202 | ||
else | ||
response.body = find_table(request.params[:id]).to_json | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# frozen_string_literal: true | ||
|
||
module HanamiTest | ||
module Actions | ||
module Tables | ||
class Index < TableAction | ||
def handle(request, response) | ||
response.headers['X-Cursor'] = 100 | ||
|
||
response.format = :json | ||
|
||
response.body = if request.params[:show_columns] | ||
[find_table('42')].to_json | ||
else | ||
[find_table].to_json | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# frozen_string_literal: true | ||
|
||
module HanamiTest | ||
module Actions | ||
module Tables | ||
class Show < TableAction | ||
format :json | ||
|
||
def handle(request, response) | ||
response.body = find_table(request.params[:id]).to_json | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# frozen_string_literal: true | ||
|
||
module HanamiTest | ||
module Actions | ||
module Tables | ||
class TableAction < HanamiTest::Action | ||
APIKEY = 'k0kubun'.freeze | ||
|
||
include TableRepository | ||
|
||
handle_exception RecordNotFound => :handle_not_fount_error | ||
|
||
before :authenticate | ||
|
||
private | ||
|
||
def handle_not_fount_error(_request, _response, _exception) | ||
halt 404, { message: 'not found' }.to_json | ||
end | ||
|
||
def authenticate(request, response) | ||
return unless request.get_header('AUTHORIZATION') != APIKEY | ||
|
||
response.format = :json | ||
halt 401, { message: 'Unauthorized' }.to_json | ||
end | ||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.