File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -230,7 +230,15 @@ export class SchemaPreprocessor<
230230
231231 // Resolve reference object in parent, then process again with resolved schema
232232 // As every object (aka schema) is 'pass-by-reference', this will update the actual apiDoc.
233- parent . object [ node . path [ - 1 ] ] = resolvedObject ;
233+ const lastPathComponent = node . path [ node . path . length - 1 ] ;
234+ if ( isInteger ( lastPathComponent ) ) {
235+ const arrayName = node . path [ node . path . length - 2 ] ;
236+ const index = parseInt ( lastPathComponent ) ;
237+ parent . object [ arrayName ] [ index ] = resolvedObject ;
238+ } else {
239+ parent . object [ lastPathComponent ] = resolvedObject ;
240+ }
241+
234242 node . object = resolvedObject ;
235243
236244 return traverse ( parent , node as VisitorNode < NodeType > , state ) ;
@@ -968,3 +976,7 @@ function findKeys(
968976function getKeyFromRef ( ref : string ) {
969977 return ref . split ( '/components/schemas/' ) [ 1 ] ;
970978}
979+
980+ function isInteger ( str : string ) : boolean {
981+ return / ^ \d + $ / . test ( str ) ;
982+ }
You can’t perform that action at this time.
0 commit comments