Forum Discussion

frank_fjs's avatar
frank_fjs
Occasional Contributor
3 years ago

Standarization: Regex custom rule filter expresion to retrieve nodes with a specific tag

Hi,

 

I am trying to write a regex custom rule but I can't retrieve the expected nodes using filter expresion. A code example is this:

 

 

paths:
  /inventory:
    get:
      tags:
      - pagination
      responses:
        200:
          description: search results
          schema:
            type: object
            properties:
              _prev:
                type: string
              _next:
                type: string

 

 

Next JsonPath expresion don't work:

$.paths.*.get.[?(@.tags contains 'pagination')].responses.200.schema.properties.[?(@._prev && @._next)]

$.paths.*.[?(@.get.tags contains 'pagination')].*.responses.200.schema.properties.[?(@._prev && @._next)]

$.paths.*.get[?(@.tags contains 'pagination')].responses.200.schema.properties.[?(@._prev && @._next)]      (without dot after get)

$.paths.*[?(@.get.tags contains 'pagination')].*.responses.200.schema.properties.[?(@._prev && @._next)]    (without dot after first *)

 

 

 

Simplifying my problem, directly, I cannot retrieve the nodes using the first filter for the tag

$.paths.*.get.[?(@.tags contains 'pagination')]

$.paths.*.[?(@.get.tags contains 'pagination')]

$.paths.*.get[?(@.tags contains 'pagination')]    (without dot after get)

$.paths.*[?(@.get.tags contains 'pagination')]    (without dot after first *)

 

I tried too the most basic example

$.paths.*.get.[?(@.tags)]

$.paths.*.[?(@.get.tags)]

$.paths.*.get[?(@.tags)]    (without dot after get)

$.paths.*[?(@.get.tags)]    (without dot after first *)

 

In all these examples Custom Rule editor show me "Path not matched"

 

But I try it using "Jayway JsonPath Evaluator", that I found referenced in "SmartBear AlertSite - JSONPath Syntax", over exported JSON of the above yaml and all they work

 

Am I doing anything wrong?

May anyone give me a example?

 

Thank a lot

No RepliesBe the first to reply