redocly-cli icon indicating copy to clipboard operation
redocly-cli copied to clipboard

Wrong lint message when referencing from a wrong location

Open tatomyr opened this issue 3 years ago • 0 comments

Describe the bug

If a valid part of a definition is being referenced from a section that does not expect this syntax, the linter shows an incorrect message inside the valid part.

To Reproduce

Consider this definition:

# openapi.yaml

openapi: 3.0.0
components:
  requestBodies:
    CreateContainer:
      content:
        application/json:
          schema:
            type: object
  schemas:
    PipeContainerCreate:
      title: PipelineContainerCreate
      allOf:
      - "$ref": "#/components/requestBodies/CreateContainer"

Run redocly lint openapi.yaml --extends minimal

Although the requestBody could receive the content field, linter notes that Property content is not expected here..

Expected behavior

We need to handle this common issue and show a proper message and a "referenced from".

Redocly Version(s) 1.0.0-beta.104

Node.js Version(s) v16.14.0

Additional context See this conversation for additional context.

tatomyr avatar Jul 14 '22 13:07 tatomyr