Skip to content

RFC9535 - filter expression does not return expected results #42

@jeremyfiel

Description

@jeremyfiel

Using this example:

search for descendants of paths where tags exists and at least one tags matches string value Enterprise-Only

$.paths..[?(@.tags && @.tags[?(@ == 'Enterprise-Only')])]
{
  "openapi": "3.1.0",
  "info": {
    "title": "...",
    "description": "...",
    "version": "1.0.0"
  },
  "tags": [
    {
      "name": "Enterprise-Only",
      "description": "...\n"
    }
  ],
  "paths": {
    "/metrics": {
      "get": {
        "operationId": "getPrometheusMetrics",
        "responses": {
          "200": {
            "description": "...",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "/super/secret": {
      "get": {
        "tags": [
          "Enterprise-Only"
        ],
        "responses": {
          "200": {
            "description": "...",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "/jeremy": {
      "get": {
        "tags": [
          "test"
        ],
        "summary": "...'"
      }
    }, "test": {}
  }
}

Expected output:

[
  {
    "responses": {
      "200": {
        "content": {
          "text/plain": {
            "schema": {
              "type": "string"
            }
          }
        },
        "description": "..."
      }
    },
    "tags": [
      "Enterprise-Only"
    ]
  }
]

Actual Output:

C:\Users\fiel\AppData\Local\npm-cache\_npx\6884673ebe34dd85\node_modules\jsonpath\generated\parser.js:166
        throw new Error(str);
              ^

Error: Lexical error on line 1. Unrecognized text.
... 'Enterprise-Only')])]
-----------------------^
    at Parser.parseError (C:\Users\fiel\AppData\Local\npm-cache\_npx\6884673ebe34dd85\node_modules\jsonpath\generated\parser.js:166:15)
    at Parser.parser.yy.parseError (C:\Users\fiel\AppData\Local\npm-cache\_npx\6884673ebe34dd85\node_modules\jsonpath\lib\parser.js:13:17)
    at Object.parseError (C:\Users\fiel\AppData\Local\npm-cache\_npx\6884673ebe34dd85\node_modules\jsonpath\generated\parser.js:341:28)
    at Object.next (C:\Users\fiel\AppData\Local\npm-cache\_npx\6884673ebe34dd85\node_modules\jsonpath\generated\parser.js:595:25)
    at Object.lex (C:\Users\fiel\AppData\Local\npm-cache\_npx\6884673ebe34dd85\node_modules\jsonpath\generated\parser.js:605:22)
    at lex (C:\Users\fiel\AppData\Local\npm-cache\_npx\6884673ebe34dd85\node_modules\jsonpath\generated\parser.js:194:28)
    at Parser.parse (C:\Users\fiel\AppData\Local\npm-cache\_npx\6884673ebe34dd85\node_modules\jsonpath\generated\parser.js:207:26)
    at JSONPath.nodes (C:\Users\fiel\AppData\Local\npm-cache\_npx\6884673ebe34dd85\node_modules\jsonpath\lib\index.js:118:26)
    at JSONPath.paths (C:\Users\fiel\AppData\Local\npm-cache\_npx\6884673ebe34dd85\node_modules\jsonpath\lib\index.js:105:22)
    at file:///C:/Users/fiel/AppData/Local/npm-cache/_npx/6884673ebe34dd85/node_modules/openapi-overlays-js/src/overlay.js:13:33

Node.js v20.16.0

Example 2:

$.paths[?!@.get]

same json document as above

Expected Output:

[
  {}
]

Actual output

C:\Users\fiel\AppData\Local\npm-cache\_npx\6884673ebe34dd85\node_modules\jsonpath\generated\parser.js:166
        throw new Error(str);
              ^

Error: Lexical error on line 1. Unrecognized text.
$.paths[?!@.get]
--------^
    at Parser.parseError (C:\Users\fiel\AppData\Local\npm-cache\_npx\6884673ebe34dd85\node_modules\jsonpath\generated\parser.js:166:15)
    at Parser.parser.yy.parseError (C:\Users\fiel\AppData\Local\npm-cache\_npx\6884673ebe34dd85\node_modules\jsonpath\lib\parser.js:13:17)
    at Object.parseError (C:\Users\fiel\AppData\Local\npm-cache\_npx\6884673ebe34dd85\node_modules\jsonpath\generated\parser.js:341:28)
    at Object.next (C:\Users\fiel\AppData\Local\npm-cache\_npx\6884673ebe34dd85\node_modules\jsonpath\generated\parser.js:595:25)
    at Object.lex (C:\Users\fiel\AppData\Local\npm-cache\_npx\6884673ebe34dd85\node_modules\jsonpath\generated\parser.js:605:22)
    at lex (C:\Users\fiel\AppData\Local\npm-cache\_npx\6884673ebe34dd85\node_modules\jsonpath\generated\parser.js:194:28)
    at Parser.parse (C:\Users\fiel\AppData\Local\npm-cache\_npx\6884673ebe34dd85\node_modules\jsonpath\generated\parser.js:207:26)
    at JSONPath.nodes (C:\Users\fiel\AppData\Local\npm-cache\_npx\6884673ebe34dd85\node_modules\jsonpath\lib\index.js:118:26)
    at JSONPath.paths (C:\Users\fiel\AppData\Local\npm-cache\_npx\6884673ebe34dd85\node_modules\jsonpath\lib\index.js:105:22)
    at file:///C:/Users/fiel/AppData/Local/npm-cache/_npx/6884673ebe34dd85/node_modules/openapi-overlays-js/src/overlay.js:13:33

Node.js v20.16.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions