Created
May 21, 2013 04:07
-
-
Save andycmaj/5617420 to your computer and use it in GitHub Desktop.
Convert swagger JSON api definition to YAML
- Requires http://rubygems.org/gems/crack
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 'crack' | |
# json file with api definition | |
in_file_name = ARGV[0] | |
# yaml file output | |
out_file_name = ARGV[1] | |
# read in json | |
json = File.read(in_file_name) | |
# convert json to hash | |
hash = Crack::JSON.parse(json) | |
# convert hash to string | |
yaml = hash.to_yaml | |
# write string to out_file_name | |
File.open(out_file_name, 'w') {|f| f.write(yaml) } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment