Reputation: 2821
How do I convert Swagger JSON to RAML/YAML and validate it? I am not looking for a programmatic way, just a one off conversion.
Upvotes: 55
Views: 103443
Reputation: 938
If you have the same OpenAPI spec (say for example same version 3.0.1) in a json format and you want to convert it to a YAML format, you only need to use yq
the following way:
yq -p json -o yaml file.json > converted_file.yaml
And vice versa:
yq -p yaml -o json file.yaml > converted_file.json
-p:
input format type
-o:
output format type
Note that JSON is a subset of YAML
Upvotes: 1
Reputation: 6632
Its actually pretty simple
Web version of swagger editor gives the flexibility to import your existing swagger file(JSON/YAML) and download the configuration file that is currently being shown. So just combine these two.
Note: Converting JSON to YAML exists, but not JSON to RAML
The YAML version of the JSON you just uploaded will be downloaded.
Upvotes: 10
Reputation: 10807
To convert API spec between various formats (e.g. Swagger/OpenAPI, RAML, Postman, etc), you can use the following free and open source tools:
Upvotes: 7
Reputation: 41
Conversion
If you are looking to convert from any version Swagger to RAML 0.8 then APITransformer.com can do it for you. We're almost done with RAML 1.0 export. Will release it in a week's time.
Validation
The converted description comes out of the same code-gen engine that APIMatic uses to validate an API description before generating SDKs/Client libraries. Therefore, the converted RAML will be validated by default.
API descriptions in a variety of formats can also be validated via APIMatic's CLI or APIMatic's API
Upvotes: 4
Reputation: 655
While I wish there was a command line tool, this company has made a converter it seems:
Upvotes: 0
Reputation: 2821
Here are the steps:
Upvotes: 64