@@ -128,14 +128,10 @@ void produceCompositeProviders(AuthenticationRecorder recorder, List<AuthProvide
128128 @ BuildStep
129129 @ Record (ExecutionTime .STATIC_INIT )
130130 void produceOauthAuthentication (CombinedIndexBuildItem beanArchiveBuildItem ,
131- BuildProducer <AuthProviderBuildItem > authenticationProviders , BuildProducer <SyntheticBeanBuildItem > beanProducer ,
131+ BuildProducer <AuthProviderBuildItem > authenticationProviders ,
132+ BuildProducer <SyntheticBeanBuildItem > beanProducer ,
132133 OidcAuthenticationRecorder oidcRecorder ) {
133134
134- if (!isClassPresentAtRuntime (ABSTRACT_TOKEN_PRODUCER )) {
135- LOGGER .debug ("{} class not found in runtime, skipping OAuth bean generation" , ABSTRACT_TOKEN_PRODUCER );
136- return ;
137- }
138- LOGGER .debug ("{} class found in runtime, producing OAuth bean generation" , ABSTRACT_TOKEN_PRODUCER );
139135 Collection <AnnotationInstance > authenticationMarkers = beanArchiveBuildItem .getIndex ()
140136 .getAnnotationsWithRepeatable (OAUTH_AUTHENTICATION_MARKER , beanArchiveBuildItem .getIndex ())
141137 .stream ()
@@ -145,6 +141,24 @@ void produceOauthAuthentication(CombinedIndexBuildItem beanArchiveBuildItem,
145141 (existing , duplicate ) -> existing ))
146142 .values ();
147143
144+ if (!isClassPresentAtRuntime (ABSTRACT_TOKEN_PRODUCER )) {
145+ if (!authenticationMarkers .isEmpty ()) {
146+ throw new IllegalStateException (
147+ "OAuth2 flows detected in spec(s) " +
148+ authenticationMarkers .stream ()
149+ .map (m -> m .value ("openApiSpecId" ).asString ())
150+ .distinct ()
151+ .collect (Collectors .joining (", " ))
152+ +
153+ " but quarkus-openapi-generator-oidc and quarkus-rest-client-oidc-filter or quarkus-oidc-client-reactive-filter are not on the classpath. "
154+ +
155+ "Please add those dependencies to your project. See https://docs.quarkiverse.io/quarkus-openapi-generator/dev/client.html#_oauth2_authentication" );
156+ }
157+ LOGGER .debug ("{} class not found in runtime, skipping OAuth bean generation" , ABSTRACT_TOKEN_PRODUCER );
158+ return ;
159+ }
160+ LOGGER .debug ("{} class found in runtime, producing OAuth bean generation" , ABSTRACT_TOKEN_PRODUCER );
161+
148162 Map <String , List <AnnotationInstance >> operationsBySpec = getOperationsBySpec (beanArchiveBuildItem );
149163
150164 for (AnnotationInstance authenticationMarker : authenticationMarkers ) {
0 commit comments