File tree 1 file changed +5
-4
lines changed
src/Symfony/Bundle/SwaggerUi
1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change 13
13
14
14
namespace ApiPlatform \Symfony \Bundle \SwaggerUi ;
15
15
16
- use ApiPlatform \Exception \RuntimeException ;
17
16
use ApiPlatform \Metadata \Resource \Factory \ResourceMetadataCollectionFactoryInterface ;
18
17
use ApiPlatform \OpenApi \Factory \OpenApiFactoryInterface ;
19
18
use ApiPlatform \OpenApi \Options ;
@@ -94,13 +93,15 @@ public function __invoke(Request $request): Response
94
93
$ swaggerData ['shortName ' ] = $ metadata ->getShortName ();
95
94
$ swaggerData ['operationId ' ] = $ this ->normalizeOperationName ($ metadata ->getName ());
96
95
97
- [$ swaggerData ['path ' ], $ swaggerData ['method ' ]] = $ this ->getPathAndMethod ($ swaggerData );
96
+ if ($ data = $ this ->getPathAndMethod ($ swaggerData )) {
97
+ [$ swaggerData ['path ' ], $ swaggerData ['method ' ]] = $ data ;
98
+ }
98
99
}
99
100
100
101
return new Response ($ this ->twig ->render ('@ApiPlatform/SwaggerUi/index.html.twig ' , $ swaggerContext + ['swagger_data ' => $ swaggerData ]));
101
102
}
102
103
103
- private function getPathAndMethod (array $ swaggerData ): array
104
+ private function getPathAndMethod (array $ swaggerData ): ? array
104
105
{
105
106
foreach ($ swaggerData ['spec ' ]['paths ' ] as $ path => $ operations ) {
106
107
foreach ($ operations as $ method => $ operation ) {
@@ -110,6 +111,6 @@ private function getPathAndMethod(array $swaggerData): array
110
111
}
111
112
}
112
113
113
- throw new RuntimeException ( sprintf ( ' The operation "%s" cannot be found in the Swagger specification. ' , $ swaggerData [ ' operationId ' ])) ;
114
+ return null ;
114
115
}
115
116
}
You can’t perform that action at this time.
0 commit comments