@@ -396,12 +396,35 @@ function findUsedSchemas(openApiSpec) {
396396 const schemasToProcess = [ ] ;
397397 const schemas = openApiSpec . components ?. schemas || { } ;
398398 const responses = openApiSpec . components ?. responses || { } ;
399+ const requestBodies = openApiSpec . components ?. requestBodies || { } ;
399400 const paths = openApiSpec . paths || { } ;
400401
401402 Object . entries ( paths ) . forEach ( ( [ , pathItem ] ) => {
402403 Object . entries ( pathItem ) . forEach ( ( [ , operation ] ) => {
403404 if ( typeof operation !== 'object' ) return ;
404405
406+ if ( operation . requestBody ?. $ref ) {
407+ const requestBodyName = operation . requestBody . $ref . replace (
408+ '#/components/requestBodies/' ,
409+ ''
410+ ) ;
411+ const requestBodyDefinition = requestBodies [ requestBodyName ] ;
412+ if ( requestBodyDefinition ?. content ) {
413+ Object . values ( requestBodyDefinition . content ) . forEach ( ( content ) => {
414+ if ( content . schema ?. $ref ) {
415+ const schemaName = content . schema . $ref . replace ( '#/components/schemas/' , '' ) ;
416+ schemasToProcess . push ( schemaName ) ;
417+ }
418+ if ( content . schema ?. properties ) {
419+ findRefsInObject ( content . schema . properties , ( ref ) => {
420+ const schemaName = ref . replace ( '#/components/schemas/' , '' ) ;
421+ schemasToProcess . push ( schemaName ) ;
422+ } ) ;
423+ }
424+ } ) ;
425+ }
426+ }
427+
405428 if ( operation . requestBody ?. content ) {
406429 Object . values ( operation . requestBody . content ) . forEach ( ( content ) => {
407430 if ( content . schema ?. $ref ) {
0 commit comments