You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2015/05/19 09:44:28 UTC
[1/2] camel git commit: resolving rest todos
Repository: camel
Updated Branches:
refs/heads/master 5fca7ac4d -> 69abfd77a
resolving rest todos
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/b3efc44e
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/b3efc44e
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/b3efc44e
Branch: refs/heads/master
Commit: b3efc44ef9059b14c16942c92cfad051a2c67547
Parents: 5fca7ac
Author: sebi <se...@softvision.ro>
Authored: Tue May 19 09:23:03 2015 +0300
Committer: Claus Ibsen <da...@apache.org>
Committed: Tue May 19 08:57:05 2015 +0200
----------------------------------------------------------------------
.../apache/camel/model/rest/RestDefinition.java | 34 ++-
.../camel/model/rest/RestOperationParam.java | 143 -----------
.../rest/RestOperationParamDefinition.java | 241 +++++++++++++++++++
.../camel/model/rest/RestParamDefinition.java | 94 --------
.../apache/camel/model/rest/VerbDefinition.java | 37 +--
.../component/swagger/RestSwaggerReader.scala | 4 +-
6 files changed, 279 insertions(+), 274 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/b3efc44e/camel-core/src/main/java/org/apache/camel/model/rest/RestDefinition.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/model/rest/RestDefinition.java b/camel-core/src/main/java/org/apache/camel/model/rest/RestDefinition.java
index 385cbdc..f3729d5 100644
--- a/camel-core/src/main/java/org/apache/camel/model/rest/RestDefinition.java
+++ b/camel-core/src/main/java/org/apache/camel/model/rest/RestDefinition.java
@@ -32,6 +32,7 @@ import org.apache.camel.model.OptionalIdentifiedDefinition;
import org.apache.camel.model.RouteDefinition;
import org.apache.camel.model.ToDefinition;
import org.apache.camel.spi.Metadata;
+import org.apache.camel.util.FileUtil;
import org.apache.camel.util.ObjectHelper;
import org.apache.camel.util.URISupport;
@@ -267,12 +268,12 @@ public class RestDefinition extends OptionalIdentifiedDefinition<RestDefinition>
return this;
}
- public RestParamDefinition restParam() {
+ public RestOperationParamDefinition restParam() {
if (getVerbs().isEmpty()) {
throw new IllegalArgumentException("Must add verb first, such as get/post/delete");
}
VerbDefinition verb = getVerbs().get(getVerbs().size() - 1);
- return new RestParamDefinition(verb);
+ return new RestOperationParamDefinition(verb);
}
public RestDefinition produces(String mediaType) {
@@ -540,6 +541,35 @@ public class RestDefinition extends OptionalIdentifiedDefinition<RestDefinition>
from = from + "?" + query;
}
+ String path = getPath();
+ String s1 = FileUtil.stripTrailingSeparator(path);
+ String s2 = FileUtil.stripLeadingSeparator(verb.getUri());
+ String allPath;
+ if (s1 != null && s2 != null) {
+ allPath = s1 + "/" + s2;
+ } else if (path != null) {
+ allPath = path;
+ } else {
+ allPath = verb.getUri();
+ }
+
+ // each {} is a parameter
+ String[] arr = allPath.split("\\/");
+ for (String a : arr) {
+ if (a.startsWith("{") && a.endsWith("}")) {
+ String key = a.substring(1, a.length() - 1);
+ restParam().name(key).type(RestParamType.path).endParam();
+ }
+ }
+
+ if( verb.getType() != null ) {
+ String bodyType = verb.getType();
+ if (bodyType.endsWith("[]")) {
+ bodyType = "List[" + bodyType.substring(0, bodyType.length() - 2) + "]";
+ }
+ restParam().name(RestParamType.body.name()).type(RestParamType.body).dataType(bodyType).endParam();
+ }
+
// the route should be from this rest endpoint
route.fromRest(from);
route.setRestDefinition(this);
http://git-wip-us.apache.org/repos/asf/camel/blob/b3efc44e/camel-core/src/main/java/org/apache/camel/model/rest/RestOperationParam.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/model/rest/RestOperationParam.java b/camel-core/src/main/java/org/apache/camel/model/rest/RestOperationParam.java
deleted file mode 100644
index 1a9c437..0000000
--- a/camel-core/src/main/java/org/apache/camel/model/rest/RestOperationParam.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.model.rest;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlAttribute;
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlElementWrapper;
-import javax.xml.bind.annotation.XmlRootElement;
-
-import org.apache.camel.spi.Metadata;
-
-// TODO: rename to Definition as this is what this is
-// TODO: Do not set default values, but infer those
-// TODO: add javadoc on the setter methods
-// TODO: add @Metadata to define the default values
-// TODO: add required=true if its required (such as name and paramType I would assume)
-
-@Metadata(label = "rest")
-@XmlRootElement(name = "param")
-@XmlAccessorType(XmlAccessType.FIELD)
-public class RestOperationParam {
- @XmlAttribute
- RestParamType paramType = RestParamType.query;
-
- @XmlAttribute
- String name;
-
- @XmlAttribute
- String description = "";
-
- @XmlAttribute
- String defaultValue = "";
-
- @XmlAttribute
- Boolean required = true;
-
- @XmlAttribute
- Boolean allowMultiple = false;
-
- @XmlAttribute
- String dataType = "string";
-
- @XmlElementWrapper(name = "allowableValues")
- @XmlElement(name = "value")
- List<String> allowableValues = new ArrayList<String>();
-
- @XmlAttribute
- String paramAccess;
-
- public RestOperationParam() {
- }
-
- public RestParamType getParamType() {
- return paramType;
- }
-
- public void setParamType(RestParamType paramType) {
- this.paramType = paramType;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getDescription() {
- return description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public String getDefaultValue() {
- return defaultValue;
- }
-
- public void setDefaultValue(String defaultValue) {
- this.defaultValue = defaultValue;
- }
-
- public Boolean getRequired() {
- return required;
- }
-
- public void setRequired(Boolean required) {
- this.required = required;
- }
-
- public Boolean getAllowMultiple() {
- return allowMultiple;
- }
-
- public void setAllowMultiple(Boolean allowMultiple) {
- this.allowMultiple = allowMultiple;
- }
-
- public String getDataType() {
- return dataType;
- }
-
- public void setDataType(String dataType) {
- this.dataType = dataType;
- }
-
- public List<String> getAllowableValues() {
- return allowableValues;
- }
-
- public void setAllowableValues(List<String> allowableValues) {
- this.allowableValues = allowableValues;
- }
-
- public String getParamAccess() {
- return paramAccess;
- }
-
- public void setParamAccess(String paramAccess) {
- this.paramAccess = paramAccess;
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/b3efc44e/camel-core/src/main/java/org/apache/camel/model/rest/RestOperationParamDefinition.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/model/rest/RestOperationParamDefinition.java b/camel-core/src/main/java/org/apache/camel/model/rest/RestOperationParamDefinition.java
new file mode 100644
index 0000000..ee2edf5
--- /dev/null
+++ b/camel-core/src/main/java/org/apache/camel/model/rest/RestOperationParamDefinition.java
@@ -0,0 +1,241 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.model.rest;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlElementWrapper;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlTransient;
+
+
+import org.apache.camel.spi.Metadata;
+
+/**
+ * This maps to the Swagger Parameter Object.
+ * see com.wordnik.swagger.model.Parameter
+ * and https://github.com/swagger-api/swagger-spec/blob/master/versions/1.2.md#524-parameter-object.
+ */
+@Metadata(label = "rest")
+@XmlRootElement(name = "param")
+@XmlAccessorType(XmlAccessType.FIELD)
+public class RestOperationParamDefinition {
+
+ @XmlTransient
+ private VerbDefinition verb;
+
+ @XmlAttribute
+ @Metadata(required = "true")
+ RestParamType paramType;
+
+ @XmlAttribute
+ @Metadata(required = "true")
+ String name;
+
+ @XmlAttribute
+ String description = "";
+
+ @XmlAttribute
+ String defaultValue = "";
+
+ @XmlAttribute
+ Boolean required = true;
+
+ @XmlAttribute
+ Boolean allowMultiple = false;
+
+ @XmlAttribute
+ @Metadata(defaultValue = "string")
+ String dataType;
+
+ @XmlElementWrapper(name = "allowableValues")
+ @XmlElement(name = "value")
+ List<String> allowableValues;
+
+ @XmlAttribute
+ String paramAccess;
+
+
+ public RestOperationParamDefinition(VerbDefinition verb) {
+ this.verb = verb;
+ }
+
+ public RestOperationParamDefinition() {
+ }
+
+ public RestParamType getParamType() {
+ if (paramType != null)
+ return paramType;
+ return RestParamType.path;
+ }
+ /**
+ * Sets the Swagger Parameter type.
+ */
+ public void setParamType(RestParamType paramType) {
+ this.paramType = paramType;
+ }
+
+ public String getName() {
+ return name;
+ }
+ /**
+ * Sets the Swagger Parameter name.
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ /**
+ * Sets the Swagger Parameter description.
+ */
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ /**
+ * Sets the Swagger Parameter default value.
+ */
+ public String getDefaultValue() {
+ return defaultValue;
+ }
+
+ public void setDefaultValue(String defaultValue) {
+ this.defaultValue = defaultValue;
+ }
+
+ public Boolean getRequired() {
+ return required;
+ }
+
+ /**
+ * Sets the Swagger Parameter required flag.
+ */
+ public void setRequired(Boolean required) {
+ this.required = required;
+ }
+
+ public Boolean getAllowMultiple() {
+ return allowMultiple;
+ }
+
+ /**
+ * Sets the Swagger Parameter allowMultiple flag.
+ */
+ public void setAllowMultiple(Boolean allowMultiple) {
+ this.allowMultiple = allowMultiple;
+ }
+
+ public String getDataType() {
+ if(dataType!=null) {
+ return dataType;
+ }
+ return "string";
+ }
+
+ /**
+ * Sets the Swagger Parameter data type.
+ */
+ public void setDataType(String dataType) {
+ this.dataType = dataType;
+ }
+
+ public List<String> getAllowableValues() {
+ if (allowableValues != null) {
+ return allowableValues;
+ }
+
+ return new ArrayList<String>();
+ }
+
+ /**
+ * Sets the Swagger Parameter alist of allowable values.
+ */
+ public void setAllowableValues(List<String> allowableValues) {
+ this.allowableValues = allowableValues;
+ }
+
+ public String getParamAccess() {
+ return paramAccess;
+ }
+
+ /**
+ * Sets the Swagger Parameter paramAccess flag.
+ */
+ public void setParamAccess(String paramAccess) {
+ this.paramAccess = paramAccess;
+ }
+
+ public RestOperationParamDefinition name(String name) {
+ setName(name);
+ return this;
+ }
+
+ public RestOperationParamDefinition description(String name) {
+ setDescription(name);
+ return this;
+ }
+
+ public RestOperationParamDefinition defaultValue(String name) {
+ setDefaultValue(name);
+ return this;
+ }
+
+ public RestOperationParamDefinition required(Boolean required) {
+ setRequired(required);
+ return this;
+ }
+
+ public RestOperationParamDefinition allowMultiple(Boolean allowMultiple) {
+ setAllowMultiple(allowMultiple);
+ return this;
+ }
+
+ public RestOperationParamDefinition dataType(String type) {
+ setDataType(type);
+ return this;
+ }
+
+ public RestOperationParamDefinition allowableValues(List<String> allowableValues) {
+ setAllowableValues(allowableValues);
+ return this;
+ }
+
+ public RestOperationParamDefinition type(RestParamType type) {
+ setParamType(type);
+ return this;
+ }
+
+ public RestOperationParamDefinition paramAccess(String paramAccess) {
+ setParamAccess(paramAccess);
+ return this;
+ }
+
+ public RestDefinition endParam() {
+ verb.getParams().add(this);
+ return verb.getRest();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/b3efc44e/camel-core/src/main/java/org/apache/camel/model/rest/RestParamDefinition.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/model/rest/RestParamDefinition.java b/camel-core/src/main/java/org/apache/camel/model/rest/RestParamDefinition.java
deleted file mode 100644
index c9078d6..0000000
--- a/camel-core/src/main/java/org/apache/camel/model/rest/RestParamDefinition.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.model.rest;
-
-import java.util.List;
-
-import javax.xml.bind.annotation.XmlTransient;
-
-import org.apache.camel.model.OptionalIdentifiedDefinition;
-
-// TODO: Should not be a Definition as its a builder for Java DSL instead.
-// instead the builder methods should be on RestOperationParam
-
-@XmlTransient
-public class RestParamDefinition extends OptionalIdentifiedDefinition<RestParamDefinition> {
-
- private RestOperationParam parameter = new RestOperationParam();
- private VerbDefinition verb;
-
- public RestParamDefinition(VerbDefinition verb) {
- this.verb = verb;
- }
-
- @Override
- public String getLabel() {
- return "param";
- }
-
-
- public RestParamDefinition name(String name) {
- parameter.setName(name);
- return this;
- }
-
- public RestParamDefinition description(String name) {
- parameter.setDescription(name);
- return this;
- }
-
- public RestParamDefinition defaultValue(String name) {
- parameter.setDefaultValue(name);
- return this;
- }
-
- public RestParamDefinition required(Boolean required) {
- parameter.setRequired(required);
- return this;
- }
-
- public RestParamDefinition allowMultiple(Boolean allowMultiple) {
- parameter.setAllowMultiple(allowMultiple);
- return this;
- }
-
- public RestParamDefinition dataType(String type) {
- parameter.setDataType(type);
- return this;
- }
-
- public RestParamDefinition allowableValues(List<String> allowableValues) {
- parameter.setAllowableValues(allowableValues);
- return this;
- }
-
- public RestParamDefinition type(RestParamType type) {
- parameter.setParamType(type);
- return this;
- }
-
- public RestParamDefinition paramAccess(String paramAccess) {
- parameter.setParamAccess(paramAccess);
- return this;
- }
-
- public RestDefinition endParam() {
- verb.getParams().add(parameter);
- return verb.getRest();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/b3efc44e/camel-core/src/main/java/org/apache/camel/model/rest/VerbDefinition.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/model/rest/VerbDefinition.java b/camel-core/src/main/java/org/apache/camel/model/rest/VerbDefinition.java
index 56a4d89..45b950f 100644
--- a/camel-core/src/main/java/org/apache/camel/model/rest/VerbDefinition.java
+++ b/camel-core/src/main/java/org/apache/camel/model/rest/VerbDefinition.java
@@ -33,7 +33,6 @@ import org.apache.camel.model.OptionalIdentifiedDefinition;
import org.apache.camel.model.RouteDefinition;
import org.apache.camel.model.ToDefinition;
import org.apache.camel.spi.Metadata;
-import org.apache.camel.util.FileUtil;
/**
* Rest command
@@ -47,7 +46,7 @@ public class VerbDefinition extends OptionalIdentifiedDefinition<VerbDefinition>
private String method;
@XmlElementRef
- private List<RestOperationParam> params = new ArrayList<RestOperationParam>();
+ private List<RestOperationParamDefinition> params = new ArrayList<RestOperationParamDefinition>();
@XmlAttribute
private String uri;
@@ -99,7 +98,7 @@ public class VerbDefinition extends OptionalIdentifiedDefinition<VerbDefinition>
}
}
- public List<RestOperationParam> getParams() {
+ public List<RestOperationParamDefinition> getParams() {
return params;
}
@@ -123,31 +122,6 @@ public class VerbDefinition extends OptionalIdentifiedDefinition<VerbDefinition>
*/
public void setUri(String uri) {
this.uri = uri;
- String path = this.rest.getPath();
-
- // TODO: The setter should be a plain setter.
- // this logic should be moved to
- // org.apache.camel.model.rest.RestDefinition.asRouteDefinition()
-
- String s1 = FileUtil.stripTrailingSeparator(path);
- String s2 = FileUtil.stripLeadingSeparator(uri);
- String allPath;
- if (s1 != null && s2 != null) {
- allPath = s1 + "/" + s2;
- } else if (path != null) {
- allPath = path;
- } else {
- allPath = uri;
- }
-
- // each {} is a parameter
- String[] arr = allPath.split("\\/");
- for (String a : arr) {
- if (a.startsWith("{") && a.endsWith("}")) {
- String key = a.substring(1, a.length() - 1);
- rest.restParam().name(key).type(RestParamType.path).endParam();
- }
- }
}
public String getConsumes() {
@@ -225,11 +199,6 @@ public class VerbDefinition extends OptionalIdentifiedDefinition<VerbDefinition>
*/
public void setType(String type) {
this.type = type;
- String bodyType = type;
- if (type.endsWith("[]")) {
- bodyType = "List[" + bodyType.substring(0, type.length() - 2) + "]";
- }
- rest.restParam().name("body").type(RestParamType.body).dataType(bodyType).endParam();
}
public String getOutType() {
@@ -362,4 +331,6 @@ public class VerbDefinition extends OptionalIdentifiedDefinition<VerbDefinition>
}
}
+
+
}
http://git-wip-us.apache.org/repos/asf/camel/blob/b3efc44e/components/camel-swagger/src/main/scala/org/apache/camel/component/swagger/RestSwaggerReader.scala
----------------------------------------------------------------------
diff --git a/components/camel-swagger/src/main/scala/org/apache/camel/component/swagger/RestSwaggerReader.scala b/components/camel-swagger/src/main/scala/org/apache/camel/component/swagger/RestSwaggerReader.scala
index 33a801a..88d3eea 100644
--- a/components/camel-swagger/src/main/scala/org/apache/camel/component/swagger/RestSwaggerReader.scala
+++ b/components/camel-swagger/src/main/scala/org/apache/camel/component/swagger/RestSwaggerReader.scala
@@ -23,7 +23,7 @@ import com.wordnik.swagger.model._
import com.wordnik.swagger.core.util.ModelUtil
import com.wordnik.swagger.core.SwaggerSpec
-import org.apache.camel.model.rest.{RestOperationParam, VerbDefinition, RestDefinition}
+import org.apache.camel.model.rest.{RestOperationParamDefinition, VerbDefinition, RestDefinition}
import org.apache.camel.util.FileUtil
import org.slf4j.LoggerFactory
@@ -176,7 +176,7 @@ class RestSwaggerReader {
def createParameters(verb: VerbDefinition): List[Parameter] = {
val parameters = new ListBuffer[Parameter]
- for (param:RestOperationParam <- verb.getParams.asScala) {
+ for (param:RestOperationParamDefinition <- verb.getParams.asScala) {
var allowValues=AnyAllowableValues
if(!param.getAllowableValues.isEmpty){
[2/2] camel git commit: Fixed rest param rename in jaxb.index
Posted by da...@apache.org.
Fixed rest param rename in jaxb.index
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/69abfd77
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/69abfd77
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/69abfd77
Branch: refs/heads/master
Commit: 69abfd77a2ee36483cf4e664efb503fb6c0cd9aa
Parents: b3efc44
Author: Claus Ibsen <da...@apache.org>
Authored: Tue May 19 09:48:50 2015 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Tue May 19 09:48:50 2015 +0200
----------------------------------------------------------------------
.../rest/RestOperationParamDefinition.java | 44 +++++++++-----------
.../apache/camel/model/rest/RestParamType.java | 3 ++
.../org/apache/camel/model/rest/jaxb.index | 4 +-
3 files changed, 25 insertions(+), 26 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/69abfd77/camel-core/src/main/java/org/apache/camel/model/rest/RestOperationParamDefinition.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/model/rest/RestOperationParamDefinition.java b/camel-core/src/main/java/org/apache/camel/model/rest/RestOperationParamDefinition.java
index ee2edf5..16db9e7 100644
--- a/camel-core/src/main/java/org/apache/camel/model/rest/RestOperationParamDefinition.java
+++ b/camel-core/src/main/java/org/apache/camel/model/rest/RestOperationParamDefinition.java
@@ -18,7 +18,6 @@ package org.apache.camel.model.rest;
import java.util.ArrayList;
import java.util.List;
-
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
@@ -27,10 +26,11 @@ import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
-
import org.apache.camel.spi.Metadata;
/**
+ * To specify the rest operation parameters using Swagger.
+ * <p/>
* This maps to the Swagger Parameter Object.
* see com.wordnik.swagger.model.Parameter
* and https://github.com/swagger-api/swagger-spec/blob/master/versions/1.2.md#524-parameter-object.
@@ -43,37 +43,36 @@ public class RestOperationParamDefinition {
@XmlTransient
private VerbDefinition verb;
- @XmlAttribute
- @Metadata(required = "true")
- RestParamType paramType;
+ @XmlAttribute(required = true)
+ @Metadata(defaultValue = "path")
+ private RestParamType paramType = RestParamType.path;
- @XmlAttribute
- @Metadata(required = "true")
- String name;
+ @XmlAttribute(required = true)
+ private String name;
@XmlAttribute
- String description = "";
+ private String description;
@XmlAttribute
- String defaultValue = "";
+ private String defaultValue;
@XmlAttribute
- Boolean required = true;
+ @Metadata(defaultValue = "true")
+ private Boolean required = true;
@XmlAttribute
- Boolean allowMultiple = false;
+ private Boolean allowMultiple;
@XmlAttribute
@Metadata(defaultValue = "string")
- String dataType;
+ private String dataType;
@XmlElementWrapper(name = "allowableValues")
@XmlElement(name = "value")
- List<String> allowableValues;
+ private List<String> allowableValues;
@XmlAttribute
- String paramAccess;
-
+ private String paramAccess;
public RestOperationParamDefinition(VerbDefinition verb) {
this.verb = verb;
@@ -83,10 +82,9 @@ public class RestOperationParamDefinition {
}
public RestParamType getParamType() {
- if (paramType != null)
- return paramType;
- return RestParamType.path;
+ return paramType;
}
+
/**
* Sets the Swagger Parameter type.
*/
@@ -97,6 +95,7 @@ public class RestOperationParamDefinition {
public String getName() {
return name;
}
+
/**
* Sets the Swagger Parameter name.
*/
@@ -149,10 +148,7 @@ public class RestOperationParamDefinition {
}
public String getDataType() {
- if(dataType!=null) {
- return dataType;
- }
- return "string";
+ return dataType != null ? dataType : "string";
}
/**
@@ -171,7 +167,7 @@ public class RestOperationParamDefinition {
}
/**
- * Sets the Swagger Parameter alist of allowable values.
+ * Sets the Swagger Parameter list of allowable values.
*/
public void setAllowableValues(List<String> allowableValues) {
this.allowableValues = allowableValues;
http://git-wip-us.apache.org/repos/asf/camel/blob/69abfd77/camel-core/src/main/java/org/apache/camel/model/rest/RestParamType.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/model/rest/RestParamType.java b/camel-core/src/main/java/org/apache/camel/model/rest/RestParamType.java
index b857f9f..61da45b 100644
--- a/camel-core/src/main/java/org/apache/camel/model/rest/RestParamType.java
+++ b/camel-core/src/main/java/org/apache/camel/model/rest/RestParamType.java
@@ -21,6 +21,9 @@ import javax.xml.bind.annotation.XmlType;
import org.apache.camel.spi.Metadata;
+/**
+ * Rest parameter types
+ */
@Metadata(label = "rest")
@XmlType
@XmlEnum(String.class)
http://git-wip-us.apache.org/repos/asf/camel/blob/69abfd77/camel-core/src/main/resources/org/apache/camel/model/rest/jaxb.index
----------------------------------------------------------------------
diff --git a/camel-core/src/main/resources/org/apache/camel/model/rest/jaxb.index b/camel-core/src/main/resources/org/apache/camel/model/rest/jaxb.index
index 9ebcd6c..1de414a 100644
--- a/camel-core/src/main/resources/org/apache/camel/model/rest/jaxb.index
+++ b/camel-core/src/main/resources/org/apache/camel/model/rest/jaxb.index
@@ -24,8 +24,8 @@ RestBindingMode
RestConfigurationDefinition
RestDefinition
RestHostNameResolver
+RestOperationParamDefinition
+RestParamType
RestPropertyDefinition
RestsDefinition
VerbDefinition
-RestOperationParam
-RestParamDefinition