Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

False unused/orphaned positive with polymorphic responses #142

Closed
scop opened this issue Oct 11, 2022 · 2 comments
Closed

False unused/orphaned positive with polymorphic responses #142

scop opened this issue Oct 11, 2022 · 2 comments
Assignees

Comments

@scop
Copy link
Contributor

scop commented Oct 11, 2022

components:
  schemas:
    ErrSomething:
      # ...
paths:
  /fish/paste:
    get:
      responses:
        default:
          content:
            application/json:
              schema:
                oneOf:
                  - $ref: "#/components/schemas/ErrSomething"
                  # ...
                discriminator:
                  # ...

Here, I get a warning

#/components/schemas/ErrSomething` is potentially unused or has been orphaned

This specific one seems to occur for polymorphic responses, i.e. components that are schema alternatives in a oneOf only in the doc, i.e. not as direct $refs below response schema.

I haven't checked if this happens similarly for polymorphic requests, but I guess it might.

https://github.com/OAI/OpenAPI-Specification/blob/3.1.0/versions/3.1.0.md#discriminator-object

@daveshanley
Copy link
Owner

Thanks for reporting, I will investigate and resolve this ASAP.

@daveshanley daveshanley self-assigned this Oct 12, 2022
daveshanley added a commit that referenced this issue Oct 12, 2022
There was a bug in the `unused_definitions` function that was not looking in all polymorphic collections for use. Added the missing two checks to address #142

Also, there was a bug I found when testing rules, I noticed that when running without a version, rules are called multipled times. This behavior is incorrect, there is no way to be reliable or accurate if multiple
versions of rule for different versions are operating. Added a check for a missing version and format. Without this data, the rule is skipped.

Updated some tests to include version details in sample spec snippet code.
daveshanley added a commit that referenced this issue Oct 12, 2022
* Applied fix for #142 and some other tweaks

There was a bug in the `unused_definitions` function that was not looking in all polymorphic collections for use. Added the missing two checks to address #142

Also, there was a bug I found when testing rules, I noticed that when running without a version, rules are called multipled times. This behavior is incorrect, there is no way to be reliable or accurate if multiple
versions of rule for different versions are operating. Added a check for a missing version and format. Without this data, the rule is skipped.

Updated some tests to include version details in sample spec snippet code.

* Tuning CI/CD config

Disabling auto-tag for main push, not everything needs a release. Also bumping version on go.
@daveshanley
Copy link
Owner

This was a bug, essentially two of the three allOf, oneOf and anyOf polymorphic collections available in the index, was not being checked as part of the unused_definition function.

Thank you for your help in making vacuum better!

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

No branches or pull requests

2 participants