Convert Swagger JSON to RAML/YAML

后端 未结 5 1081
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-05 03:02

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.

相关标签:
5条回答
  • 2021-02-05 03:19

    Here are the steps:

    1. Export Swagger JSON into a file on your drive. This JSON should be published on your server at the following URI: /swagger/docs/v1
    2. Go to http://editor.swagger.io/#/
    3. On the top left corner, select File-> Import File... Point to the local Swagger JSON file you exported in step #1 to open in the Swagger Editor
    4. Select Generate Client -> Swagger YAML option from the menu
    5. It will generate the YAML that you can validate at http://www.yamllint.com/ site
    0 讨论(0)
  • 2021-02-05 03:19

    To convert API spec between various formats (e.g. Swagger/OpenAPI, RAML, Postman, etc), you can use the following free and open source tools:

    • https://github.com/lucybot/api-spec-converter
    • https://github.com/stoplightio/api-spec-converter
    0 讨论(0)
  • 2021-02-05 03:28

    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

    0 讨论(0)
  • 2021-02-05 03:32

    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

    1. First import your swagger JSON at http://editor.swagger.io/#/ (File > Import File)
    2. Once you see your configurations, just download the corresponding YAML version (File > Download YAML).

    The YAML version of the JSON you just uploaded will be downloaded.

    0 讨论(0)
  • 2021-02-05 03:35

    While I wish there was a command line tool, this company has made a converter it seems:

    https://apitransformer.com/

    0 讨论(0)
提交回复
热议问题