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

In OAS30, nullables are faultily converted to generic "object" type

jsamr opened this issue · comments

oas-raml-coverter version 1.1.35

Similar to #42.

bar2 field of FooFromBar schema should be of schema Foo with nullable option set, but is instead set to "type": "object"

OAS30 reference on nullable

Full reproduction

RAML Source

types:
  Foo:
    properties:
      bar1: number
  FooFromBar:
    properties:
      bar2: Foo?

Expected (oas3+json)

{
  "components": {
    "schemas": {
      "Foo": {
        "properties": {
          "bar1": {
            "type": "number"
          }
        },
        "required": [
          "bar1"
        ],
        "type": "object"
      },
      "FooFromBar": {
        "properties": {
          "bar2": {
            "nullable": true,
            "allOf": {
              "$ref": "#/components/schemas/Foo"
            }
          }
        },
        "required": [
          "bar2"
        ],
        "type": "object"
      }
    }
  }
}

Observed (oas3+json)

{
  "components": {
    "schemas": {
      "Foo": {
        "properties": {
          "bar1": {
            "type": "number"
          }
        },
        "required": [
          "bar1"
        ],
        "type": "object"
      },
      "FooFromBar": {
        "properties": {
          "bar2": {
            "type": "object"
          }
        },
        "required": [
          "bar2"
        ],
        "type": "object"
      }
    }
  }
}

In case the raml as:

   name: string | nil

The OAS3.0 converted contains

         "name": {
                        "oneOf": [
                           {
                             "type": "string"
                           },
                           {
                             "type": "nil"
                           }
                         ]
                       },

where the expectation could be:

        "name": {
                        "oneOf": [
                           {
                             "type": "string"
                           }],
                          nullable: true                             
                       },