use of org.apache.tapestry5.annotations.StaticActivationContextValue in project tapestry-5 by apache.
the class BaseRestDemoPage method superclassEndpoint.
@OnEvent(EventConstants.HTTP_GET)
public Object superclassEndpoint(@StaticActivationContextValue("superclassEndpoint") String pathParameter) {
final JSONArray jsonArray = new JSONArray();
jsonArray.add(pathParameter);
return jsonArray;
}
use of org.apache.tapestry5.annotations.StaticActivationContextValue in project tapestry-5 by apache.
the class DefaultOpenApiDescriptionGenerator method getPath.
private String getPath(Method method, Class<?> pageClass) {
final StringBuilder builder = new StringBuilder();
builder.append(pageRenderLinkSource.createPageRenderLink(pageClass).toString());
for (Parameter parameter : method.getParameters()) {
if (!isIgnored(parameter)) {
builder.append("/");
final StaticActivationContextValue staticValue = parameter.getAnnotation(StaticActivationContextValue.class);
if (staticValue != null) {
builder.append(staticValue.value());
} else {
builder.append("{");
builder.append(getParameterName(parameter));
builder.append("}");
}
}
}
String path = builder.toString();
if (!path.startsWith(basePath)) {
throw new RuntimeException(String.format("Method %s has path %s, which " + "doesn't start with base path %s. It's likely you need to adjust the " + "base path and/or the endpoint paths", method, path, basePath));
} else {
// keep the slash
path = path.substring(basePath.length() - 1);
// remove possible double slashes
path = path.replace("//", "/");
}
return path;
}
use of org.apache.tapestry5.annotations.StaticActivationContextValue in project tapestry-5 by apache.
the class Index method getExample.
@RestInfo(returnType = User.class, produces = "application/json")
@OnEvent(EventConstants.HTTP_GET)
public User getExample(@StaticActivationContextValue("example") String example) {
User user = new User();
user.setEmail("fulano@fulano.com");
user.setName("Fulano da Silva");
user.getAttributes().add(new Attribute("favoriteColor", "blue"));
return user;
}
Aggregations