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

filter-in on tags includes operations that don't have a tag #1741

Open
michael-wolfenden opened this issue Sep 19, 2024 · 1 comment
Open
Labels
Type: Bug Something isn't working

Comments

@michael-wolfenden
Copy link

Describe the bug

filter-in on tags includes operations that don't have a tag

To Reproduce
Steps to reproduce the behavior:

  1. Given this redocly.yaml file
decorators:
  remove-unused-components: on
  filter-in:
    property: tags
    value: [cats]
    matchStrategy: all
  1. And this OpenAPI file(s) spec.yml

NOTE; /dogs doesn't contain a tags property

openapi: "3.0.0"
info:
  version: 1.0.0
  title: Swagger Petstore
paths:
  /cats:
    get:
      tags:
        - cats
      responses:
        200:
          description: A list of cats
          content:
            text/plain:
              schema:
                type: string
  /dogs:
    get:
      responses:
        200:
          description: A list of dogs
          content:
            text/plain:
              schema:
                type: string
  1. Run this command with these arguments... redocly bundle .\spec.yaml --config .\redocly.yaml --output .\output.yml
  2. output.yml contains both operations
openapi: 3.0.0
info:
  version: 1.0.0
  title: Swagger Petstore
paths:
  /cats:
    get:
      tags:
        - cats
      responses:
        '200':
          description: A list of cats
          content:
            text/plain:
              schema:
                type: string
  /dogs:
    get:
      responses:
        '200':
          description: A list of dogs
          content:
            text/plain:
              schema:
                type: string

Expected behavior

I would have expected the output to only contain the /cats operation.

NOTE; filter-in works correctly if

  • /dogs has a tag
  /dogs:
    get:
      tags:
        - dogs
  • /dogs has an empty tags property
  /dogs:
    get:
      tags: []

Redocly Version(s)

redocly --version
1.13.0

Node.js Version(s)

node -v
v20.11.0

OS, environment

Windows

@michael-wolfenden michael-wolfenden added the Type: Bug Something isn't working label Sep 19, 2024
@emaas
Copy link

emaas commented Oct 29, 2024

We are running into the same issue.

Looking at the code, it looks like this behavior is on purpose:
should include path without x-audience property
I do however agree that this is unexpected behavior.
And we are also running into this issue.

Perhaps a new match strategy can be added. Something like any_excluding_empty, and all_excluding_empty?

Another approach would be to add a decorator called "filter_out_non_existing" that would have the responsibility of filtering out items not containing a certain property.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants