Skip to content

Handle upcast and downcast of JSON Schemas with multiple types #1786

@darrelmiller

Description

@darrelmiller

In OpenAPI 3.1, JSON Schema can have a type that is an array.

  • If the array has only one value that is not null, treat as if the type was just a string
  • If the array has only one value that is null, in v3/v2 emit as nullable/x-nullable and emit no type
  • If the array has two values where one is null, then in v3/v2 emit as nullable/x-nullable and convert type to string of other value.
  • If the array has two values where neither is null, or more than two values, then in v3/v2 do not emit the type field. By omitting the type field we keep the schema from creating false negatives and it is more likely that downstream tooling will flag the issue.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions