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
d2c108e3
Commit
d2c108e3
authored
Sep 22, 2016
by
andrew morton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Write JSON to disk
Fixes #1
parent
e95d89af
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
4 deletions
+11
-4
formatter.rb
lib/rspec/swagger/formatter.rb
+9
-4
helpers.rb
lib/rspec/swagger/helpers.rb
+2
-0
No files found.
lib/rspec/swagger/formatter.rb
View file @
d2c108e3
...
@@ -16,9 +16,9 @@ module RSpec
...
@@ -16,9 +16,9 @@ module RSpec
metadata
=
notification
.
example
.
metadata
metadata
=
notification
.
example
.
metadata
return
unless
metadata
[
:swagger_object
]
==
:response
return
unless
metadata
[
:swagger_object
]
==
:response
metadata
.
each
do
|
k
,
v
|
#
metadata.each do |k, v|
puts
"
#{
k
}
\t
#{
v
}
"
if
k
.
to_s
.
starts_with?
(
"swagger"
)
#
puts "#{k}\t#{v}" if k.to_s.starts_with?("swagger")
end
#
end
document
=
document_for
(
metadata
[
:swagger_document
])
document
=
document_for
(
metadata
[
:swagger_document
])
path_item
=
path_item_for
(
document
,
metadata
[
:swagger_path_item
])
path_item
=
path_item_for
(
document
,
metadata
[
:swagger_path_item
])
...
@@ -31,7 +31,12 @@ module RSpec
...
@@ -31,7 +31,12 @@ module RSpec
end
end
def
write_json
(
name
,
document
)
def
write_json
(
name
,
document
)
puts
JSON
.
pretty_generate
(
document
)
root
=
::
RSpec
.
configuration
.
swagger_root
# It would be good to at least warn if the name includes some '../' that
# takes it out of root directory.
target
=
Pathname
(
name
).
expand_path
(
root
)
target
.
dirname
.
mkpath
target
.
write
(
JSON
.
pretty_generate
(
document
))
end
end
def
document_for
(
doc_name
=
nil
)
def
document_for
(
doc_name
=
nil
)
...
...
lib/rspec/swagger/helpers.rb
View file @
d2c108e3
...
@@ -197,6 +197,8 @@ module RSpec
...
@@ -197,6 +197,8 @@ module RSpec
module
Resolver
module
Resolver
def
resolve_document
metadata
def
resolve_document
metadata
# TODO: It's really inefficient to keep recreating this. It'd be nice
# if we could cache them some place.
name
=
metadata
[
:swagger_document
]
name
=
metadata
[
:swagger_document
]
Document
.
new
(
RSpec
.
configuration
.
swagger_docs
[
name
])
Document
.
new
(
RSpec
.
configuration
.
swagger_docs
[
name
])
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