Redocly/redocly-cli

Validation error: type required when nullable is true

pantsmann opened this issue · 2 comments

What happened?

A property has nullable = true and allOf set to $ref and the validation says there is an error because type is missing.

...
      "properties":{
           "somefield": {
                  "allOf": [
                        { 
                            "$ref": "#/components/schemas/SomeType"
                        }
                   ]
                   "nullable": true
...

What should have happened instead?

"allOf", in this case, takes the place of "type" so there should be no error. If this is not the case then what type would not conflict with the $ref?

I recognize that the 3.0.3 spec only mentions "type" being needed if "nullable" is true, but the construction above is valid and is the standard way of including a ref. At least that is my understanding.

Minimal reproducible OpenAPI snippet

Screenshots

Additional context

extension version v0.4.3
OpenAPI version 3.0.3

This looks like a bug. Thanks for reporting!

Moving the issue into the Redocly CLI repository as that behaviour comes from the Redocly linter.

This is not valid.

image

This is not valid:

type:
  nullable: true
  allOf:
    $ref: '#/components/schemas/SomeType'

This is valid:

type:
  nullable: true
  type: # (replace with the same type as SomeType such as string, object, etc.
  allOf:
    $ref: '#/components/schemas/SomeType'