Created
May 21, 2013 04:39
-
-
Save andycmaj/5617516 to your computer and use it in GitHub Desktop.
Convert Swagger YAML api definition to JSON
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'yaml' | |
require 'json' | |
# yaml file with api definition | |
in_file_name = ARGV[0] | |
# json file output | |
out_file_name = ARGV[1] | |
# read in yaml | |
yaml = File.read(in_file_name) | |
# convert yaml to hash | |
hash = YAML::load(yaml) | |
# convert hash to string | |
json = hash.to_json | |
# write string to out_file_name | |
File.open(out_file_name, 'w') {|f| f.write(json) } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment