Skip to content
This repository has been archived by the owner on Sep 6, 2019. It is now read-only.

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

Open
jsamr opened this issue Aug 4, 2018 · 2 comments
Open

Comments

@jsamr
Copy link

jsamr commented Aug 4, 2018

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"
      }
    }
  }
}
@jsamr jsamr changed the title In OAS3, nullables are faultily converted to generic "object" type In OAS30, nullables are faultily converted to generic "object" type Aug 4, 2018
@jsamr
Copy link
Author

jsamr commented Aug 9, 2018

Full reproduction available here: https://github.com/jsamr/oas-raml-converter-missing-nullable

@yingqiaoshop
Copy link

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                             
                       },

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants