@@ -80,24 +80,30 @@ function getRef({ $ref: ref }) {
8080 return { $ref : prepareReferenceName ( ref ) } ;
8181 }
8282
83- const path = relativePath . split ( '/' ) ;
83+ let path = relativePath . split ( '/' ) ;
8484 if ( path [ 0 ] === 'definitions' ) {
8585 if ( path [ 2 ] === 'schemas' ) {
8686 return { $ref : `${ pathToFile } #/components/schemas/${ path . slice ( 4 ) . join ( '/' ) } ` } ;
8787 }
88+
89+ path = [ '' , ...path ] ;
8890 }
8991
9092 const schemaIndex = path . indexOf ( 'schema' ) ;
9193 const schemaPath = schemaIndex === - 1 ? [ ] : path . slice ( schemaIndex ) ;
92- const pathWithoutSlashes = path . slice ( 0 , schemaIndex ) . filter ( item => item !== 'properties' ) ;
94+ const pathWithoutProperties = path . slice ( 0 , schemaIndex ) . filter ( item => item !== 'properties' ) ;
95+ const bucketWithRequest = ( path [ 1 ] === 'definitions' ) ? path [ 1 ] : pathWithoutProperties . slice ( 0 , 2 ) ;
96+
97+ if ( pathWithoutProperties [ 3 ] !== 'response' ) {
98+ if ( pathWithoutProperties [ 2 ] !== 'requestBody' ) {
99+ return { $ref : `${ pathToFile } #/paths/${ [ ...pathWithoutProperties , ...schemaPath ] . join ( '/' ) } ` } ;
100+ }
93101
94- if ( pathWithoutSlashes [ 3 ] !== 'response' ) {
95- return { $ref : `${ pathToFile } #/paths/${ [ ...pathWithoutSlashes , ...schemaPath ] . join ( '/' ) } ` } ;
102+ return { $ref : `${ pathToFile } #/paths/${ [ ...bucketWithRequest , 'requestBody' , 'content' , ...pathWithoutProperties . slice ( 3 ) , ...schemaPath ] . join ( '/' ) } ` } ;
96103 }
97104
98- const bucketWithRequest = pathWithoutSlashes . slice ( 0 , 2 ) ;
99- const response = pathWithoutSlashes [ 2 ] ;
100- const pathToItem = pathWithoutSlashes . slice ( 4 )
105+ const response = pathWithoutProperties [ 2 ] ;
106+ const pathToItem = pathWithoutProperties . slice ( 4 )
101107
102108 const pathWithResponses = [ ...bucketWithRequest , 'responses' , response , ...pathToItem , ...schemaPath ] ;
103109
0 commit comments