Skip to content

Commit

Permalink
Merge pull request #17 from troter/troter-patch-1
Browse files Browse the repository at this point in the history
avoid passing path that contains query string to Committee::Drivers::OpenApi3::Schema#operation_object
  • Loading branch information
willnet authored Jul 20, 2022
2 parents 273ae15 + 17c74da commit 64b1dfc
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/committee/rails/request_object.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ def initialize(request)
end

def path
@request.original_fullpath
URI.parse(@request.original_fullpath).path
end

def path_info
@request.original_fullpath
URI.parse(@request.original_fullpath).path
end

def request_method
Expand Down
4 changes: 4 additions & 0 deletions spec/fake_app/rails_app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ class ApplicationController < ActionController::Base
end

class UsersController < ApplicationController
def index
render json: [{ id: 1, nickname: 'willnet' }]
end

def create
render json: { id: 1, nickname: 'willnet' }
end
Expand Down
26 changes: 26 additions & 0 deletions spec/fake_app/schema/schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,32 @@ servers:
- url: https://example.com/
paths:
/users:
get:
description: read users
parameters:
- name: page
example: 42
in: query
required: false
schema:
type: integer
responses:
'200':
description: success
content:
application/json:
schema:
type: array
items:
type: object
properties:
id:
$ref: '#/components/schemas/id'
nickname:
$ref: '#/components/schemas/nickname'
required:
- id
- nickname
post:
description: create user
requestBody:
Expand Down
7 changes: 7 additions & 0 deletions spec/lib/methods_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@
assert_schema_conform(200)
end

context 'and request with querystring' do
it 'pass' do
get '/users', params: { page: 1 }, headers: { 'Content-Type' => 'application/json' }
assert_schema_conform(200)
end
end

context 'and override #request method' do
def request
'hi'
Expand Down

0 comments on commit 64b1dfc

Please # to comment.