mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
actually use the resource class
This commit is contained in:
@@ -3,6 +3,7 @@ package com.commafeed.frontend.rest.resources;
|
|||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
import javax.annotation.PostConstruct;
|
||||||
|
import javax.annotation.Resource;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.interceptor.AroundInvoke;
|
import javax.interceptor.AroundInvoke;
|
||||||
import javax.interceptor.InvocationContext;
|
import javax.interceptor.InvocationContext;
|
||||||
@@ -182,28 +183,29 @@ public abstract class AbstractREST {
|
|||||||
String basePath = ApiListingResource
|
String basePath = ApiListingResource
|
||||||
.getBasePath(applicationSettingsService.get().getPublicUrl());
|
.getBasePath(applicationSettingsService.get().getPublicUrl());
|
||||||
|
|
||||||
Api api = null;
|
Class<?> resource = null;
|
||||||
String path = prependSlash(uriInfo.getPath());
|
String path = prependSlash(uriInfo.getPath());
|
||||||
for (Class<?> klass : app.getClasses()) {
|
for (Class<?> klass : app.getClasses()) {
|
||||||
Api a = klass.getAnnotation(Api.class);
|
Api api = klass.getAnnotation(Api.class);
|
||||||
if (a != null && a.value() != null
|
if (api != null && api.value() != null
|
||||||
&& StringUtils.equals(prependSlash(a.value()), path)) {
|
&& StringUtils.equals(prependSlash(api.value()), path)) {
|
||||||
api = a;
|
resource = klass;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (api == null) {
|
if (resource == null) {
|
||||||
return Response
|
return Response
|
||||||
.status(Status.NOT_FOUND)
|
.status(Status.NOT_FOUND)
|
||||||
.entity("Api annotation not found on class "
|
.entity("Api annotation not found on class "
|
||||||
+ getClass().getName()).build();
|
+ getClass().getName()).build();
|
||||||
}
|
}
|
||||||
|
Api api = resource.getAnnotation(Api.class);
|
||||||
String apiPath = api.value();
|
String apiPath = api.value();
|
||||||
String apiListingPath = api.value();
|
String apiListingPath = api.value();
|
||||||
|
|
||||||
Documentation doc = new HelpApi(null).filterDocs(JaxrsApiReader.read(
|
Documentation doc = new HelpApi(null).filterDocs(JaxrsApiReader.read(
|
||||||
getClass(), apiVersion, swaggerVersion, basePath, apiPath),
|
resource, apiVersion, swaggerVersion, basePath, apiPath),
|
||||||
headers, uriInfo, apiListingPath, apiPath);
|
headers, uriInfo, apiListingPath, apiPath);
|
||||||
|
|
||||||
doc.setSwaggerVersion(swaggerVersion);
|
doc.setSwaggerVersion(swaggerVersion);
|
||||||
|
|||||||
Reference in New Issue
Block a user