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

RAML json schema REFs are not resolved recursively

ArtFlag opened this issue · comments

Hi,

Thanks for this converter!
I'm trying to convert some RAML1.0 to OAS2.

I use this RAML file:

#%RAML 1.0

title: Webhooks
version: 0
baseUri: https://example.com/v0/d/payments
mediaType: application/json
protocols: [ HTTPS ]
documentation:
  - title: Payment Provider Webhooks
    content: Allows integration of a payment provider.

/instruments:
  displayName: Instruments webhooks
  description: |
    Instrument webhooks description
  post:
    displayName: Create financial instrument
    body:
      application/json:
        type: !include hook/create_instrument.json
    description: |
      Description here
    responses:
      200:
        description: |
          The operation was successful.
        body:
         application/json:
           type: !include hook/operation_success.json

This last line import this hook/operation_success.json file:

{
    "$schema": "http://json-schema.org/draft-04/schema#",
    "type": "array",
    "items": {
        "items": {
            "$ref": "./financial_instrument_transaction.json"
        }
    }
}

The $ref field points to a file that lives in the same folder. When I build my html output from RAML, everything is fine.

But when I convert my file to OAS2, i get an incorrect $ref value, notice "$ref": "./financial_instrument_transaction.json":

{
  "swagger": "2.0",
  "info": {
    "title": "Webhooks",
    "version": "0"
  },
  "host": "example.com",
  "basePath": "/v0/d/payments",
  "schemes": [
    "https"
  ],
  "consumes": [
    "application/json"
  ],
  "produces": [
    "application/json"
  ],
  "paths": {
    "/instruments": {
      "post": {
        "description": "Description here\n",
        "operationId": "Create financial instrument",
        "responses": {
          "200": {
            "description": "The operation was successful.\n",
            "schema": {
              "title": "Schema of a successful financial operation.",
              "description": "A list of transactions that resulted from a successful operation. If the operation is asynchronous, this list is empty. To complete the request, use the Payment Provider Asynchronous API to notify NewStore of the outcome of the request.",
              "type": "array",
              "items": {
                "type": "string",
                "items": {
                  "$ref": "./financial_instrument_transaction.json"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "title": "Create instrument operation schema",
              "required": [
                "account_id"
              ],
              "type": "object",
              "properties": {
                "account_id": {
                  "type": "string"
                }
              }
            },
            "in": "body",
            "name": "body",
            "required": true
          }
        ]
      }
    }
  }
}

So it seems that the converter does not resolve refs recursively. The correct conversion should be "$ref": "hook/financial_instrument_transaction.json" or the whole referenced file should be pulled in (which would make more sense).

Could this be fixed, somehow?

Thanks 🙂