-
Notifications
You must be signed in to change notification settings - Fork 8
Open
Description
Description
When using bump overlay to apply an overlay that adds new properties to a schema, enum arrays from nested properties are incorrectly appended to existing enum arrays at different paths, resulting in duplicate values.
Environment
- bump-cli version: 2.9.8
- Node.js version: 24.x
Steps to Reproduce
- Have an OpenAPI spec with a property containing an enum:
# base-spec.yaml
paths:
/items/{id}:
put:
requestBody:
content:
application/json:
schema:
type: object
properties:
method:
type: string
enum: [GET, POST, PUT, DELETE]- Apply an overlay that adds a nested object with a property of the same name:
# overlay.yaml
overlay: 1.0.0
actions:
- target: $.paths['/items/{id}'].put.requestBody.content['application/json'].schema.properties
update:
request:
type: object
properties:
method:
type: string
enum: [GET, POST, PUT, DELETE]- Run:
bump overlay base-spec.yaml overlay.yaml
Expected Behavior
The top-level method.enum should remain unchanged with 4 values:
method:
enum: [GET, POST, PUT, DELETE]And a new request.properties.method.enum should be added with 4 values.
Actual Behavior
The top-level method.enum is incorrectly modified to have 8 values (duplicated):
method:
enum: [GET, POST, PUT, DELETE, GET, POST, PUT, DELETE]Root Cause
In src/core/overlay.ts, the update method uses mergician with appendArrays: true:
const merger = mergician({ appendArrays: true });This causes arrays to be concatenated during deep merge. When the overlay adds a nested property with the same name (method) containing an enum array, mergician appears to find and concatenate enum arrays from different schema paths.
Suggested Fix
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels