Skip to content

Commit

Permalink
Merge pull request #88 from mjbamford/feature/api_file_name
Browse files Browse the repository at this point in the history
Added api_file_name to config
  • Loading branch information
richhollis committed Sep 26, 2014
2 parents e90775d 0b27c22 commit f64f5d3
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lib/swagger/docs/generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 5,7 @@ class Generator
DEFAULT_VER = "1.0"
DEFAULT_CONFIG = {
:api_file_path => "public/",
:api_file_name => "api-docs.json",
:base_path => "/",
:clean_directory => false,
:formatting => :pretty
Expand All @@ -30,7 31,7 @@ def write_doc(result)
resources = root.delete 'resources'
root.merge!(config[:attributes] || {}) # merge custom user attributes like info
# write the api-docs file
write_to_file("#{settings[:api_file_path]}/api-docs.json", root, config)
write_to_file("#{settings[:api_file_path]}/#{config[:api_file_name]}", root, config)
# write the individual resource files
resources.each do |resource|
resource_file_path = resource.delete 'resourceFilePath'
Expand Down
2 changes: 1 addition & 1 deletion lib/swagger/docs/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 1,5 @@
module Swagger
module Docs
VERSION = "0.1.9"
VERSION = "0.1.10"
end
end
11 changes: 11 additions & 0 deletions spec/lib/swagger/docs/generator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 53,17 @@
it "writes api path correctly" do
expect(response["apis"][0]["path"]).to eq "api/v1/sample.{format}"
end

context "api_file_name" do
let(:api_file_name) { 'swagger-docs.json' }
let(:config) {{
DEFAULT_VER => {
:api_file_path => tmp_dir,
:api_file_name => api_file_name }
}}
let(:file_resources) { tmp_dir api_file_name }
specify { expect(File.exists? file_resources).to be true }
end
end
context "resource file" do
let(:resource) { file_resource.read }
Expand Down

0 comments on commit f64f5d3

Please sign in to comment.