mulesoft / oas-raml-converter

(DEPRECATED) Converts between OAS and RAML API specifications
https://mulesoft.github.io/oas-raml-converter/
MIT License
73 stars 48 forks source link

In OAS30, inheriting schemas miss their required fields #46

Open jsamr opened 6 years ago

jsamr commented 6 years ago

oas-raml-coverter version 1.1.35

When inheriting from Foo, FooFromBar schema should have a required array with its field names in it.

I believe it is related to #43 since the schemas afflicted with the bug are also wrongly typed string.

Full reproduction

Raml definition

types:
  Foo:
    type: object
    properties:
      foo1:
        type: number
        required: true
  BarFromFoo:
    type: Foo
    properties:
      bar1:
        type: string
        required: true

Expected output (oas3+json)

{
  "components": {
    "schemas": {
      "Foo": {
        "type": "object",
        "properties": {
          "foo1": {
            "type": "number"
          }
        },
        "required": [
          "foo1"
        ]
      },
      "BarFromFoo": {
        "allOf": [
          {
            "$ref": "#/components/schemas/Foo"
          },
          {
            "properties": {
              "bar1": {
                "type": "string"
              },
              "bar2": {
                "type": "string"
              }
            },
            "type": "object"
          }
        ],
        "required": [
          "bar1",
          "bar2"
        ]
      }
    }
  }
}

Observed output (oas3+json)

{
  "components": {
    "schemas": {
      "Foo": {
        "type": "object",
        "properties": {
          "foo1": {
            "type": "number"
          }
        },
        "required": [
          "foo1"
        ]
      },
      "BarFromFoo": {
        "allOf": [
          {
            "$ref": "#/components/schemas/Foo"
          },
          {
            "properties": {
              "bar1": {
                "type": "string"
              },
              "bar2": {
                "type": "string"
              }
            },
            "type": "object"
          }
        ],
        "type": "string"
      }
    }
  }
}
jsamr commented 6 years ago

Reproduction available here: https://github.com/jsamr/oas-raml-converter-missing-required