@@ -231,6 +231,28 @@ describe('openapi-format CLI overlay tests', () => {
231231 ] ) ;
232232 } ) ;
233233
234+ it ( 'should spread update arrays into array targets' , async ( ) => {
235+ const baseOAS = {
236+ servers : [ { url : 'https://api.example.com' } , { url : 'https://api.backup.example.com' } ]
237+ } ;
238+ const overlaySet = {
239+ actions : [
240+ {
241+ target : '$.servers' ,
242+ update : [ { url : 'https://api.eu.example.com' } , { url : 'https://api.us.example.com' } ]
243+ }
244+ ]
245+ } ;
246+
247+ const result = await openapiOverlay ( baseOAS , { overlaySet} ) ;
248+ expect ( result . data . servers ) . toEqual ( [
249+ { url : 'https://api.example.com' } ,
250+ { url : 'https://api.backup.example.com' } ,
251+ { url : 'https://api.eu.example.com' } ,
252+ { url : 'https://api.us.example.com' }
253+ ] ) ;
254+ } ) ;
255+
234256 it ( 'should replace primitive values when using update' , async ( ) => {
235257 const baseOAS = { info : { title : 'Old title' } } ;
236258 const overlaySet = {
@@ -290,6 +312,23 @@ describe('openapi-format CLI overlay tests', () => {
290312 ] ) ;
291313 } ) ;
292314
315+ it ( 'should spread copied arrays into array targets' , async ( ) => {
316+ const baseOAS = {
317+ servers : [ { url : 'https://api.example.com' } ] ,
318+ serverPool : [ { url : 'https://api.eu.example.com' } , { url : 'https://api.us.example.com' } ]
319+ } ;
320+ const overlaySet = {
321+ actions : [ { target : '$.servers' , copy : true , from : '$.serverPool' } ]
322+ } ;
323+
324+ const result = await openapiOverlay ( baseOAS , { overlaySet} ) ;
325+ expect ( result . data . servers ) . toEqual ( [
326+ { url : 'https://api.example.com' } ,
327+ { url : 'https://api.eu.example.com' } ,
328+ { url : 'https://api.us.example.com' }
329+ ] ) ;
330+ } ) ;
331+
293332 it ( 'should replace primitive targets when copying primitive values' , async ( ) => {
294333 const baseOAS = {
295334 info : { title : 'Old title' , description : 'New title' }
0 commit comments