Code Monkey home page Code Monkey logo

swagger-to-raml-object's Introduction

This repository is deprecated! Please use the official oas-raml-converter instead.

Swagger To RAML Object

NPM version Build status Test coverage

Takes a swagger spec and converts it into a RAML JavaScript object, usually for conversion to RAML with the raml-object-to-raml module.

Installation

npm install swagger-to-raml-object --save

Usage

Quickly get started converting swagger to RAML in your command line:

# Make sure node and npm are installed before continuing.

npm install swagger-to-raml-object -g
npm install raml-object-to-raml -g

# Convert a swagger spec into a raml object.
swagger-to-raml-object http://petstore.swagger.wordnik.com/api/api-docs

# Pipe the result of that into the raml object to raml converter.
swagger-to-raml-object http://petstore.swagger.wordnik.com/api/api-docs | raml-object-to-raml

# You can then output the result of that to a file.
swagger-to-raml-object http://petstore.swagger.wordnik.com/api/api-docs | raml-object-to-raml > output.raml

CLI

The CLI accepts a single swagger file to load and will recursively compile the spec into a single RAML object representation before printing the JSON to stdout.

swagger-to-raml-object resources.json > raml.json

JavaScript

The module exports a single function for converting Swagger specifications. It accepts three arguments, the root resource listing, a file reader function and a callback for when parsing is complete. The callback is called with an error (if something occured) and the resulting RAML object.

var converter = require('swagger-to-raml-object');

converter(rootFile, function (filename, done) {
  return fs.readFile(filename, 'utf8', done);
}, function (err, ramlObject) {
  if (err) {
    console.error(err);
  }

  console.log(ramlObject);
  // {
  //   "title": "Example API",
  //   "resources": [{ ... }],
  //   ...
  // }
});

Features and Limitations

  • Works with Swagger 1.2 (not 2.0 yet)
  • Loads from any resource structure given a file reader function
  • Does not parse XML bodies into schemas yet (only JSON and form)
  • Does not do any RAML documentation optimisations such as resourceTypes, traits or global schemas
  • Currently only does single file output

License

Apache 2.0

swagger-to-raml-object's People

Contributors

blakeembrey avatar logicmason avatar sichvoge avatar svc-scm avatar usarid avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

swagger-to-raml-object's Issues

Open link with authentication

Hi!

I'm trying to convert a swagger definition on a public website. The problem is that I need to login on this site. Is there a way to get around this?

Greetz,
Marco Mans

Swagger 2.0 Support

For someone who wants to try out both Swagger and RAML and started by writing a prototype spec in the Swagger editor, this would be really useful. The Swagger editor defaults to Swagger 2.0

Generating JSON schema as seperate files

Hello,

We were able to generate the RAML out of the swagger successfully without any issues but the RAML file generated when loaded to API designer raised error reporting "Request Entity too large" . The reason for this what I understand from mule forum is that the web API designer is having some limitation on the size\length of the file . The currently the size of the RAML is due to the JSON schema represented directly on the RAML file (instead of referencing them).

As of now the only option left out for us is to reduce the size of the RAML which is by segregating the generated JSON schema separated as a file and reducing the overall size of the RAML by just referring them. But this seems to be a tedious task defeating the purpose of accelerating the swagger to RAML conversion.

Could you please suggest or make the appropriate enhancement on the conversion tool.

PFA the RAML generated from the swagger to raml utlity.
inventory.zip

Thanks & Regards
Arun

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.