(_typeRecursionDetector);
@@ -736,7 +796,7 @@ public JsonType visitUnknown(TypeMirror typeMirror, Void o) {
public interface RestImplementationSupport {
Class extends Annotation> getMappingAnnotationType();
- String[] getRequestPaths(ExecutableElement executableElement, TypeElement contextClass);
+ String[] getRequestPaths(ExecutableElement executableElement, TypeElement contextClass);
String[] getRequestPaths(TypeElement cls);
diff --git a/src/main/java/org/versly/rest/wsdoc/impl/JavaEEWebsocketImplementationSupport.java b/src/main/java/org/versly/rest/wsdoc/impl/JavaEEWebsocketImplementationSupport.java
new file mode 100644
index 0000000..85d70c5
--- /dev/null
+++ b/src/main/java/org/versly/rest/wsdoc/impl/JavaEEWebsocketImplementationSupport.java
@@ -0,0 +1,87 @@
+package org.versly.rest.wsdoc.impl;
+
+import java.lang.annotation.Annotation;
+
+import javax.lang.model.element.ExecutableElement;
+import javax.lang.model.element.TypeElement;
+import javax.lang.model.element.VariableElement;
+import javax.websocket.server.ServerEndpoint;
+
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.versly.rest.wsdoc.AnnotationProcessor;
+
+public class JavaEEWebsocketImplementationSupport implements AnnotationProcessor.RestImplementationSupport {
+
+ @Override
+ public Class extends Annotation> getMappingAnnotationType() {
+ return RequestMapping.class;
+ }
+
+ @Override
+ public String[] getRequestPaths(ExecutableElement executableElement, TypeElement contextClass) {
+ return new String[0];
+ }
+
+ @Override
+ public String[] getRequestPaths(TypeElement cls) {
+ ServerEndpoint clsAnno = cls.getAnnotation(ServerEndpoint.class);
+ return requestPathsForAnnotation(clsAnno);
+ }
+
+ private String[] requestPathsForAnnotation(ServerEndpoint clsAnno) {
+ if (clsAnno == null)
+ return new String[0];
+ else
+ return new String[]{ clsAnno.value() };
+ }
+
+ @Override
+ public String getRequestMethod(ExecutableElement executableElement, TypeElement contextClass) {
+ return "GET";
+ }
+
+ @Override
+ public String getPathVariable(VariableElement var) {
+ PathVariable pathVar = var.getAnnotation(PathVariable.class);
+ return pathVar == null ? null : pathVar.value();
+ }
+
+ @Override
+ public String getRequestParam(VariableElement var) {
+ RequestParam reqParam = var.getAnnotation(RequestParam.class);
+ return reqParam == null ? null : reqParam.value();
+ }
+
+ /**
+ * Return whether this variable is an un-annotated POJO.
+ * This catches the case where a model is bound to directly. We explicitly exclude spring classes so that we don't look at the
+ * magical spring bound parameters like Errors or ModelMap
+ */
+ @Override
+ public String getPojoRequestParam(VariableElement var) {
+ if (getRequestParam(var) == null && getPathVariable(var) == null && !ignorePojo(var)) {
+ return ""; // No annotations to parse
+ } else {
+ return null;
+ }
+
+ }
+
+ private boolean ignorePojo(VariableElement var)
+ {
+ // Atmosphere Types
+ if(var.asType().toString().startsWith("org.atmosphere"))
+ {
+ return true;
+ }
+
+ return false;
+ }
+
+ @Override
+ public boolean isRequestBody(VariableElement var) {
+ return !var.asType().toString().equalsIgnoreCase("javax.websocket.Session");
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/org/versly/rest/wsdoc/impl/JaxRSRestImplementationSupport.java b/src/main/java/org/versly/rest/wsdoc/impl/JaxRSRestImplementationSupport.java
index ab1fcd8..4a1217b 100644
--- a/src/main/java/org/versly/rest/wsdoc/impl/JaxRSRestImplementationSupport.java
+++ b/src/main/java/org/versly/rest/wsdoc/impl/JaxRSRestImplementationSupport.java
@@ -4,6 +4,8 @@
import java.lang.annotation.Annotation;
import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
import java.util.List;
import javax.lang.model.element.ExecutableElement;
diff --git a/src/main/java/org/versly/rest/wsdoc/impl/RestDocumentation.java b/src/main/java/org/versly/rest/wsdoc/impl/RestDocumentation.java
index 3982cbd..be7c240 100644
--- a/src/main/java/org/versly/rest/wsdoc/impl/RestDocumentation.java
+++ b/src/main/java/org/versly/rest/wsdoc/impl/RestDocumentation.java
@@ -286,6 +286,7 @@ public class Method implements Serializable {
private JsonType _responseBody;
private String _commentText;
private boolean _isMultipartRequest;
+ private boolean _isWebsocket;
private String _requestSchema;
private String _responseSchema;
private String _responseExample;
@@ -453,6 +454,14 @@ public boolean isMultipartRequest() {
public void setMultipartRequest(boolean multipart) {
_isMultipartRequest = multipart;
}
+
+ public boolean isWebsocket() {
+ return _isWebsocket;
+ }
+
+ public void setWebsocket(boolean websocket) {
+ _isWebsocket = websocket;
+ }
/**
* An HTML-safe, textual key that uniquely identifies this endpoint.
diff --git a/src/main/java/org/versly/rest/wsdoc/impl/SpringMVCRestImplementationSupport.java b/src/main/java/org/versly/rest/wsdoc/impl/SpringMVCRestImplementationSupport.java
index eda410d..5400a9c 100644
--- a/src/main/java/org/versly/rest/wsdoc/impl/SpringMVCRestImplementationSupport.java
+++ b/src/main/java/org/versly/rest/wsdoc/impl/SpringMVCRestImplementationSupport.java
@@ -1,16 +1,19 @@
package org.versly.rest.wsdoc.impl;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.versly.rest.wsdoc.AnnotationProcessor;
-
import java.lang.annotation.Annotation;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
import javax.lang.model.element.ExecutableElement;
import javax.lang.model.element.TypeElement;
import javax.lang.model.element.VariableElement;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.versly.rest.wsdoc.AnnotationProcessor;
+
public class SpringMVCRestImplementationSupport implements AnnotationProcessor.RestImplementationSupport {
@Override
@@ -67,13 +70,30 @@ public String getRequestParam(VariableElement var) {
*/
@Override
public String getPojoRequestParam(VariableElement var) {
- if (getRequestParam(var) == null && getPathVariable(var) == null && !var.asType().toString().startsWith("org.springframework")) {
+ if (getRequestParam(var) == null && getPathVariable(var) == null && !ignorePojo(var)) {
return ""; // No annotations to parse
} else {
return null;
}
}
+
+ private boolean ignorePojo(VariableElement var)
+ {
+ // Spring Types
+ if(var.asType().toString().startsWith("org.springframework"))
+ {
+ return true;
+ }
+
+ // Atmosphere Types
+ if(var.asType().toString().startsWith("org.atmosphere"))
+ {
+ return true;
+ }
+
+ return false;
+ }
@Override
diff --git a/src/main/resources/org/versly/rest/wsdoc/RestDocumentation.ftl b/src/main/resources/org/versly/rest/wsdoc/RestDocumentation.ftl
index 4ab98f7..3c5504e 100644
--- a/src/main/resources/org/versly/rest/wsdoc/RestDocumentation.ftl
+++ b/src/main/resources/org/versly/rest/wsdoc/RestDocumentation.ftl
@@ -90,6 +90,12 @@
Note: this endpoint expects a multipart request body.
#if>
+
+ <#if methodDoc.websocket>
+
+ Note: this is a websocket endpoint.
+
+ #if>
<#assign subs=methodDoc.urlSubstitutions.fields>
<#if (subs?keys?size > 0)>