stoplightio / spectral

A flexible JSON/YAML linter for creating automated style guides, with baked in support for OpenAPI v3.1, v3.0, and v2.0 as well as AsyncAPI v2.x.
https://stoplight.io/spectral
Apache License 2.0
2.43k stars 235 forks source link

Define Json Schema in OAS triggers no-$ref-siblings error #2531

Open htdan opened 11 months ago

htdan commented 11 months ago

Describe the bug Tried to define Json Schema as part of API response with a Schema definition in the components section as follows (simplified).

"components": { "schemas": { "Schema": { "type": "object", "properties": { "title": { "type": "string" }, "$ref": { "type": "string", "format": "iri-reference" } } } } }

When run spectral with the OAS, the following error reported. It is a false positive?

44:19 error no-$ref-siblings $ref must not be placed next to any other properties components.schemas.Schema.properties.title

To Reproduce

  1. Given a OpenAPI/AsyncAPI document with above definition for Schema object.
  2. Run this CLI command 'spectral lint '
  3. See error similar to above

Environment (remove any that are not applicable):