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

Wrong OAS30 object type definition which faultily inherits from string

jsamr opened this issue · comments

oas-raml-coverter version 1.1.35

The OAS parser used by ReDoc project complains about a forbidden definition:

Error: Incompatible types in allOf at "#/components/schemas/BarFromFoo"

BarFromFoo should not be of "type": "string"

Full reproduction

Raml definition

types:
  Foo:
    type: object
  BarFromFoo:
    type: Foo
    properties:
      foo: string

Expected output

{
  "components": {
    "schemas": {
      "Foo": {
        "type": "object"
      },
      "BarFromFoo": {
        "allOf": [
          {
            "$ref": "#/components/schemas/Foo"
          },
          {
            "properties": {
              "foo": {
                "type": "string"
              }
            },
            "type": "object"
          }
        ]
      }
    }
  }
}

Observed output

{
  "components": {
    "schemas": {
      "Foo": {
        "type": "object"
      },
      "BarFromFoo": {
        "allOf": [
          {
            "$ref": "#/components/schemas/Foo"
          },
          {
            "properties": {
              "foo": {
                "type": "string"
              }
            },
            "type": "object"
          }
        ],
        "type": "string"
      }
    }
  }
}

According to the OpenAPI 3.0 specification, for allOf, anyOf, oneOf keywords, there is no need to have the definition on type. So, maybe, one solution is just not to generate "type:" when those keywords are generated.