Forum Discussion

Stoplight's avatar
Stoplight
Community Manager
9 months ago

Spectral: How to correctly override oas3-unused-component targetting components.schemas.$ref?

Originally posted by user GableMike to the Stoplight Community on 08/10/2023 at 14:47 ET.

I apologize if this is the wrong channel for this. I could not find anything explicitly related to spectral in this discord, though the spectral github support section links to this https://github.com/stoplightio/spectral#ℹ%EF%B8%8F-support

Here is an edited version of my root OAS file:

openapi: "3.1.0"
servers:
  - url: https://api.com
    description:  API
info:
  title:  API
  description: API
  contact:
    name:  Engineering
    url: https://api.com
    email: engineers@api.com
  version: 0.0.1
paths:
  $ref: "paths/_index.yaml"
components:
  schemas: 
    $ref: "schemas/_index.yaml"
tags:
  - name: api-keys

Here is my spectral config file:

extends: ["spectral:oas"]
overrides:
  - files:
      - "main.yaml#components.schemas.$ref"
    rules:
      oas3-unused-component: "off"

Here is the warning I am trying to suppress with the override:

 17:11  warning  oas3-unused-component  Potentially unused component has been detected.  components.schemas.$ref

It does not suppress the warning. I don't understand why.

I'd also like the linter to give more information on which parts of the component it thinks are not being used.

  • GableMike (OP) [08/15/2023 - 17:19 ET]

    I no longer have need to override this because I have restructured my OpenAPI spec using redocly split and because I have fixed the error I was early trying to supress as I was onboarding to using spectral lint. Thank you for following up though.

  • Stoplight's avatar
    Stoplight
    Community Manager

    Dan T (Staff) [08/15/2023 - 17:17 ET]

    Hi GableMike, looks like the community doesn't have any help for you on this one. Perhaps you might consider posting this question in the Discussions section of the Spectral Github repo to see if you might get some guidance.

    https://github.com/stoplightio/spectral/discussions

    • Stoplight's avatar
      Stoplight
      Community Manager

      GableMike (OP) [08/15/2023 - 17:19 ET]

      I no longer have need to override this because I have restructured my OpenAPI spec using redocly split and because I have fixed the error I was early trying to supress as I was onboarding to using spectral lint. Thank you for following up though.