Overlay-Specification icon indicating copy to clipboard operation
Overlay-Specification copied to clipboard

Allow updating and removing primitive values

Open ralfhandl opened this issue 1 year ago • 1 comments

The current text does not allow directly targeting a primitive value, for example a certain string in the tags array of an Operation Object, and thus does not allow a convenient/workable way to remove or replace a certain tag name without knowing all other tag names in the tags field.

Proposal

Allow target JSON Path expressions to select nodes of all JSON types.

For example allow

overlay: 1.0.0
info:
  title: Remove a string from the tags array of all operations
  version: 1.0.0
actions:
  - target: $.paths.*.*.tags[?@ == 'dummy']
    remove: true

and

overlay: 1.0.0
info:
  title: Preplace a string in the tags array of all operations
  version: 1.0.0
actions:
  - target: $.paths.*.*.tags[?@ == 'Foo']
    update: "Bar"

ralfhandl avatar Sep 11 '24 13:09 ralfhandl

If this is allowed, #70 should be discarded in 2.0

jeremyfiel avatar Oct 08 '24 17:10 jeremyfiel

The current text does not allow directly targeting a primitive value

Yes, IMHO this is the most problematic part of the spec, which prevents to use it seriously. Totally for this change!

char0n avatar Oct 07 '25 12:10 char0n

Removing or updating a primitive value within an array actually works already with both bump-cli and speakeasy, see files array-remove-*.yaml in https://github.com/ralfhandl/overlay-experiments/tree/main/examples.

So it would seem sufficient to "update" the specification 😎

ralfhandl avatar Nov 01 '25 15:11 ralfhandl