Skip to content

Commit

Permalink
Check referenced components in "items" generated
Browse files Browse the repository at this point in the history
  • Loading branch information
exoego committed Nov 8, 2022
1 parent fb50316 commit 7549a86
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 4 deletions.
24 changes: 23 additions & 1 deletion spec/rails/app/controllers/tables_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ class TablesController < ApplicationController

def index
response.set_header('X-Cursor', 100)
render json: [find_table]
if params[:show_columns]
render json: [find_table('42')]
else
render json: [find_table]
end
end

def show
Expand Down Expand Up @@ -53,6 +57,24 @@ def find_table(id = nil)
created_at: time.iso8601,
updated_at: time.iso8601,
}
when '42'
{
id: 42,
name: 'access',
description: 'logs',
database: {
id: 4242,
name: 'production',
},
columns: [
{ name: 'id', column_type: 'integer' },
{ name: 'description', column_type: 'varchar' }
],
null_sample: nil,
storage_size: 12.3,
created_at: time.iso8601,
updated_at: time.iso8601,
}
else
raise NotFoundError
end
Expand Down
25 changes: 23 additions & 2 deletions spec/rails/doc/smart/expected.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ paths:
schema:
type: integer
example: 10
- name: show_columns
in: query
schema:
type: string
example: "true"
responses:
'200':
description: with flat query parameters
Expand All @@ -46,16 +51,21 @@ paths:
items:
"$ref": "#/components/schemas/Table"
example:
- id: 1
- id: 42
name: access
description: logs
database:
id: 2
id: 4242
name: production
null_sample:
storage_size: 12.3
created_at: '2020-07-17T00:00:00+00:00'
updated_at: '2020-07-17T00:00:00+00:00'
columns:
- name: id
column_type: integer
- name: description
column_type: varchar
headers:
X-Cursor:
schema:
Expand Down Expand Up @@ -137,6 +147,10 @@ components:
type: string
database:
"$ref": "#/components/schemas/Database"
columns:
type: array
items:
"$ref": "#/components/schemas/Column"
null_sample:
nullable: true
storage_size:
Expand All @@ -155,3 +169,10 @@ components:
description: 'this should be preserved'
name:
type: string
Column:
type: object
properties:
name:
type: string
column_type:
type: string
4 changes: 4 additions & 0 deletions spec/rails/doc/smart/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,10 @@ components:
type: string
database:
"$ref": "#/components/schemas/Database"
columns:
type: array
items:
"$ref": "#/components/schemas/Column"
null_sample:
nullable: true
storage_size:
Expand Down
2 changes: 1 addition & 1 deletion spec/requests/rails_smart_merge_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
context it 'returns a list of tables' do
it 'with flat query parameters' do
# These new params replace them in old spec
get '/tables', params: { page: '42', per: '10' },
get '/tables', params: { page: '42', per: '10', show_columns: true },
headers: { authorization: 'k0kubun', "X-Authorization-Token": 'token' }
response.set_header('X-Cursor', 100)
expect(response.status).to eq(200)
Expand Down

0 comments on commit 7549a86

Please sign in to comment.