Closed CanVuralStudocu closed 1 year ago
https://swagger.io/docs/specification/using-ref/#sibling suggests otherwise:
Any sibling elements of a $ref are ignored. This is because $ref works by replacing itself and everything on its level with the definition it is pointing at.
Instead, you have to use allOf
:
{
"allOf": [
{ "$ref": "#/components/schemas/Pet" }
],
"description": "This is a sibling description that should be allowed."
}
I found this issue that confirms $ref
can have siblings: https://github.com/OAI/OpenAPI-Specification/issues/2744
@CanVuralStudocu That's an addition to the OAS3.1 spec. This rule as configured doesn't apply to OAS3.1 and is only enabled for OAS3 and 2
Describe the bug I think according to the OpenAPI spec (https://swagger.io/specification/#reference-object) reference objects can have
$ref
,summary
anddescription
fields. But the Spectral ruleno-$ref-siblings
marks thedescription
sibling of$ref
as error.To Reproduce
spectral lint
no-$ref-siblings $ref must not be placed next to any other properties
Expected behavior
description
andsummary
should be allowed as a sibling to$ref