Skip to content

Nullable fields produce '"nullable": true' in a oneOf #19

Open
@OxonianCambion

Description

@OxonianCambion

I've been using your serverless-openapi-documenter and I think the root cause is in here.

When converting something of the form:

"foo": {
  "title": "foo",
  "type": [
    "string",
    "null"
  ]
}

the converted output is

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

However, I don't think that is valid. (It certainly gives errors when I try to use the generated open api file, e.g. in postman)
I think it needs to be either:

"foo": {
  "title": "foo",
  "type": "string",
  "nullable": true
}

or

"foo": {
  "title": "foo",
  "oneOf": [
    {
      "type": "string"
    },
    {
      "type": "null"
    }
  ]
}

with the former looking slightly neater. Both work correctly when I manually update my generated open api file.

I can see convertNull in Converter.js appears to be making the transform, but don't know if it is as easy as just changing its return value.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions