Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
rspec-rails-swagger
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open-source
rspec-rails-swagger
Commits
36fa6734
Commit
36fa6734
authored
Sep 25, 2016
by
andrew morton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a helper for declaring schemas
parent
db0a1d45
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
2 deletions
+29
-2
helpers.rb
lib/rspec/swagger/helpers.rb
+10
-1
helpers_spec.rb
spec/rspec/swagger/helpers_spec.rb
+19
-1
No files found.
lib/rspec/swagger/helpers.rb
View file @
36fa6734
...
...
@@ -87,7 +87,7 @@ module RSpec
def
parameter
name
,
attributes
=
{}
attributes
.
symbolize_keys!
#
l
ook for $refs
#
L
ook for $refs
if
name
.
respond_to?
(
:has_key?
)
ref
=
name
.
delete
(
:ref
)
||
name
.
delete
(
'ref'
)
full_param
=
resolve_document
(
metadata
).
resolve_ref
(
ref
)
...
...
@@ -241,6 +241,15 @@ module RSpec
def
capture_example
metadata
[
:capture_examples
]
=
true
end
def
schema
definition
definition
.
symbolize_keys!
ref
=
definition
.
delete
(
:ref
)
schema
=
ref
?
{
'$ref'
=>
ref
}
:
definition
metadata
[
:swagger_response
][
:schema
]
=
schema
end
end
end
end
...
...
spec/rspec/swagger/helpers_spec.rb
View file @
36fa6734
...
...
@@ -217,7 +217,7 @@ RSpec.describe RSpec::Swagger::Helpers::Response do
end
subject
{
klass
.
new
}
before
{
subject
.
metadata
=
{
swagger_object: :response
}
}
before
{
subject
.
metadata
=
{
swagger_object: :response
,
swagger_response:
{}
}
}
describe
'#capture_example'
do
it
"sets the capture metadata"
do
...
...
@@ -225,4 +225,22 @@ RSpec.describe RSpec::Swagger::Helpers::Response do
.
to
change
{
subject
.
metadata
[
:capture_examples
]
}.
to
(
true
)
end
end
describe
'#schema'
do
it
'stores the schema'
do
subject
.
schema
({
type: :object
,
properties:
{
title:
{
type:
'string'
}
}
})
expect
(
subject
.
metadata
[
:swagger_response
]).
to
include
(
schema:
{
type: :object
,
properties:
{
title:
{
type:
'string'
}
}
})
end
it
'supports refs'
do
subject
.
schema
ref:
'#/definitions/Pet'
expect
(
subject
.
metadata
[
:swagger_response
]).
to
include
(
schema:
{
'$ref'
=>
'#/definitions/Pet'
})
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment