Skip to content

Commit

Permalink
Add test for array query params
Browse files Browse the repository at this point in the history
  • Loading branch information
lannn committed May 6, 2024
1 parent b1547e7 commit 62cc737
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 3 deletions.
18 changes: 16 additions & 2 deletions spec/apps/rails/doc/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,20 @@
"price": "0"
}
},
{
"name": "names[]",
"in": "query",
"required": false,
"schema": {
"type": "array",
"items": {
"type": "string"
}
},
"example": [
"Example Table"
]
},
{
"name": "page",
"in": "query",
Expand Down Expand Up @@ -797,7 +811,7 @@
}
},
"422": {
"description": "fails to create a table (2)",
"description": "fails to create a table",
"content": {
"application/json": {
"schema": {
Expand Down Expand Up @@ -1240,4 +1254,4 @@
}
},
"custom_field": "custom_value"
}
}
11 changes: 10 additions & 1 deletion spec/apps/rails/doc/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,15 @@ paths:
- price
example:
price: '0'
- name: names[]
in: query
required: false
schema:
type: array
items:
type: string
example:
- Example Table
- name: page
in: query
required: false
Expand All @@ -381,7 +390,7 @@ paths:
example: 10
responses:
'200':
description: with different deep query parameters
description: with array query parameters
headers:
X-Cursor:
schema:
Expand Down
5 changes: 5 additions & 0 deletions spec/requests/rails_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@
get '/tables', params: { filter: { 'price' => 0 } }, headers: { authorization: 'k0kubun' }
expect(response.status).to eq(200)
end

it 'with array query parameters' do
get '/tables', params: { names: ['Example Table'] }, headers: { authorization: 'k0kubun' }
expect(response.status).to eq(200)
end
end

it 'has a request spec which does not make any request' do
Expand Down

0 comments on commit 62cc737

Please sign in to comment.