File tree Expand file tree Collapse file tree 1 file changed +35
-27
lines changed Expand file tree Collapse file tree 1 file changed +35
-27
lines changed Original file line number Diff line number Diff line change @@ -287,8 +287,12 @@ export function toOpenAPISchema(
287287 const excludePaths = Array . isArray ( exclude ?. paths )
288288 ? exclude . paths
289289 : typeof exclude ?. paths !== 'undefined'
290- ? [ exclude . paths ]
291- : [ ]
290+ ? [ exclude . paths ]
291+ : [ ]
292+
293+ const excludeMethods = exclude ?. methods ?. map ( ( method ) =>
294+ method . toLowerCase ( )
295+ ) ?? [ 'options' ]
292296
293297 const paths : OpenAPIV3 . PathsObject = Object . create ( null )
294298 // @ts -ignore
@@ -314,7 +318,11 @@ export function toOpenAPISchema(
314318
315319 if (
316320 ( excludeStaticFile && route . path . includes ( '.' ) ) ||
317- excludePaths . includes ( route . path ) ||
321+ excludePaths . some ( ( excludedPath ) =>
322+ excludedPath instanceof RegExp
323+ ? excludedPath . test ( route . path )
324+ : excludedPath === route . path
325+ ) ||
318326 excludeMethods . includes ( method )
319327 )
320328 continue
@@ -553,7 +561,7 @@ export function toOpenAPISchema(
553561 'text/plain' : {
554562 schema : body
555563 }
556- }
564+ }
557565 : {
558566 'application/json' : {
559567 schema : body
@@ -564,7 +572,7 @@ export function toOpenAPISchema(
564572 'multipart/form-data' : {
565573 schema : body
566574 }
567- }
575+ }
568576 }
569577 }
570578 }
@@ -599,19 +607,19 @@ export function toOpenAPISchema(
599607 type === 'undefined'
600608 ? ( { type, description } as any )
601609 : type === 'string' ||
602- type === 'number' ||
603- type === 'integer' ||
604- type === 'boolean'
605- ? {
606- 'text/plain' : {
607- schema : response
608- }
610+ type === 'number' ||
611+ type === 'integer' ||
612+ type === 'boolean'
613+ ? {
614+ 'text/plain' : {
615+ schema : response
609616 }
610- : {
611- 'application/json' : {
612- schema : response
613- }
617+ }
618+ : {
619+ 'application/json' : {
620+ schema : response
614621 }
622+ }
615623 }
616624 }
617625 } else {
@@ -635,19 +643,19 @@ export function toOpenAPISchema(
635643 type === 'undefined'
636644 ? ( { type, description } as any )
637645 : type === 'string' ||
638- type === 'number' ||
639- type === 'integer' ||
640- type === 'boolean'
641- ? {
642- 'text/plain' : {
643- schema : response
644- }
646+ type === 'number' ||
647+ type === 'integer' ||
648+ type === 'boolean'
649+ ? {
650+ 'text/plain' : {
651+ schema : response
645652 }
646- : {
647- 'application/json' : {
648- schema : response
649- }
653+ }
654+ : {
655+ 'application/json' : {
656+ schema : response
650657 }
658+ }
651659 }
652660 }
653661 }
You can’t perform that action at this time.
0 commit comments