How to convert Swagger YAML to JSON?

3,454 views
Skip to first unread message

Joel Parker Henderson

unread,
Mar 25, 2015, 1:17:09 AM3/25/15
to swagger-sw...@googlegroups.com
I have  a swagger.yaml file, and want to convert it to a swagger.json file.

Is it necessary to use the Swagger codegen tool, or is any generic converter script ok?

For example this is what I typically use for YAML to JSON:

    cat foo.yaml | ruby -ryaml -rjson -e 'puts JSON.pretty_generate(YAML::load(ARGF.read))' > foo.json

Is there any reason this wouldn't work reliably on a Swagger file?

Thanks for guidance.

tony tam

unread,
Mar 25, 2015, 2:26:36 AM3/25/15
to swagger-sw...@googlegroups.com
That is fine, or you can paste it in http://editor.swagger.io and export as JSON.
Reply all
Reply to author
Forward
0 new messages