Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/rspec/openapi/schema_merger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def merge_schema!(base, spec)
elsif base[key].is_a?(Array) && value.is_a?(Array)
# parameters need to be merged as if `name` and `in` were the Hash keys.
if key == 'parameters'
base[key] |= value
base[key] = value | base[key]
base[key].uniq! { |param| param.slice('name', 'in') }
else
base[key] = value
Expand Down
62 changes: 31 additions & 31 deletions spec/rails/doc/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,29 +106,19 @@
},
"parameters": [
{
"name": "page",
"in": "query",
"schema": {
"type": "integer"
},
"example": 1
},
{
"name": "per",
"name": "filter[price]",
"in": "query",
"schema": {
"type": "integer"
},
"example": 10
},
{
"name": "X-Authorization-Token",
"in": "header",
"required": true,
"schema": {
"type": "string"
"type": "object",
"properties": {
"price": {
"type": "string"
}
}
},
"example": "token"
"example": {
"price": "0"
}
},
{
"name": "filter[name]",
Expand All @@ -146,19 +136,29 @@
}
},
{
"name": "filter[price]",
"name": "page",
"in": "query",
"schema": {
"type": "object",
"properties": {
"price": {
"type": "string"
}
}
"type": "integer"
},
"example": {
"price": "0"
}
"example": 1
},
{
"name": "per",
"in": "query",
"schema": {
"type": "integer"
},
"example": 10
},
{
"name": "X-Authorization-Token",
"in": "header",
"required": true,
"schema": {
"type": "string"
},
"example": "token"
}
]
},
Expand Down Expand Up @@ -268,7 +268,7 @@
"schema": {
"type": "integer"
},
"example": 1
"example": 2
}
],
"responses": {
Expand Down
32 changes: 16 additions & 16 deletions spec/rails/doc/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,15 @@ paths:
tags:
- Table
parameters:
- name: page
in: query
schema:
type: integer
example: 1
- name: per
- name: filter[price]
in: query
schema:
type: integer
example: 10
type: object
properties:
price:
type: string
example:
price: '0'
- name: filter[name]
in: query
schema:
Expand All @@ -39,15 +38,16 @@ paths:
type: string
example:
name: Example Table
- name: filter[price]
- name: page
in: query
schema:
type: object
properties:
price:
type: string
example:
price: '0'
type: integer
example: 1
- name: per
in: query
schema:
type: integer
example: 10
- name: X-Authorization-Token
in: header
required: true
Expand Down Expand Up @@ -180,7 +180,7 @@ paths:
required: true
schema:
type: integer
example: 1
example: 2
responses:
'200':
description: returns a table
Expand Down
14 changes: 7 additions & 7 deletions spec/rails/doc/smart/expected.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,18 @@ paths:
in: query
schema:
type: integer
example: 1
example: 42

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Note) 42 came from the updated test

- name: per
in: query
schema:
type: integer
example: 10
- name: X-Authorization-Token
in: header
required: true
schema:
type: string
example: token
- name: filter[name]
in: query
schema:
Expand All @@ -48,12 +54,6 @@ paths:
type: string
example:
price: '0'
- name: X-Authorization-Token
in: header
required: true
schema:
type: string
example: token
responses:
'200':
description: with flat query parameters
Expand Down
3 changes: 2 additions & 1 deletion spec/requests/rails_smart_merge_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
describe '#index' do
context it 'returns a list of tables' do
it 'with flat query parameters' do
get '/tables', params: { page: '1', per: '10' },
# These new params replace them in old spec
get '/tables', params: { page: '42', per: '10' },
headers: { authorization: 'k0kubun', "X-Authorization-Token": 'token' }
expect(response.status).to eq(200)
end
Expand Down