How to match keys by partial name when location isn't known? #955
-
I'm working with some OpenAPI definitions that have
I've attached the top part of an OpenAPI file that contains a few of these properties. It's YAML, even though the file name is .txt. I hack around at programming and write API documentation, but I haven't been able to figure out how to do this using yq. I've tried some of the examples to get my feet wet, and some work and some don't. One that doesn't work is
Just returns an empty set when my sample.yaml file definitely contains values that have "b" in them. So I would greatly appreciate any help or insights that anyone can shar |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 11 replies
-
You're on the right track with that, but first you have to tell it to recurse though the whole structure. So you will need to do somthing like:
Explanation:
|
Beta Was this translation helpful? Give feedback.
You're on the right track with that, but first you have to tell it to recurse though the whole structure. So you will need to do somthing like:
Explanation:
..
tells yq to recursively match all the nodesselect(tag == "!!map")
we only select maps (as arrays wont havex-
keys anywaywith_entries(select(.key | match("x-.*")))
we filter out the maps to only include the keys that start with x-