From 62cc73731d9d04edd65c9a7fe24c281b6b4f0d5a Mon Sep 17 00:00:00 2001 From: lannn Date: Mon, 6 May 2024 11:58:32 +0700 Subject: [PATCH] Add test for array query params --- spec/apps/rails/doc/openapi.json | 18 ++++++++++++++++-- spec/apps/rails/doc/openapi.yaml | 11 ++++++++++- spec/requests/rails_spec.rb | 5 +++++ 3 files changed, 31 insertions(+), 3 deletions(-) diff --git a/spec/apps/rails/doc/openapi.json b/spec/apps/rails/doc/openapi.json index 9b34273..639dba4 100644 --- a/spec/apps/rails/doc/openapi.json +++ b/spec/apps/rails/doc/openapi.json @@ -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", @@ -797,7 +811,7 @@ } }, "422": { - "description": "fails to create a table (2)", + "description": "fails to create a table", "content": { "application/json": { "schema": { @@ -1240,4 +1254,4 @@ } }, "custom_field": "custom_value" -} \ No newline at end of file +} diff --git a/spec/apps/rails/doc/openapi.yaml b/spec/apps/rails/doc/openapi.yaml index b87068e..c49d605 100644 --- a/spec/apps/rails/doc/openapi.yaml +++ b/spec/apps/rails/doc/openapi.yaml @@ -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 @@ -381,7 +390,7 @@ paths: example: 10 responses: '200': - description: with different deep query parameters + description: with array query parameters headers: X-Cursor: schema: diff --git a/spec/requests/rails_spec.rb b/spec/requests/rails_spec.rb index 9365139..6e36357 100644 --- a/spec/requests/rails_spec.rb +++ b/spec/requests/rails_spec.rb @@ -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