Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

False Positives in oas3-unused-component Rule for Schemas Referenced via oneOf, Vendor Extensions, and Property Access #578

Open
BentEngbers opened this issue Nov 13, 2024 · 1 comment

Comments

@BentEngbers
Copy link

BentEngbers commented Nov 13, 2024

In the following cases, Vacuum incorrectly flags the schemas a, b, and c as false positives when using the oas3-unused-component rule with OpenAPI version 3.1.0.

Cases

  1. oneOf Schema

    oneOf:
      - $ref: "#/components/schemas/a"
      - type: "null"

    Vacuum incorrectly marks a as unused when referenced within a oneOf structure.

  2. Vendor Extension

    x-publish: false
    $ref: '#/components/schemas/b'

    Vacuum mistakenly identifies b as unused when it is referenced alongside a vendor extension.

  3. Property Access

openapi: 3.1.0
paths:
  /example:
    get:
      operationId: example
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/response/properties/foo"
components:
  schemas:
    response:
      type: object
      properties:
        foo:
          type: string

Vacuum incorrectly flags example as unused when accessing a property within the schema:

 `#/components/schemas/response` is potentially unused or has been orphaned          | oas3-unused-component
@BentEngbers BentEngbers changed the title The oas3-unused-component rules produces false positives False Positives in oas3-unused-component Rule for Schemas Referenced via oneOf, Vendor Extensions, and Property Access Nov 13, 2024
@daveshanley
Copy link
Owner

Can you provide a snippet that we can run to validate this? trying to re-create things from single lines out of context takes a long time.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants