https://github.com/mulesoft/oas-raml-converter
(DEPRECATED) Converts between OAS and RAML API specifications
https://github.com/mulesoft/oas-raml-converter
oas openapi-spec raml raml-converter raml-tooling swagger
Last synced: 4 months ago
JSON representation
(DEPRECATED) Converts between OAS and RAML API specifications
- Host: GitHub
- URL: https://github.com/mulesoft/oas-raml-converter
- Owner: mulesoft
- License: mit
- Archived: true
- Fork: true (stoplightio/api-spec-converter)
- Created: 2016-08-05T09:49:24.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2019-09-05T20:45:29.000Z (over 5 years ago)
- Last Synced: 2025-01-18T02:34:54.774Z (4 months ago)
- Topics: oas, openapi-spec, raml, raml-converter, raml-tooling, swagger
- Language: JavaScript
- Homepage: https://mulesoft.github.io/oas-raml-converter/
- Size: 31.3 MB
- Stars: 73
- Watchers: 242
- Forks: 48
- Open Issues: 32
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# OAS RAML Converter (DEPRECATED) [](https://www.npmjs.com/package/oas-raml-converter)
# Deprecation Notice
**This project has been deprecated and is no longer maintained. Please use [WebAPI Parser](https://github.com/raml-org/webapi-parser) converter instead. https://github.com/raml-org/webapi-parser**### Master [](https://travis-ci.org/mulesoft/oas-raml-converter) [](https://coveralls.io/github/mulesoft/oas-raml-converter?branch=master)
### v0.2.x [](https://travis-ci.org/mulesoft/oas-raml-converter) [](https://coveralls.io/github/mulesoft/oas-raml-converter?branch=v0.2.x)
This package helps to convert between different API specifications. It was originally forked from [the stoplight.io converter](https://github.com/stoplightio/api-spec-converter).
## Supported Conversions (beta)
- OAS (OAS 2.0) -> RAML 1.0: [Complete Functional Specification](./docs/OAS20-to-RAML10.md)
- RAML 1.0 -> OAS (OAS 2.0): [Complete Functional Specification](./docs/RAML10-to-OAS20.md)
- RAML 1.0 -> OAS (OAS 3.0): [Complete Functional Specification](./docs/RAML10-to-OAS30.md)
- RAML 0.8 -> OAS (OAS 2.0)
- RAML 0.8 -> RAML 1.0## Using
### 1. Online web page
For an online conversion, use: [https://mulesoft.github.io/oas-raml-converter](https://mulesoft.github.io/oas-raml-converter).
### 2. Command line tool
This command needs to be execute after cloning repository,
```
npm run build
```This utility helps you converting local files from your command line.
```
./lib/bin/converter.js --from OAS20 --to RAML ./path/to/swagger.json
./lib/bin/converter.js --from OAS20 --to RAML ./path/to/swagger.json > output.raml./lib/bin/converter.js --from RAML --to OAS20 ./path/to/source.raml > swagger.json
```Or install globally and then:
```
oas-raml-converter --from OAS20 --to RAML ./path/to/swagger.json
oas-raml-converter --from OAS20 --to RAML ./path/to/swagger.json > output.ramloas-raml-converter --from RAML --to OAS20 ./path/to/source.raml > swagger.json
```### 3. As a service
For a REST API of the converter, you can start it in an express server, checkout the [oas-raml-converter-service](https://github.com/mulesoft/oas-raml-converter-service) project.
### 4. As a dependency
#### Installation (NodeJS or Browser)
```bash
npm install --save oas-raml-converter
```#### Initializing a converter
Raml 1.0 to OAS 2.0:
```js
var converter = require('oas-raml-converter');
var raml10ToOas20 = new converter.Converter(converter.Formats.RAML, converter.Formats.OAS20);
```OAS 2.0 to Raml 1.0:
```js
var converter = require('oas-raml-converter');
var oas20ToRaml10 = new converter.Converter(converter.Formats.OAS20, converter.Formats.RAML);
```The converter detects the input raml format automatically by passing `RAML` import format, so:
Raml 0.8 to OAS 2.0:
```js
var converter = require('oas-raml-converter');
var raml08ToOas20 = new converter.Converter(converter.Formats.RAML, converter.Formats.OAS20);
```
Raml 0.8 to Raml 1.0:
```js
var converter = require('oas-raml-converter');
var raml08ToRaml10 = new converter.Converter(converter.Formats.RAML, converter.Formats.RAML);
```#### Converting from a file or url
```js
oas20ToRaml10.convertFile('/path/to/swagger.json').then(function(raml) {
console.log(raml); // raml is raml yaml string
})
.catch(function(err) {
console.error(err);
});
```#### Converting from a string or json
```js
var myOasString = '...';
oas20ToRaml10.convertData(myOasString).then(function(raml) {
console.log(raml); // raml is raml yaml string
})
.catch(function(err) {
console.error(err);
});
```#### Passing options
```js
var options = {
validate: false, // Parse both input and output to check that its a valid document
validateImport: false, // Only validate input
validateExport: false, // Only validate output
format: 'yaml', // Output format: json (default for OAS) or yaml (default for RAML)
fs: { ... } // Use a custom file system solver (not yet available)
};oas20ToRaml10.convertFile('/path/to/swagger.json', options).then(function(raml) {
console.log(raml); // raml is raml yaml string
})
.catch(function(err) {
console.error(err);
});
```## Contributing
Contributions are welcome! Please check the current issues to make sure what you are trying to do has not already been discussed.
### Steps
1. Fork.
2. Make changes.
3. Write tests.
4. Send a pull request.### Develop
Install dependencies:
```bash
npm install
```Run tests:
```bash
npm test
```Run eslint to check linting errors:
```bash
npm run eslint
```