We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
For example, using has:
has
#!/bin/bash yq e " .paths[][] | {.operationId: { \"requiresAuthentication\": has(\"security\")}} | select(.[]) as \$i ireduce ({}; . + \$i) " <(printf '%s\n' ' x-require-authenticated: &x-require-authenticated - bearer_auth: [] - api_key: [] paths: /ping: get: operationId: op1 security: *x-require-authenticated /ping2: get: operationId: op2 security: *x-require-authenticated ') echo ---- yq e " .paths[][] | {.operationId: { \"requiresAuthentication\": has(\"security\")}} | select(.[]) as \$i ireduce ({}; . + \$i) " <(printf '%s\n' ' x-require-authenticated: &x-require-authenticated security: - bearer_auth: [] - api_key: [] paths: /ping: get: operationId: op1 !!merge <<: *x-require-authenticated /ping2: get: operationId: op2 !!merge <<: *x-require-authenticated ')
op1: requiresAuthentication: true op2: requiresAuthentication: true ---- op1: requiresAuthentication: false op2: requiresAuthentication: false
I presume I need to resolve references beforehand somehow, because . as \$item ireduce ({}; . * \$item gives:
. as \$item ireduce ({}; . * \$item
paths: /ping: get: operationId: op1 <<: *x-require-authenticated /ping2: get: operationId: op2 <<: *x-require-authenticated
and yq treats it as if << were a literal key, because has(\"<<\") is true in this case and viceversa
has(\"<<\")
Version of yq: 4.27.2 / latest v4.34.2 Operating system: linux Installed via: go install
The text was updated successfully, but these errors were encountered:
Looks like explode(.) needs to be manually called to resolve merges.
explode(.)
https://mikefarah.gitbook.io/yq/operators/anchor-and-alias-operators
Sorry, something went wrong.
No branches or pull requests
For example, using
has
:I presume I need to resolve references beforehand somehow, because
. as \$item ireduce ({}; . * \$item
gives:and yq treats it as if << were a literal key, because
has(\"<<\")
is true in this case and viceversaVersion of yq: 4.27.2 / latest v4.34.2
Operating system: linux
Installed via: go install
The text was updated successfully, but these errors were encountered: