lib/zup/generator.rb in zup-generator-0.1.0 vs lib/zup/generator.rb in zup-generator-0.1.1
- old
+ new
@@ -147,11 +147,11 @@
return nil if response.code == "404"
return JSON.parse(response.body, :symbolize_names => true)
end
- def generate_swagger(api_id, version_id)
+ def generate_swagger(api_id, version_id, extension = nil)
api = @apis.select {|e| e[:id] == api_id}.first
version = api[:versions].select {|e| e[:id] == version_id}.first
if !api.nil? && !version.nil?
content = {
@@ -222,12 +222,16 @@
}
end
end
end
- # pbcopy content.to_json
-
- return content
+ if extension == "json"
+ return content.to_json
+ elsif extension == "yaml"
+ return JSON.parse(content.to_json).to_yaml
+ else
+ return content
+ end
else
return nil
end
end