Skip to content

Commit ee0ab2d

Browse files
committed
Improve reader so it scans up in the hierarchy for @ApplicationPath annotation in order to work properly with Weld proxies.
1 parent d489adb commit ee0ab2d

File tree

1 file changed

+7
-1
lines changed
  • modules/swagger-jaxrs2/src/main/java/io/swagger/v3/jaxrs2

1 file changed

+7
-1
lines changed

modules/swagger-jaxrs2/src/main/java/io/swagger/v3/jaxrs2/Reader.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,13 @@ public OpenAPI read(Set<Class<?>> classes, Map<String, Object> resources) {
198198

199199
protected String resolveApplicationPath() {
200200
if (application != null) {
201-
ApplicationPath applicationPath = application.getClass().getAnnotation(ApplicationPath.class);
201+
Class<?> applicationToScan = this.application.getClass();
202+
ApplicationPath applicationPath;
203+
//search up in the hierarchy until we find one with the annotation, this is needed because for example Weld proxies will not have the annotation and the right class will be the superClass
204+
while ((applicationPath = applicationToScan.getAnnotation(ApplicationPath.class)) == null && !applicationToScan.getSuperclass().equals(Application.class)) {
205+
applicationToScan = applicationToScan.getSuperclass();
206+
}
207+
202208
if (applicationPath != null) {
203209
if (StringUtils.isNotBlank(applicationPath.value())) {
204210
return applicationPath.value();

0 commit comments

Comments
 (0)