@@ -130,6 +130,7 @@ async function generatePaths<
130130> ( hono : Hono < E , S , P > , ctx : SpecContext ) : Promise < OpenAPIV3_1 . PathsObject > {
131131 const paths : OpenAPIV3_1 . PathsObject = { } ;
132132
133+ const promises : Promise < void > [ ] = [ ] ;
133134 for ( const route of hono . routes ) {
134135 const middlewareHandler = route . handler [ uniqueSymbol ] as
135136 | HandlerUniqueProperty
@@ -166,20 +167,23 @@ async function generatePaths<
166167 const defaultOptionsForThisMethod =
167168 ctx . options . defaultOptions ?. [ routeMethod ] ;
168169
169- const { schema : routeSpecs , components = { } } = await getSpec (
170- middlewareHandler ,
171- defaultOptionsForThisMethod ,
172- ) ;
173-
174- ctx . components = mergeComponentsObjects ( ctx . components , components ) ;
170+ promises . push (
171+ getSpec ( middlewareHandler , defaultOptionsForThisMethod ) . then (
172+ ( { schema : routeSpecs , components = { } } ) => {
173+ ctx . components = mergeComponentsObjects ( ctx . components , components ) ;
175174
176- registerSchemaPath ( {
177- route,
178- specs : routeSpecs ,
179- paths,
180- } ) ;
175+ registerSchemaPath ( {
176+ route,
177+ specs : routeSpecs ,
178+ paths,
179+ } ) ;
180+ } ,
181+ ) ,
182+ ) ;
181183 }
182184
185+ await Promise . all ( promises ) ;
186+
183187 return paths ;
184188}
185189
@@ -235,7 +239,10 @@ async function getSpec(
235239 const result = await raw . schema . toOpenAPISchema ( ) ;
236240 raw . schema = result . schema ;
237241 if ( result . components ) {
238- components = mergeComponentsObjects ( components , result . components ) ;
242+ components = mergeComponentsObjects (
243+ components ,
244+ result . components ,
245+ ) ;
239246 }
240247 }
241248 }
0 commit comments