mulesoft / oas-raml-converter

(DEPRECATED) Converts between OAS and RAML API specifications

Home Page:https://mulesoft.github.io/oas-raml-converter/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

When run different scripts that convert the same oas to raml, return differents results.

LucasLudueno opened this issue · comments

For example:
OasFile:

{
  "swagger": "2.0",
  "info": {
    "version": "1.0.0",
    "title": "Swagger Petstore"
  },
  "host": "petstore.swagger.io",
  "basePath": "/api",
  "schemes": [
    "http"
  ],
  "consumes": [
    "application/json"
  ],
  "produces": [
    "application/json"
  ],
  "paths": {
    "/reviews": {
      "x-raml-resource-displayName": "reviews"
    },
    "/reviews/{id}": {
      "parameters": [
        {
          "name": "id",
          "in": "path",
          "description": "ID of review",
          "required": true,
          "type": "string"
        }
      ],
      "post": {
        "operationId": "GET_reviews-id",
        "description": "Returns a review",
        "parameters": [
          {
            "name": "body",
            "in": "body",
            "description": "Review to add to the store",
            "schema": {
              "$ref": "#/definitions/NewReview"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "review response",
            "examples": {
              "application/json": {
                "$ref": "#/definitions/Review"
              }
            }
          }
        }
      },
      "x-raml-resource-displayName": "{id}"
    }
  },
  "definitions": {
    "Review": {
      "properties": {
        "code": {
          "type": "integer",
          "format": "int32"
        },
        "message": {
          "type": "string"
        }
      },
      "type": "object"
    },
    "NewReview": {
      "properties": {
        "title": {
          "type": "string"
        }
      },
      "type": "object"
    }
  }
}

Script 1:

#!/usr/local/bin/nano

const fs = require('fs');

const path = './oasFile.json';
const conv = require('oas-raml-converter');
const sw = new conv.Converter(conv.Formats.SWAGGER, conv.Formats.RAML10);

sw.convertFile(path).then((a) => console.log(a));

Script 2:

#!/usr/local/bin/nano

const fs = require('fs');

const path = './oasFile.json';
const conv = require('oas-raml-converter');
const sw = new conv.Converter(conv.Formats.SWAGGER, conv.Formats.RAML10);

sw.convertFile(path).then((a) => a);
sw.convertFile(path).then((a) => console.log(a));