You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@juneau.apache.org by ja...@apache.org on 2018/04/30 00:13:17 UTC
[juneau] branch master updated: Swagger enhancements.
This is an automated email from the ASF dual-hosted git repository.
jamesbognar pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/juneau.git
The following commit(s) were added to refs/heads/master by this push:
new 3c5b8c1 Swagger enhancements.
3c5b8c1 is described below
commit 3c5b8c145cec83d7320330d856699728bc584b5e
Author: JamesBognar <ja...@apache.org>
AuthorDate: Sun Apr 29 20:13:03 2018 -0400
Swagger enhancements.
---
.../org/apache/juneau/dto/swagger/Operation.java | 29 +
.../apache/juneau/dto/swagger/ParameterInfo.java | 54 +-
.../apache/juneau/dto/swagger/ResponseInfo.java | 45 +-
.../apache/juneau/rest/BasicRestInfoProvider.java | 170 +-
.../java/org/apache/juneau/rest/RestContext.java | 6 +
.../org/apache/juneau/rest/RestParamDefaults.java | 22 +-
.../org/apache/juneau/rest/annotation/Body.java | 8 +-
.../apache/juneau/rest/annotation/FormData.java | 8 +-
.../org/apache/juneau/rest/annotation/Header.java | 6 +-
.../org/apache/juneau/rest/annotation/Path.java | 8 +-
.../org/apache/juneau/rest/annotation/Query.java | 8 +-
.../apache/juneau/rest/annotation/Response.java | 4 +-
.../juneau/rest/annotation/ResponseHeader.java | 2 +-
.../juneau/rest/annotation/ResponseHeaders.java | 37 +
.../org/apache/juneau/rest/util/RestUtils.java | 4 +
.../juneau/rest/BasicRestInfoProviderTest.java | 2815 ++++++++++++++++++--
.../rest/BasicRestInfoProviderTest.properties | 4 +-
.../rest/BasicRestInfoProviderTest_swagger.json | 133 +-
18 files changed, 2932 insertions(+), 431 deletions(-)
diff --git a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/swagger/Operation.java b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/swagger/Operation.java
index 1affb33..a896ee1 100644
--- a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/swagger/Operation.java
+++ b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/swagger/Operation.java
@@ -653,6 +653,22 @@ public class Operation extends SwaggerElement {
public List<ParameterInfo> getParameters() {
return parameters;
}
+
+ /**
+ * Returns the parameter with the specified type and name.
+ *
+ * @param in The parameter in.
+ * @param name The parameter name. Can be <jk>null</jk> for parameter type <code>body</code>.
+ * @return The matching parameter info, or <jk>null</jk> if not found.
+ */
+ public ParameterInfo getParameter(String in, String name) {
+ if (parameters != null)
+ for (ParameterInfo pi : parameters)
+ if (StringUtils.isEquals(pi.getIn(), in))
+ if (StringUtils.isEquals(pi.getName(), name) || "body".equals(pi.getIn()))
+ return pi;
+ return null;
+ }
/**
* Bean property setter: <property>parameters</property>.
@@ -758,6 +774,19 @@ public class Operation extends SwaggerElement {
return responses;
}
+
+ /**
+ * Returns the response info with the given status code.
+ *
+ * @param status The HTTP status code.
+ * @return The response info, or <jk>null</jk> if not found.
+ */
+ public ResponseInfo getResponse(Object status) {
+ if (responses != null)
+ return responses.get(String.valueOf(status));
+ return null;
+ }
+
/**
* Bean property setter: <property>responses</property>.
*
diff --git a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/swagger/ParameterInfo.java b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/swagger/ParameterInfo.java
index 9034c5d..5264d7e 100644
--- a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/swagger/ParameterInfo.java
+++ b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/swagger/ParameterInfo.java
@@ -90,7 +90,7 @@ import org.apache.juneau.utils.*;
* <li class='link'><a class='doclink' href='../../../../../overview-summary.html#juneau-dto.Swagger'>Overview > juneau-dto > Swagger</a>
* </ul>
*/
-@Bean(properties="in,name,type,description,required,schema,format,allowEmptyValue,items,collectionFormat,default,maximum,exclusiveMaximum,minimum,exclusiveMinimum,maxLength,minLength,pattern,maxItems,minItems,uniqueItems,enum,multipleOf,x-examples,*")
+@Bean(properties="in,name,type,description,required,schema,format,allowEmptyValue,items,collectionFormat,default,maximum,exclusiveMaximum,minimum,exclusiveMinimum,maxLength,minLength,pattern,maxItems,minItems,uniqueItems,enum,multipleOf,x-example,x-examples,*")
public class ParameterInfo extends SwaggerElement {
private static final String[] VALID_IN = {"query", "header", "path", "formData", "body"};
@@ -124,6 +124,7 @@ public class ParameterInfo extends SwaggerElement {
private Items items;
private Object _default;
private List<Object> _enum;
+ private Object example;
private Map<String,String> examples;
/**
@@ -162,6 +163,7 @@ public class ParameterInfo extends SwaggerElement {
this.items = copyFrom.items == null ? null : copyFrom.items.copy();
this._default = copyFrom._default;
this._enum = newList(copyFrom._enum);
+ this.example = copyFrom.example;
this.examples = copyFrom.examples == null ? null : new LinkedHashMap<String,String>();
if (copyFrom.examples != null)
@@ -239,6 +241,10 @@ public class ParameterInfo extends SwaggerElement {
_default = p._default;
if (p._enum != null)
_enum = p._enum;
+ if (p.example != null)
+ example = p.examples;
+ if (p.examples != null)
+ examples = p.examples;
}
return this;
}
@@ -1409,6 +1415,41 @@ public class ParameterInfo extends SwaggerElement {
}
/**
+ * Bean property getter: <property>x-example</property>.
+ *
+ * @return The property value, or <jk>null</jk> if it is not set.
+ */
+ @BeanProperty("x-example")
+ public Object getExample() {
+ return example;
+ }
+
+ /**
+ * Bean property setter: <property>x-example</property>.
+ *
+ * @param value
+ * The new value for this property.
+ * <br>Can be <jk>null</jk> to unset the property.
+ * @return This object (for method chaining).
+ */
+ @BeanProperty("x-example")
+ public ParameterInfo setExample(Object value) {
+ example = value;
+ return this;
+ }
+
+ /**
+ * Bean property setter: <property>x-example</property>.
+ *
+ * @param value The property value.
+ * @return This object (for method chaining).
+ */
+ public ParameterInfo example(Object value) {
+ example = value;
+ return this;
+ }
+
+ /**
* Bean property getter: <property>x-examples</property>.
*
* @return The property value, or <jk>null</jk> if it is not set.
@@ -1419,7 +1460,7 @@ public class ParameterInfo extends SwaggerElement {
}
/**
- * Bean property setter: <property>examples</property>.
+ * Bean property setter: <property>x-examples</property>.
*
* @param value
* The new value for this property.
@@ -1433,7 +1474,7 @@ public class ParameterInfo extends SwaggerElement {
}
/**
- * Adds one or more values to the <property>examples</property> property.
+ * Adds one or more values to the <property>x-examples</property> property.
*
* @param values
* The values to add to this property.
@@ -1446,7 +1487,7 @@ public class ParameterInfo extends SwaggerElement {
}
/**
- * Adds a single value to the <property>examples</property> property.
+ * Adds a single value to the <property>x-examples</property> property.
*
* @param name The extra property name.
* @param value The extra property value.
@@ -1458,7 +1499,7 @@ public class ParameterInfo extends SwaggerElement {
}
/**
- * Adds one or more values to the <property>examples</property> property.
+ * Adds one or more values to the <property>x-examples</property> property.
*
* @param values
* The values to add to this property.
@@ -1507,6 +1548,7 @@ public class ParameterInfo extends SwaggerElement {
case "uniqueItems": return toType(getUniqueItems(), type);
case "enum": return toType(getEnum(), type);
case "multipleOf": return toType(getMultipleOf(), type);
+ case "x-example": return toType(getExample(), type);
case "x-examples": return toType(getExamples(), type);
default: return super.get(property, type);
}
@@ -1540,6 +1582,7 @@ public class ParameterInfo extends SwaggerElement {
case "uniqueItems": return uniqueItems(value);
case "enum": return setEnum(null)._enum(value);
case "multipleOf": return multipleOf(value);
+ case "x-example": return example(value);
case "x-examples": return examples(value);
default:
super.set(property, value);
@@ -1573,6 +1616,7 @@ public class ParameterInfo extends SwaggerElement {
.appendIf(uniqueItems != null, "uniqueItems")
.appendIf(_enum != null, "enum")
.appendIf(multipleOf != null, "multipleOf")
+ .appendIf(example != null, "x-example")
.appendIf(examples != null, "x-examples");
return new MultiSet<>(s, super.keySet());
}
diff --git a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/swagger/ResponseInfo.java b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/swagger/ResponseInfo.java
index 5dd1da6..7591e5e 100644
--- a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/swagger/ResponseInfo.java
+++ b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/swagger/ResponseInfo.java
@@ -59,12 +59,13 @@ import org.apache.juneau.utils.*;
* <li class='link'><a class='doclink' href='../../../../../overview-summary.html#juneau-dto.Swagger'>Overview > juneau-dto > Swagger</a>
* </ul>
*/
-@Bean(properties="description,schema,headers,examples,*")
+@Bean(properties="description,schema,headers,x-example,examples,*")
public class ResponseInfo extends SwaggerElement {
private String description;
private SchemaInfo schema;
private Map<String,HeaderInfo> headers;
+ private Object example;
private Map<String,Object> examples;
/**
@@ -88,6 +89,8 @@ public class ResponseInfo extends SwaggerElement {
for (Map.Entry<String,HeaderInfo> e : copyFrom.headers.entrySet())
this.headers.put(e.getKey(), e.getValue().copy());
+ this.example = copyFrom.example;
+
this.examples = copyFrom.examples == null ? null : new LinkedHashMap<String,Object>();
if (copyFrom.examples != null)
this.examples.putAll(copyFrom.examples);
@@ -118,6 +121,8 @@ public class ResponseInfo extends SwaggerElement {
schema = r.schema;
if (r.headers != null)
headers = r.headers;
+ if (r.example != null)
+ example = r.example;
if (r.examples != null)
examples = r.examples;
}
@@ -314,6 +319,41 @@ public class ResponseInfo extends SwaggerElement {
}
/**
+ * Bean property getter: <property>x-example</property>.
+ *
+ * @return The property value, or <jk>null</jk> if it is not set.
+ */
+ @BeanProperty("x-example")
+ public Object getExample() {
+ return example;
+ }
+
+ /**
+ * Bean property setter: <property>x-example</property>.
+ *
+ * @param value
+ * The new value for this property.
+ * <br>Can be <jk>null</jk> to unset the property.
+ * @return This object (for method chaining).
+ */
+ @BeanProperty("x-example")
+ public ResponseInfo setExample(Object value) {
+ example = value;
+ return this;
+ }
+
+ /**
+ * Bean property setter: <property>x-example</property>.
+ *
+ * @param value The property value.
+ * @return This object (for method chaining).
+ */
+ public ResponseInfo example(Object value) {
+ example = value;
+ return this;
+ }
+
+ /**
* Bean property getter: <property>examples</property>.
*
* <p>
@@ -397,6 +437,7 @@ public class ResponseInfo extends SwaggerElement {
case "description": return toType(getDescription(), type);
case "schema": return toType(getSchema(), type);
case "headers": return toType(getHeaders(), type);
+ case "example": return toType(getExample(), type);
case "examples": return toType(getExamples(), type);
default: return super.get(property, type);
}
@@ -410,6 +451,7 @@ public class ResponseInfo extends SwaggerElement {
case "description": return description(value);
case "schema": return schema(value);
case "headers": return setHeaders(null).headers(value);
+ case "example": return setExample(value);
case "examples": return setExamples(null).examples(value);
default:
super.set(property, value);
@@ -423,6 +465,7 @@ public class ResponseInfo extends SwaggerElement {
.appendIf(description != null, "description")
.appendIf(schema != null, "schema")
.appendIf(headers != null, "headers")
+ .appendIf(example != null, "example")
.appendIf(examples != null, "examples");
return new MultiSet<>(s, super.keySet());
}
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/BasicRestInfoProvider.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/BasicRestInfoProvider.java
index 55ed686..8c11d5e 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/BasicRestInfoProvider.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/BasicRestInfoProvider.java
@@ -278,9 +278,9 @@ public class BasicRestInfoProvider implements RestInfoProvider {
op.putAll(parseMap(joinnl(ms.value()), vr, true, false, "@MethodSwagger(value) on class {0} method {1}", c, m));
op.appendIf(true, true, true, "operationId", vr.resolve(ms.operationId()));
- op.appendIf(true, true, true, "summary", vr.resolve(rm.summary()));
+ op.appendIf(false, true, true, "summary", vr.resolve(rm.summary()));
op.appendIf(true, true, true, "summary", vr.resolve(joinnl(ms.summary())));
- op.appendIf(true, true, true, "description", vr.resolve(joinnl(rm.description())));
+ op.appendIf(false, true, true, "description", vr.resolve(joinnl(rm.description())));
op.appendIf(true, true, true, "description", vr.resolve(joinnl(ms.description())));
op.appendIf(true, true, true, "deprecated", vr.resolve(ms.deprecated()));
op.appendIf(true, true, true, "externalDocs", parseMap(joinnl(ms.externalDocs()), vr, false, true, "@MethodSwagger(externalDocs) on class {0} method {1}", c, m));
@@ -293,7 +293,7 @@ public class BasicRestInfoProvider implements RestInfoProvider {
op.putIfNotExists("operationId", mn);
- if (m.getAnnotation(Deprecated.class) != null)
+ if (m.getAnnotation(Deprecated.class) != null || m.getDeclaringClass().getAnnotation(Deprecated.class) != null)
op.put("deprecated", true);
op.appendIf(true, true, true, "summary", vr.resolve(mb.findFirstString(locale, mn + ".summary")));
@@ -314,7 +314,7 @@ public class BasicRestInfoProvider implements RestInfoProvider {
ObjectMap paramMap = new ObjectMap();
if (op.containsKey("parameters"))
for (ObjectMap param : op.getObjectList("parameters").elements(ObjectMap.class))
- paramMap.put(param.getString("in") + '.' + param.getString("name"), param);
+ paramMap.put(param.getString("in") + '.' + ("body".equals(param.getString("in")) ? "body" : param.getString("name")), param);
// Finally, look for parameters defined on method.
for (RestMethodParam mp : context.getRestMethodParams(m)) {
@@ -324,7 +324,7 @@ public class BasicRestInfoProvider implements RestInfoProvider {
if (in == OTHER || in == RESPONSE || in == RESPONSE_HEADER || in == RESPONSE_STATUS)
continue;
- String key = in.toString() + '.' + (in == BODY ? null : mp.getName());
+ String key = in.toString() + '.' + (in == BODY ? "body" : mp.getName());
ObjectMap param = paramMap.getObjectMap(key, true);
@@ -334,29 +334,29 @@ public class BasicRestInfoProvider implements RestInfoProvider {
param.append("name", mp.name);
ObjectMap pi = mp.getMetaData();
- param.appendIf(false, true, true, "required", vr.resolve(pi.getString("required")));
- param.appendIf(false, true, true, "description", vr.resolve(pi.getString("description")));
- param.appendIf(false, true, true, "type", vr.resolve(pi.getString("type")));
- param.appendIf(false, true, true, "format", vr.resolve(pi.getString("format")));
- param.appendIf(false, true, true, "pattern", vr.resolve(pi.getString("pattern")));
- param.appendIf(false, true, true, "collectionFormat", vr.resolve(pi.getString("collectionFormat")));
- param.appendIf(false, true, true, "maximum", vr.resolve(pi.getString("maximum")));
- param.appendIf(false, true, true, "minimum", vr.resolve(pi.getString("minimum")));
- param.appendIf(false, true, true, "multipleOf", vr.resolve(pi.getString("multipleOf")));
- param.appendIf(false, true, true, "maxLength", vr.resolve(pi.getString("maxLength")));
- param.appendIf(false, true, true, "minLength", vr.resolve(pi.getString("minLength")));
- param.appendIf(false, true, true, "maxItems", vr.resolve(pi.getString("maxItems")));
- param.appendIf(false, true, true, "minItems", vr.resolve(pi.getString("minItems")));
- param.appendIf(false, true, true, "allowEmptyVals", vr.resolve(pi.getString("allowEmptyVals")));
- param.appendIf(false, true, true, "exclusiveMaximum", vr.resolve(pi.getString("exclusiveMaximum")));
- param.appendIf(false, true, true, "exclusiveMimimum", vr.resolve(pi.getString("exclusiveMimimum")));
- param.appendIf(false, true, true, "uniqueItems", vr.resolve(pi.getString("uniqueItems")));
- param.appendIf(false, true, true, "schema", parseMap(pi.getString("schema"), vr, false, true, "ParameterInfo/schema on class {0} method {1}", c, m));
- param.appendIf(false, true, true, "default", JsonParser.DEFAULT.parse(vr.resolve(pi.getString("default")), Object.class));
- param.appendIf(false, true, true, "enum", parseList(pi.getString("enum"), vr, false, true, "ParameterInfo/enum on class {0} method {1}", c, m));
- param.appendIf(false, true, true, "x-example", parseAnything(vr.resolve(pi.getString("example"))));
- if (pi.containsKeyNotEmpty("items"))
- param.appendIf(false, true, true, "items", new ObjectMap(vr.resolve(pi.getString("items"))));
+ param.appendIf(true, true, true, "required", vr.resolve(pi.getString("required")));
+ param.appendIf(true, true, true, "description", vr.resolve(pi.getString("description")));
+ param.appendIf(true, true, true, "type", vr.resolve(pi.getString("type")));
+ param.appendIf(true, true, true, "format", vr.resolve(pi.getString("format")));
+ param.appendIf(true, true, true, "pattern", vr.resolve(pi.getString("pattern")));
+ param.appendIf(true, true, true, "collectionFormat", vr.resolve(pi.getString("collectionFormat")));
+ param.appendIf(true, true, true, "maximum", vr.resolve(pi.getString("maximum")));
+ param.appendIf(true, true, true, "minimum", vr.resolve(pi.getString("minimum")));
+ param.appendIf(true, true, true, "multipleOf", vr.resolve(pi.getString("multipleOf")));
+ param.appendIf(true, true, true, "maxLength", vr.resolve(pi.getString("maxLength")));
+ param.appendIf(true, true, true, "minLength", vr.resolve(pi.getString("minLength")));
+ param.appendIf(true, true, true, "maxItems", vr.resolve(pi.getString("maxItems")));
+ param.appendIf(true, true, true, "minItems", vr.resolve(pi.getString("minItems")));
+ param.appendIf(true, true, true, "allowEmptyValue", vr.resolve(pi.getString("allowEmptyValue")));
+ param.appendIf(true, true, true, "exclusiveMaximum", vr.resolve(pi.getString("exclusiveMaximum")));
+ param.appendIf(true, true, true, "exclusiveMinimum", vr.resolve(pi.getString("exclusiveMinimum")));
+ param.appendIf(true, true, true, "uniqueItems", vr.resolve(pi.getString("uniqueItems")));
+ param.appendIf(true, true, true, "schema", parseMap(pi.getString("schema"), vr, false, true, "ParameterInfo/schema on class {0} method {1}", c, m));
+ param.appendIf(true, true, true, "default", JsonParser.DEFAULT.parse(vr.resolve(pi.getString("default")), Object.class));
+ param.appendIf(true, true, true, "enum", parseList(pi.getString("enum"), vr, false, true, "ParameterInfo/enum on class {0} method {1}", c, m));
+ param.appendIf(true, true, true, "x-example", parseAnything(vr.resolve(pi.getString("example"))));
+ param.appendIf(true, true, true, "x-examples", parseMap(pi.getString("examples"), vr, false, true, "ParameterInfo/examples on class {0} method {1}", c, m));
+ param.appendIf(true, true, true, "items", parseMap(pi.getString("items"), vr, false, true, "ParameterInfo/items on class {0} method {1}", c, m));
if ((in == BODY || in == PATH) && ! param.containsKeyNotEmpty("required"))
param.put("required", true);
@@ -376,10 +376,11 @@ public class BasicRestInfoProvider implements RestInfoProvider {
if (code != 0) {
ObjectMap md = rt.getMetaData();
ObjectMap om = responses.getObjectMap(String.valueOf(code), true);
- om.appendIf(false, true, true, "description", vr.resolve(md.getString("description")));
- om.appendIf(false, true, true, "x-example", parseAnything(vr.resolve(md.getString("example"))));
- om.appendIf(false, true, true, "schema", parseMap(md.getString("schema"), vr, false, true, "RestMethodThrown/schema on class {0} method {1}", c, m));
- om.appendIf(false, true, true, "headers", parseList(md.getString("headers"), vr, false, true, "RestMethodThrown/headers on class {0} method {1}", c, m));
+ om.appendIf(true, true, true, "description", vr.resolve(md.getString("description")));
+ om.appendIf(true, true, true, "x-example", parseAnything(vr.resolve(md.getString("example"))));
+ om.appendIf(true, true, true, "examples", parseMap(md.getString("examples"), vr, false, true, "RestMethodThrown/examples on class {0} method {1}", c, m));
+ om.appendIf(true, true, true, "schema", parseMap(md.getString("schema"), vr, false, true, "RestMethodThrown/schema on class {0} method {1}", c, m));
+ om.appendIf(true, true, true, "headers", parseMap(md.getString("headers"), vr, false, true, "RestMethodThrown/headers on class {0} method {1}", c, m));
}
}
@@ -389,22 +390,15 @@ public class BasicRestInfoProvider implements RestInfoProvider {
ObjectMap rom = responses.getObjectMap(rStatus, true);
ObjectMap rmd = r.getMetaData();
- rom.appendIf(false, true, true, "description", vr.resolve(rmd.getString("description")));
- rom.appendIf(false, true, true, "x-example", parseAnything(vr.resolve(rmd.getString("example"))));
- rom.appendIf(false, true, true, "schema", parseMap(rmd.getString("schema"), vr, false, true, "RestMethodReturn/schema on class {0} method {1}", c, m));
- rom.appendIf(false, true, true, "headers", parseMap(rmd.getString("headers"), vr, false, true, "RestMethodReturn/headers on class {0} method {1}", c, m));
+ rom.appendIf(true, true, true, "description", vr.resolve(rmd.getString("description")));
+ rom.appendIf(true, true, true, "x-example", parseAnything(vr.resolve(rmd.getString("example"))));
+ rom.appendIf(true, true, true, "examples", parseMap(rmd.getString("examples"), vr, false, true, "RestMethodReturn/examples on class {0} method {1}", c, m));
+ rom.appendIf(true, true, true, "schema", parseMap(rmd.getString("schema"), vr, false, true, "RestMethodReturn/schema on class {0} method {1}", c, m));
+ rom.appendIf(true, true, true, "headers", parseMap(rmd.getString("headers"), vr, false, true, "RestMethodReturn/headers on class {0} method {1}", c, m));
rom.put("schema", getSchema(req, rom.getObjectMap("schema", true), js, m.getGenericReturnType()));
addXExamples(req, sm, rom, "ok", js, m.getGenericReturnType());
- // Add default response descriptions.
- for (Map.Entry<String,Object> e : responses.entrySet()) {
- String key = e.getKey();
- Object val = e.getValue();
- if (StringUtils.isDecimal(key) && val instanceof ObjectMap)
- responses.getObjectMap(key).appendIf(false, true, true, "description", RestUtils.getHttpResponseText(Integer.parseInt(key)));
- }
-
// Finally, look for @ResponseHeader parameters defined on method.
for (RestMethodParam mp : context.getRestMethodParams(m)) {
@@ -412,51 +406,67 @@ public class BasicRestInfoProvider implements RestInfoProvider {
if (in == RESPONSE_HEADER) {
ObjectMap pi = mp.getMetaData();
- String code = pi.getString("status", "200");
- String name = mp.getName();
-
- ObjectMap header = responses.getObjectMap(code, true).getObjectMap("headers", true).getObjectMap(name, true);
-
- header.appendIf(false, true, true, "description", vr.resolve(pi.getString("description")));
- header.appendIf(false, true, true, "type", vr.resolve(pi.getString("type")));
- header.appendIf(false, true, true, "format", vr.resolve(pi.getString("format")));
- header.appendIf(false, true, true, "collectionFormat", vr.resolve(pi.getString("collectionFormat")));
- header.appendIf(false, true, true, "maximum", vr.resolve(pi.getString("maximum")));
- header.appendIf(false, true, true, "minimum", vr.resolve(pi.getString("minimum")));
- header.appendIf(false, true, true, "multipleOf", vr.resolve(pi.getString("multipleOf")));
- header.appendIf(false, true, true, "maxLength", vr.resolve(pi.getString("maxLength")));
- header.appendIf(false, true, true, "minLength", vr.resolve(pi.getString("minLength")));
- header.appendIf(false, true, true, "maxItems", vr.resolve(pi.getString("maxItems")));
- header.appendIf(false, true, true, "minItems", vr.resolve(pi.getString("minItems")));
- header.appendIf(false, true, true, "exclusiveMaximum", vr.resolve(pi.getString("exclusiveMaximum")));
- header.appendIf(false, true, true, "exclusiveMimimum", vr.resolve(pi.getString("exclusiveMimimum")));
- header.appendIf(false, true, true, "uniqueItems", vr.resolve(pi.getString("uniqueItems")));
- header.appendIf(false, true, true, "default", JsonParser.DEFAULT.parse(vr.resolve(pi.getString("default")), Object.class));
- header.appendIf(false, true, true, "enum", parseList(pi.getString("enum"), vr, false, true, "ParameterInfo/enum on class {0} method {1}", c, m));
- header.appendIf(false, true, true, "x-example", parseAnything(vr.resolve(pi.getString("example"))));
- if (pi.containsKeyNotEmpty("items"))
- header.appendIf(false, true, true, "items", new ObjectMap(vr.resolve(pi.getString("items"))));
+ for (String code : pi.keySet()) {
+ String name = mp.getName();
+ ObjectMap pi2 = pi.getObjectMap(code, true);
+
+ ObjectMap header = responses.getObjectMap(code, true).getObjectMap("headers", true).getObjectMap(name, true);
+
+ header.appendIf(true, true, true, "description", vr.resolve(pi2.getString("description")));
+ header.appendIf(true, true, true, "type", vr.resolve(pi2.getString("type")));
+ header.appendIf(true, true, true, "format", vr.resolve(pi2.getString("format")));
+ header.appendIf(true, true, true, "collectionFormat", vr.resolve(pi2.getString("collectionFormat")));
+ header.appendIf(true, true, true, "maximum", vr.resolve(pi2.getString("maximum")));
+ header.appendIf(true, true, true, "minimum", vr.resolve(pi2.getString("minimum")));
+ header.appendIf(true, true, true, "multipleOf", vr.resolve(pi2.getString("multipleOf")));
+ header.appendIf(true, true, true, "maxLength", vr.resolve(pi2.getString("maxLength")));
+ header.appendIf(true, true, true, "minLength", vr.resolve(pi2.getString("minLength")));
+ header.appendIf(true, true, true, "maxItems", vr.resolve(pi2.getString("maxItems")));
+ header.appendIf(true, true, true, "minItems", vr.resolve(pi2.getString("minItems")));
+ header.appendIf(true, true, true, "exclusiveMaximum", vr.resolve(pi2.getString("exclusiveMaximum")));
+ header.appendIf(true, true, true, "exclusiveMinimum", vr.resolve(pi2.getString("exclusiveMinimum")));
+ header.appendIf(true, true, true, "uniqueItems", vr.resolve(pi2.getString("uniqueItems")));
+ header.appendIf(true, true, true, "default", JsonParser.DEFAULT.parse(vr.resolve(pi2.getString("default")), Object.class));
+ header.appendIf(true, true, true, "enum", parseList(pi2.getString("enum"), vr, false, true, "ParameterInfo/enum on class {0} method {1}", c, m));
+ header.appendIf(true, true, true, "x-example", parseAnything(vr.resolve(pi2.getString("example"))));
+ header.appendIf(true, true, true, "examples", parseMap(pi2.getString("examples"), vr, false, true, "ParameterInfo/examples on class {0} method {1}", c, m));
+ header.appendIf(true, true, true, "items", parseMap(pi2.getString("items"), vr, false, true, "ParameterInfo/items on class {0} method {1}", c, m));
+ }
} else if (in == RESPONSE) {
ObjectMap pi = mp.getMetaData();
- String code = pi.getString("status", "200");
-
- ObjectMap response = responses.getObjectMap(code, true);
-
- response.appendIf(false, true, true, "description", vr.resolve(pi.getString("description")));
- response.appendIf(false, true, true, "schema", vr.resolve(pi.getString("schema")));
- response.appendIf(false, true, true, "x-example", parseAnything(vr.resolve(pi.getString("example"))));
+ for (String code : pi.keySet()) {
+ ObjectMap pi2 = pi.getObjectMap(code, true);
+
+ ObjectMap response = responses.getObjectMap(code, true);
+
+ response.appendIf(true, true, true, "description", vr.resolve(pi2.getString("description")));
+ response.appendIf(true, true, true, "schema", parseMap(pi2.getString("schema"), vr, false, true, "@Response/schema on class {0} method {1}", c, m));
+ response.appendIf(true, true, true, "headers", parseMap(pi2.getString("headers"), vr, false, true, "@Response/headers on class {0} method {1}", c, m));
+ response.appendIf(true, true, true, "x-example", parseAnything(vr.resolve(pi2.getString("example"))));
+ response.appendIf(true, true, true, "examples", parseMap(pi2.getString("examples"), vr, false, true, "@Response/examples on class {0} method {1}", c, m));
+ }
} else if (in == RESPONSE_STATUS) {
ObjectMap pi = mp.getMetaData();
- String code = pi.getString("status", "200");
+ for (String code : pi.keySet()) {
+ ObjectMap pi2 = pi.getObjectMap(code, true);
- ObjectMap response = responses.getObjectMap(code, true);
+ ObjectMap response = responses.getObjectMap(code, true);
- response.appendIf(false, true, true, "description", vr.resolve(pi.getString("description")));
+ response.appendIf(true, true, true, "description", vr.resolve(pi2.getString("description")));
+ }
}
}
+ // Add default response descriptions.
+ for (Map.Entry<String,Object> e : responses.entrySet()) {
+ String key = e.getKey();
+ ObjectMap val = responses.getObjectMap(key);
+ if (StringUtils.isDecimal(key))
+ val.appendIf(false, true, true, "description", RestUtils.getHttpResponseText(Integer.parseInt(key)));
+ }
+
if (responses.isEmpty())
op.remove("responses");
else
@@ -637,7 +647,7 @@ public class BasicRestInfoProvider implements RestInfoProvider {
}
} else {
String paramName = piri.getString("name");
- String s = req.getPartSerializer().serialize(HttpPartType.valueOf(in.toUpperCase()), example);
+ String s = sm.partSerializer.serialize(HttpPartType.valueOf(in.toUpperCase()), example);
if ("query".equals(in))
s = "?" + urlEncodeLax(paramName) + "=" + urlEncodeLax(s);
else if ("formData".equals(in))
@@ -656,7 +666,7 @@ public class BasicRestInfoProvider implements RestInfoProvider {
private ObjectMap resolve(JsonSchemaSerializerSession js, ObjectMap m) {
if (m == null)
return null;
- if (m.containsKey("$ref")) {
+ if (m.containsKey("$ref") && js.getBeanDefs() != null) {
String ref = m.getString("$ref");
if (ref.startsWith("#/definitions/"))
return js.getBeanDefs().get(ref.substring(14));
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestContext.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestContext.java
index b5ea4e8..cb2cc5b 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestContext.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestContext.java
@@ -4302,6 +4302,9 @@ public final class RestContext extends BeanContext {
else if (a instanceof ResponseStatuses)
for (ResponseStatus rs : ((ResponseStatuses)a).value())
rp[i] = new RestParamDefaults.ResponseStatusObject(method, rs, t, ps, rp[i]);
+ else if (a instanceof ResponseHeaders)
+ for (ResponseHeader rh : ((ResponseHeaders)a).value())
+ rp[i] = new RestParamDefaults.ResponseHeaderObject(method, rh, t, ps, rp[i]);
}
}
@@ -4334,6 +4337,9 @@ public final class RestContext extends BeanContext {
else if (a instanceof ResponseStatuses)
for (ResponseStatus rs : ((ResponseStatuses)a).value())
rp[i] = new RestParamDefaults.ResponseStatusObject(method, rs, t, ps, rp[i]);
+ else if (a instanceof ResponseHeaders)
+ for (ResponseHeader rh : ((ResponseHeaders)a).value())
+ rp[i] = new RestParamDefaults.ResponseHeaderObject(method, rh, t, ps, rp[i]);
}
if (rp[i] == null) {
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestParamDefaults.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestParamDefaults.java
index 21555d6..a4346ff 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestParamDefaults.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestParamDefaults.java
@@ -569,9 +569,9 @@ class RestParamDefaults {
.appendSkipEmpty("multipleOf", a.multipleOf())
.appendSkipEmpty("maxLength", a.maxLength())
.appendSkipEmpty("minLength", a.minLength())
- .appendSkipEmpty("allowEmptyVals", a.allowEmptyVals())
+ .appendSkipEmpty("allowEmptyValue", a.allowEmptyValue())
.appendSkipEmpty("exclusiveMaximum", a.exclusiveMaximum())
- .appendSkipEmpty("exclusiveMimimum", a.exclusiveMimimum())
+ .appendSkipEmpty("exclusiveMinimum", a.exclusiveMinimum())
.appendSkipEmpty("schema", joinnl(a.schema()))
.appendSkipEmpty("enum", joinnl(a._enum()))
.appendSkipEmpty("example", joinnl(a.example()))
@@ -608,15 +608,16 @@ class RestParamDefaults {
.appendSkipEmpty("minLength", a.minLength())
.appendSkipEmpty("maxItems", a.maxItems())
.appendSkipEmpty("minItems", a.minItems())
- .appendSkipEmpty("allowEmptyVals", a.allowEmptyVals())
+ .appendSkipEmpty("allowEmptyValue", a.allowEmptyValue())
.appendSkipEmpty("exclusiveMaximum", a.exclusiveMaximum())
- .appendSkipEmpty("exclusiveMimimum", a.exclusiveMimimum())
+ .appendSkipEmpty("exclusiveMinimum", a.exclusiveMinimum())
.appendSkipEmpty("uniqueItems", a.uniqueItems())
.appendSkipEmpty("schema", joinnl(a.schema()))
.appendSkipEmpty("default", joinnl(a._default()))
.appendSkipEmpty("enum", joinnl(a._enum()))
.appendSkipEmpty("items", joinnl(a.items()))
.appendSkipEmpty("example", joinnl(a.example()))
+ .appendSkipEmpty("examples", joinnl(a.examples()))
;
}
}
@@ -652,7 +653,7 @@ class RestParamDefaults {
.appendSkipEmpty("minLength", a.minLength())
.appendSkipEmpty("maxItems", a.maxItems())
.appendSkipEmpty("minItems", a.minItems())
- .appendSkipEmpty("allowEmptyVals", a.allowEmptyVals())
+ .appendSkipEmpty("allowEmptyValue", a.allowEmptyValue())
.appendSkipEmpty("exclusiveMaximum", a.exclusiveMaximum())
.appendSkipEmpty("exclusiveMinimum", a.exclusiveMinimum())
.appendSkipEmpty("uniqueItems", a.uniqueItems())
@@ -726,7 +727,7 @@ class RestParamDefaults {
.appendSkipEmpty("maxItems", a.maxItems())
.appendSkipEmpty("minItems", a.minItems())
.appendSkipEmpty("exclusiveMaximum", a.exclusiveMaximum())
- .appendSkipEmpty("exclusiveMimimum", a.exclusiveMinimum())
+ .appendSkipEmpty("exclusiveMinimum", a.exclusiveMinimum())
.appendSkipEmpty("uniqueItems", a.uniqueItems())
.appendSkipEmpty("default", joinnl(a._default()))
.appendSkipEmpty("enum", joinnl(a._enum()))
@@ -784,6 +785,7 @@ class RestParamDefaults {
.appendSkipEmpty("schema", joinnl(a.schema()))
.appendSkipEmpty("headers", joinnl(a.headers()))
.appendSkipEmpty("example", joinnl(a.example()))
+ .appendSkipEmpty("examples", joinnl(a.examples()))
;
return om;
}
@@ -888,9 +890,9 @@ class RestParamDefaults {
.appendSkipEmpty("minLength", a.minLength())
.appendSkipEmpty("maxItems", a.maxItems())
.appendSkipEmpty("minItems", a.minItems())
- .appendSkipEmpty("allowEmptyVals", a.allowEmptyVals())
+ .appendSkipEmpty("allowEmptyValue", a.allowEmptyValue())
.appendSkipEmpty("exclusiveMaximum", a.exclusiveMaximum())
- .appendSkipEmpty("exclusiveMimimum", a.exclusiveMimimum())
+ .appendSkipEmpty("exclusiveMinimum", a.exclusiveMinimum())
.appendSkipEmpty("uniqueItems", a.uniqueItems())
.appendSkipEmpty("schema", joinnl(a.schema()))
.appendSkipEmpty("default", joinnl(a._default()))
@@ -938,9 +940,9 @@ class RestParamDefaults {
.appendSkipEmpty("minLength", a.minLength())
.appendSkipEmpty("maxItems", a.maxItems())
.appendSkipEmpty("minItems", a.minItems())
- .appendSkipEmpty("allowEmptyVals", a.allowEmptyVals())
+ .appendSkipEmpty("allowEmptyValue", a.allowEmptyValue())
.appendSkipEmpty("exclusiveMaximum", a.exclusiveMaximum())
- .appendSkipEmpty("exclusiveMimimum", a.exclusiveMimimum())
+ .appendSkipEmpty("exclusiveMinimum", a.exclusiveMinimum())
.appendSkipEmpty("uniqueItems", a.uniqueItems())
.appendSkipEmpty("schema", joinnl(a.schema()))
.appendSkipEmpty("default", joinnl(a._default()))
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/Body.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/Body.java
index f6c8b7c..6fcc1a4 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/Body.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/Body.java
@@ -273,7 +273,7 @@ public @interface Body {
* (e.g. <js>"$L{my.localized.variable}"</js>).
* </ul>
*/
- String allowEmptyVals() default "";
+ String allowEmptyValue() default "";
/**
* Defines the swagger value <code>/paths/{path}/{method}/parameters/#/exclusiveMaximum</code>.
@@ -290,7 +290,7 @@ public @interface Body {
String exclusiveMaximum() default "";
/**
- * Defines the swagger value <code>/paths/{path}/{method}/parameters/#/exclusiveMimimum</code>.
+ * Defines the swagger value <code>/paths/{path}/{method}/parameters/#/exclusiveMinimum</code>.
*
* <h5 class='section'>Notes:</h5>
* <ul class='spaced-list'>
@@ -301,7 +301,7 @@ public @interface Body {
* (e.g. <js>"$L{my.localized.variable}"</js>).
* </ul>
*/
- String exclusiveMimimum() default "";
+ String exclusiveMinimum() default "";
/**
* Defines the swagger value <code>/paths/{path}/{method}/parameters/#/uniqueItems</code>.
@@ -402,4 +402,6 @@ public @interface Body {
* </ul>
*/
String[] example() default {};
+
+ String[] examples() default {};
}
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/FormData.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/FormData.java
index 8049a63..0e3b068 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/FormData.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/FormData.java
@@ -306,7 +306,7 @@ public @interface FormData {
String minItems() default "";
/**
- * Defines the swagger value <code>/paths/{path}/{method}/parameters/#/allowEmptyVals</code>.
+ * Defines the swagger value <code>/paths/{path}/{method}/parameters/#/allowEmptyValue</code>.
*
* <h5 class='section'>Notes:</h5>
* <ul class='spaced-list'>
@@ -317,7 +317,7 @@ public @interface FormData {
* (e.g. <js>"$L{my.localized.variable}"</js>).
* </ul>
*/
- String allowEmptyVals() default "";
+ String allowEmptyValue() default "";
/**
* Defines the swagger value <code>/paths/{path}/{method}/parameters/#/exclusiveMaximum</code>.
@@ -334,7 +334,7 @@ public @interface FormData {
String exclusiveMaximum() default "";
/**
- * Defines the swagger value <code>/paths/{path}/{method}/parameters/#/exclusiveMimimum</code>.
+ * Defines the swagger value <code>/paths/{path}/{method}/parameters/#/exclusiveMinimum</code>.
*
* <h5 class='section'>Notes:</h5>
* <ul class='spaced-list'>
@@ -345,7 +345,7 @@ public @interface FormData {
* (e.g. <js>"$L{my.localized.variable}"</js>).
* </ul>
*/
- String exclusiveMimimum() default "";
+ String exclusiveMinimum() default "";
/**
* Defines the swagger value <code>/paths/{path}/{method}/parameters/#/uniqueItems</code>.
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/Header.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/Header.java
index 66ecc63..b0225c4 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/Header.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/Header.java
@@ -279,7 +279,7 @@ public @interface Header {
String minItems() default "";
/**
- * Defines the swagger value <code>/paths/{path}/{method}/parameters/#/allowEmptyVals</code>.
+ * Defines the swagger value <code>/paths/{path}/{method}/parameters/#/allowEmptyValue</code>.
*
* <h5 class='section'>Notes:</h5>
* <ul class='spaced-list'>
@@ -290,7 +290,7 @@ public @interface Header {
* (e.g. <js>"$L{my.localized.variable}"</js>).
* </ul>
*/
- String allowEmptyVals() default "";
+ String allowEmptyValue() default "";
/**
* Defines the swagger value <code>/paths/{path}/{method}/parameters/#/exclusiveMaximum</code>.
@@ -307,7 +307,7 @@ public @interface Header {
String exclusiveMaximum() default "";
/**
- * Defines the swagger value <code>/paths/{path}/{method}/parameters/#/exclusiveMimimum</code>.
+ * Defines the swagger value <code>/paths/{path}/{method}/parameters/#/exclusiveMinimum</code>.
*
* <h5 class='section'>Notes:</h5>
* <ul class='spaced-list'>
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/Path.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/Path.java
index ebe2e14..1e304f7 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/Path.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/Path.java
@@ -241,7 +241,7 @@ public @interface Path {
String minLength() default "";
/**
- * Defines the swagger value <code>/paths/{path}/{method}/parameters/#/allowEmptyVals</code>.
+ * Defines the swagger value <code>/paths/{path}/{method}/parameters/#/allowEmptyValue</code>.
*
* <h5 class='section'>Notes:</h5>
* <ul class='spaced-list'>
@@ -252,7 +252,7 @@ public @interface Path {
* (e.g. <js>"$L{my.localized.variable}"</js>).
* </ul>
*/
- String allowEmptyVals() default "";
+ String allowEmptyValue() default "";
/**
* Defines the swagger value <code>/paths/{path}/{method}/parameters/#/exclusiveMaximum</code>.
@@ -269,7 +269,7 @@ public @interface Path {
String exclusiveMaximum() default "";
/**
- * Defines the swagger value <code>/paths/{path}/{method}/parameters/#/exclusiveMimimum</code>.
+ * Defines the swagger value <code>/paths/{path}/{method}/parameters/#/exclusiveMinimum</code>.
*
* <h5 class='section'>Notes:</h5>
* <ul class='spaced-list'>
@@ -280,7 +280,7 @@ public @interface Path {
* (e.g. <js>"$L{my.localized.variable}"</js>).
* </ul>
*/
- String exclusiveMimimum() default "";
+ String exclusiveMinimum() default "";
/**
* Defines the swagger value <code>/paths/{path}/{method}/parameters/#/schema</code>.
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/Query.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/Query.java
index dc02856..c95f2a3 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/Query.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/Query.java
@@ -302,7 +302,7 @@ public @interface Query {
String minItems() default "";
/**
- * Defines the swagger value <code>/paths/{path}/{method}/parameters/#/allowEmptyVals</code>.
+ * Defines the swagger value <code>/paths/{path}/{method}/parameters/#/allowEmptyValue</code>.
*
* <h5 class='section'>Notes:</h5>
* <ul class='spaced-list'>
@@ -313,7 +313,7 @@ public @interface Query {
* (e.g. <js>"$L{my.localized.variable}"</js>).
* </ul>
*/
- String allowEmptyVals() default "";
+ String allowEmptyValue() default "";
/**
* Defines the swagger value <code>/paths/{path}/{method}/parameters/#/exclusiveMaximum</code>.
@@ -330,7 +330,7 @@ public @interface Query {
String exclusiveMaximum() default "";
/**
- * Defines the swagger value <code>/paths/{path}/{method}/parameters/#/exclusiveMimimum</code>.
+ * Defines the swagger value <code>/paths/{path}/{method}/parameters/#/exclusiveMinimum</code>.
*
* <h5 class='section'>Notes:</h5>
* <ul class='spaced-list'>
@@ -341,7 +341,7 @@ public @interface Query {
* (e.g. <js>"$L{my.localized.variable}"</js>).
* </ul>
*/
- String exclusiveMimimum() default "";
+ String exclusiveMinimum() default "";
/**
* Defines the swagger value <code>/paths/{path}/{method}/parameters/#/uniqueItems</code>.
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/Response.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/Response.java
index 7f5def4..cc17898 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/Response.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/Response.java
@@ -91,7 +91,7 @@ import org.apache.juneau.rest.helper.*;
*
*/
@Documented
-@Target(TYPE)
+@Target({PARAMETER,TYPE})
@Retention(RUNTIME)
@Inherited
public @interface Response {
@@ -201,4 +201,6 @@ public @interface Response {
* </ul>
*/
String[] example() default {};
+
+ String[] examples() default {};
}
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/ResponseHeader.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/ResponseHeader.java
index abe609c..eb705c9 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/ResponseHeader.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/ResponseHeader.java
@@ -321,7 +321,7 @@ public @interface ResponseHeader {
String exclusiveMaximum() default "";
/**
- * Defines the swagger value <code>/paths/{path}/{method}/responses/{status-code}/headers/{header-name}/exclusiveMimimum</code>.
+ * Defines the swagger value <code>/paths/{path}/{method}/responses/{status-code}/headers/{header-name}/exclusiveMinimum</code>.
*
* <h5 class='section'>Notes:</h5>
* <ul class='spaced-list'>
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/ResponseHeaders.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/ResponseHeaders.java
new file mode 100644
index 0000000..bc4ca8d
--- /dev/null
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/ResponseHeaders.java
@@ -0,0 +1,37 @@
+// ***************************************************************************************************************************
+// * 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.juneau.rest.annotation;
+
+import static java.lang.annotation.ElementType.*;
+import static java.lang.annotation.RetentionPolicy.*;
+
+import java.lang.annotation.*;
+
+/**
+ * Used to associate multiple {@link ResponseHeader @ResponseHeader} annotations to the same parameter or class.
+ *
+ * <p>
+ * Since Juneau currently prereq's Java 1.7, we cannot take advantage of annotation duplication support in Java 8.
+ * <br>This annotation overcomes that limitation.
+ */
+@Documented
+@Target({PARAMETER,TYPE})
+@Retention(RUNTIME)
+@Inherited
+public @interface ResponseHeaders {
+
+ /**
+ * Specifies one or more {@link ResponseHeader @ResponseHeader} annotations to apply to the same parameter or class.
+ */
+ ResponseHeader[] value() default {};
+}
\ No newline at end of file
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/util/RestUtils.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/util/RestUtils.java
index 14653c2..27a0ba3 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/util/RestUtils.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/util/RestUtils.java
@@ -41,6 +41,10 @@ public final class RestUtils {
}
private static Map<Integer,String> httpMsgs = new AMap<Integer,String>()
+ .append(100, "Continue")
+ .append(101, "Switching Protocols")
+ .append(102, "Processing")
+ .append(103, "Early Hints")
.append(200, "OK")
.append(201, "Created")
.append(202, "Accepted")
diff --git a/juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/BasicRestInfoProviderTest.java b/juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/BasicRestInfoProviderTest.java
index 7fd0152..d8f2780 100644
--- a/juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/BasicRestInfoProviderTest.java
+++ b/juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/BasicRestInfoProviderTest.java
@@ -19,14 +19,18 @@ import static org.apache.juneau.http.HttpMethodName.*;
import java.io.*;
import java.util.*;
+import org.apache.juneau.json.*;
+import org.apache.juneau.xml.*;
import org.apache.juneau.annotation.*;
import org.apache.juneau.dto.swagger.*;
import org.apache.juneau.rest.annotation.*;
import org.apache.juneau.rest.util.*;
import org.apache.juneau.utils.*;
import org.junit.*;
+import org.junit.runners.*;
@SuppressWarnings("javadoc")
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class BasicRestInfoProviderTest {
private Swagger getSwaggerWithFile(Object resource) throws Exception {
@@ -715,11 +719,11 @@ public class BasicRestInfoProviderTest {
}
//-----------------------------------------------------------------------------------------------------------------
- // /paths/<path>/<method>
+ // /paths/<path>/<method>/operationId
//-----------------------------------------------------------------------------------------------------------------
@RestResource()
- public static class M01 {
+ public static class MA01 {
@RestMethod(name=GET,path="/path/{foo}")
public Foo doFoo() {
@@ -728,13 +732,13 @@ public class BasicRestInfoProviderTest {
}
@Test
- public void m01_operation_default() throws Exception {
- assertObjectEquals("{operationId:'doFoo',responses:{'200':{description:'OK',schema:{type:'object',properties:{id:{format:'int32',type:'integer'}}}}}}", getSwagger(new M01()).getPaths().get("/path/{foo}").get("get"));
- assertObjectEquals("{operationId:'s-operationId',summary:'s-summary',description:'s-description',tags:['s-tag'],externalDocs:{description:'s-description',url:'s-url'},consumes:['s-consumes'],produces:['s-produces'],responses:{'200':{description:'OK',schema:{type:'object',properties:{id:{format:'int32',type:'integer'}}}}},schemes:['s-scheme'],deprecated:true}", getSwaggerWithFile(new M01()).getPaths().get("/path/{foo}").get("get"));
+ public void ma01_operation_operationId_default() throws Exception {
+ assertEquals("doFoo", getSwagger(new MA01()).getPaths().get("/path/{foo}").get("get").getOperationId());
+ assertEquals("s-operationId", getSwaggerWithFile(new MA01()).getPaths().get("/path/{foo}").get("get").getOperationId());
}
- @RestResource(swagger=@ResourceSwagger("{paths:{'/path/{foo}':{get:{summary:'a-summary',description:'a-description',operationId:'a-operationId',deprecated:true,consumes:['a-consumes'],produces:['a-produces'],tags:['a-tag'],schemes:['a-scheme'],externalDocs:{description: 'a-description',url: 'a-url'}}}}}"))
- public static class M02 {
+ @RestResource(swagger=@ResourceSwagger("paths:{'/path/{foo}':{get:{operationId:'a-operationId'}}}"))
+ public static class MA02 {
@RestMethod(name=GET,path="/path/{foo}")
public Foo doFoo() {
return null;
@@ -742,235 +746,2634 @@ public class BasicRestInfoProviderTest {
}
@Test
- public void m02_operation_swaggerOnClass() throws Exception {
- assertObjectEquals("{operationId:'a-operationId',summary:'a-summary',description:'a-description',tags:['a-tag'],externalDocs:{description:'a-description',url:'a-url'},consumes:['a-consumes'],produces:['a-produces'],responses:{'200':{description:'OK',schema:{type:'object',properties:{id:{format:'int32',type:'integer'}}}}},schemes:['a-scheme'],deprecated:true}", getSwagger(new M02()).getPaths().get("/path/{foo}").get("get"));
- assertObjectEquals("{operationId:'a-operationId',summary:'a-summary',description:'a-description',tags:['a-tag'],externalDocs:{description:'a-description',url:'a-url'},consumes:['a-consumes'],produces:['a-produces'],responses:{'200':{description:'OK',schema:{type:'object',properties:{id:{format:'int32',type:'integer'}}}}},schemes:['a-scheme'],deprecated:true}", getSwaggerWithFile(new M02()).getPaths().get("/path/{foo}").get("get"));
+ public void ma02_operation_operationId_swaggerOnClass() throws Exception {
+ assertEquals("a-operationId", getSwagger(new MA02()).getPaths().get("/path/{foo}").get("get").getOperationId());
+ assertEquals("a-operationId", getSwaggerWithFile(new MA02()).getPaths().get("/path/{foo}").get("get").getOperationId());
}
- @RestResource(swagger=@ResourceSwagger("{paths:{'/path/{foo}':{get:{summary:'a-summary',description:'a-description',operationId:'a-operationId',deprecated:true,consumes:['a-consumes'],produces:['a-produces'],tags:['a-tag'],schemes:['a-scheme'],externalDocs:{description:'a-description',url:'a-url'}}}}}"))
- public static class M03 {
- @RestMethod(name=GET,path="/path/{foo}",swagger=@MethodSwagger("summary:'b-summary',description:'b-description',operationId:'b-operationId',deprecated:false,consumes:['b-consumes'],produces:['b-produces'],tags:['b-tag'],schemes:['b-scheme'],externalDocs:{description:'b-description',url:'b-url'}}"))
+ @RestResource(swagger=@ResourceSwagger("paths:{'/path/{foo}':{get:{operationId:'a-operationId'}}}"))
+ public static class MA03 {
+ @RestMethod(name=GET,path="/path/{foo}",swagger=@MethodSwagger("operationId:'b-operationId'"))
public Foo doFoo() {
return null;
}
}
@Test
- public void m03_operation_swaggerOnMethod() throws Exception {
- assertObjectEquals("{operationId:'b-operationId',summary:'b-summary',description:'b-description',tags:['b-tag'],externalDocs:{description:'b-description',url:'b-url'},consumes:['b-consumes'],produces:['b-produces'],responses:{'200':{description:'OK',schema:{type:'object',properties:{id:{format:'int32',type:'integer'}}}}},schemes:['b-scheme'],deprecated:false}", getSwagger(new M03()).getPaths().get("/path/{foo}").get("get"));
- assertObjectEquals("{operationId:'b-operationId',summary:'b-summary',description:'b-description',tags:['b-tag'],externalDocs:{description:'b-description',url:'b-url'},consumes:['b-consumes'],produces:['b-produces'],responses:{'200':{description:'OK',schema:{type:'object',properties:{id:{format:'int32',type:'integer'}}}}},schemes:['b-scheme'],deprecated:false}", getSwaggerWithFile(new M03()).getPaths().get("/path/{foo}").get("get"));
+ public void ma03_operation_operationId_swaggerOnMethod() throws Exception {
+ assertEquals("b-operationId", getSwagger(new MA03()).getPaths().get("/path/{foo}").get("get").getOperationId());
+ assertEquals("b-operationId", getSwaggerWithFile(new MA03()).getPaths().get("/path/{foo}").get("get").getOperationId());
}
- @RestResource(swagger=@ResourceSwagger("{paths:{'/path/{foo}':{get:{summary:'a-summary',description:'a-description',operationId:'a-operationId',deprecated:true,consumes:['a-consumes'],produces:['a-produces'],tags:['a-tag'],schemes:['a-scheme'],externalDocs:{description:'a-description',url:'a-url'}}}}}"))
- public static class M04 {
- @RestMethod(name=GET,path="/path/{foo}",swagger=@MethodSwagger(summary="b-summary",description="b-description",operationId="b-operationId",deprecated="false",consumes="b-consumes",produces="b-produces",tags="b-tag",schemes="b-scheme",externalDocs="description:'b-description',url:'b-url'"))
+ @RestResource(swagger=@ResourceSwagger("paths:{'/path/{foo}':{get:{operationId:'a-operationId'}}}"))
+ public static class MA04 {
+ @RestMethod(name=GET,path="/path/{foo}",swagger=@MethodSwagger(operationId="c-operationId"))
public Foo doFoo() {
return null;
}
}
@Test
- public void m04_operation_swaggerOnAnnotation() throws Exception {
- assertObjectEquals("{operationId:'b-operationId',summary:'b-summary',description:'b-description',tags:['b-tag'],externalDocs:{description:'b-description',url:'b-url'},consumes:['b-consumes'],produces:['b-produces'],responses:{'200':{description:'OK',schema:{type:'object',properties:{id:{format:'int32',type:'integer'}}}}},schemes:['b-scheme'],deprecated:false}", getSwagger(new M04()).getPaths().get("/path/{foo}").get("get"));
- assertObjectEquals("{operationId:'b-operationId',summary:'b-summary',description:'b-description',tags:['b-tag'],externalDocs:{description:'b-description',url:'b-url'},consumes:['b-consumes'],produces:['b-produces'],responses:{'200':{description:'OK',schema:{type:'object',properties:{id:{format:'int32',type:'integer'}}}}},schemes:['b-scheme'],deprecated:false}", getSwaggerWithFile(new M04()).getPaths().get("/path/{foo}").get("get"));
+ public void ma04_operation_operationId_swaggerOnAnnotation() throws Exception {
+ assertEquals("c-operationId", getSwagger(new MA04()).getPaths().get("/path/{foo}").get("get").getOperationId());
+ assertEquals("c-operationId", getSwaggerWithFile(new MA04()).getPaths().get("/path/{foo}").get("get").getOperationId());
}
- @RestResource(messages="BasicRestInfoProviderTest", swagger=@ResourceSwagger("{paths:{'/path/{foo}':{get:{summary:'a-summary',description:'a-description',operationId:'a-operationId',deprecated:true,consumes:['a-consumes'],produces:['a-produces'],tags:['a-tag'],schemes:['a-scheme'],externalDocs:{description:'a-description',url:'a-url'}}}}}"))
- public static class M05 {
- @RestMethod(name=GET,path="/path/{foo}",swagger=@MethodSwagger(summary="$L{foo}",description="$L{foo}",operationId="$L{foo}",deprecated="$L{foo}",consumes="$L{foo}",produces="$L{foo}",tags="$L{foo}",schemes="$L{foo}",externalDocs="description:'$L{foo}',url:'$L{foo}'"))
+ @RestResource(messages="BasicRestInfoProviderTest", swagger=@ResourceSwagger("paths:{'/path/{foo}':{get:{operationId:'a-operationId'}}}"))
+ public static class MA05 {
+ @RestMethod(name=GET,path="/path/{foo}",swagger=@MethodSwagger(operationId="$L{foo}"))
public Foo doFoo() {
return null;
}
}
@Test
- public void m05_operation_swaggerOnAnnotation_localized() throws Exception {
- assertObjectEquals("{operationId:'l-foo',summary:'l-foo',description:'l-foo',tags:['l-foo'],externalDocs:{description:'l-foo',url:'l-foo'},consumes:['l-foo'],produces:['l-foo'],responses:{'200':{description:'OK',schema:{type:'object',properties:{id:{format:'int32',type:'integer'}}}}},schemes:['l-foo'],deprecated:false}", getSwagger(new M05()).getPaths().get("/path/{foo}").get("get"));
- assertObjectEquals("{operationId:'l-foo',summary:'l-foo',description:'l-foo',tags:['l-foo'],externalDocs:{description:'l-foo',url:'l-foo'},consumes:['l-foo'],produces:['l-foo'],responses:{'200':{description:'OK',schema:{type:'object',properties:{id:{format:'int32',type:'integer'}}}}},schemes:['l-foo'],deprecated:false}", getSwaggerWithFile(new M05()).getPaths().get("/path/{foo}").get("get"));
+ public void ma05_operation_operationId_swaggerOnAnnotation_localized() throws Exception {
+ assertEquals("l-foo", getSwagger(new MA05()).getPaths().get("/path/{foo}").get("get").getOperationId());
+ assertEquals("l-foo", getSwaggerWithFile(new MA05()).getPaths().get("/path/{foo}").get("get").getOperationId());
}
//-----------------------------------------------------------------------------------------------------------------
+ // /paths/<path>/<method>/summary
+ //-----------------------------------------------------------------------------------------------------------------
+
+ @RestResource()
+ public static class MB01 {
+
+ @RestMethod(name=GET,path="/path/{foo}")
+ public Foo doFoo() {
+ return null;
+ }
+ }
+
+ @Test
+ public void mb01_operation_summary_default() throws Exception {
+ assertEquals(null, getSwagger(new MB01()).getPaths().get("/path/{foo}").get("get").getSummary());
+ assertEquals("s-summary", getSwaggerWithFile(new MB01()).getPaths().get("/path/{foo}").get("get").getSummary());
+ }
+
+ @RestResource(swagger=@ResourceSwagger("paths:{'/path/{foo}':{get:{summary:'a-summary'}}}"))
+ public static class MB02 {
+ @RestMethod(name=GET,path="/path/{foo}")
+ public Foo doFoo() {
+ return null;
+ }
+ }
+
+ @Test
+ public void mb02_operation_summary_swaggerOnClass() throws Exception {
+ assertEquals("a-summary", getSwagger(new MB02()).getPaths().get("/path/{foo}").get("get").getSummary());
+ assertEquals("a-summary", getSwaggerWithFile(new MB02()).getPaths().get("/path/{foo}").get("get").getSummary());
+ }
+
+ @RestResource(swagger=@ResourceSwagger("paths:{'/path/{foo}':{get:{summary:'a-summary'}}}"))
+ public static class MB03 {
+ @RestMethod(name=GET,path="/path/{foo}",swagger=@MethodSwagger("summary:'b-summary'"))
+ public Foo doFoo() {
+ return null;
+ }
+ }
+
+ @Test
+ public void mb03_operation_summary_swaggerOnMethod() throws Exception {
+ assertEquals("b-summary", getSwagger(new MB03()).getPaths().get("/path/{foo}").get("get").getSummary());
+ assertEquals("b-summary", getSwaggerWithFile(new MB03()).getPaths().get("/path/{foo}").get("get").getSummary());
+ }
+
+ @RestResource(swagger=@ResourceSwagger("paths:{'/path/{foo}':{get:{summary:'a-summary'}}}"))
+ public static class MB04 {
+ @RestMethod(name=GET,path="/path/{foo}",swagger=@MethodSwagger(summary="c-summary"))
+ public Foo doFoo() {
+ return null;
+ }
+ }
+
+ @Test
+ public void mb04_operation_summary_swaggerOnAnnotation() throws Exception {
+ assertEquals("c-summary", getSwagger(new MB04()).getPaths().get("/path/{foo}").get("get").getSummary());
+ assertEquals("c-summary", getSwaggerWithFile(new MB04()).getPaths().get("/path/{foo}").get("get").getSummary());
+ }
+
+ @RestResource(messages="BasicRestInfoProviderTest", swagger=@ResourceSwagger("paths:{'/path/{foo}':{get:{summary:'a-summary'}}}"))
+ public static class MB05 {
+ @RestMethod(name=GET,path="/path/{foo}",swagger=@MethodSwagger(summary="$L{foo}"))
+ public Foo doFoo() {
+ return null;
+ }
+ }
+
+ @Test
+ public void mb05_operation_summary_swaggerOnAnnotation_localized() throws Exception {
+ assertEquals("l-foo", getSwagger(new MB05()).getPaths().get("/path/{foo}").get("get").getSummary());
+ assertEquals("l-foo", getSwaggerWithFile(new MB05()).getPaths().get("/path/{foo}").get("get").getSummary());
+ }
+
+ @RestResource(swagger=@ResourceSwagger("paths:{'/path/{foo}':{get:{summary:'a-summary'}}}"))
+ public static class MB06 {
+ @RestMethod(name=GET,path="/path/{foo}",summary="d-summary")
+ public Foo doFoo() {
+ return null;
+ }
+ }
+
+ @Test
+ public void mb06_operation_summary_RestMethod() throws Exception {
+ assertEquals("a-summary", getSwagger(new MB06()).getPaths().get("/path/{foo}").get("get").getSummary());
+ assertEquals("a-summary", getSwaggerWithFile(new MB06()).getPaths().get("/path/{foo}").get("get").getSummary());
+ }
+
+ @RestResource(swagger=@ResourceSwagger("paths:{'/path/{foo}':{get:{}}}"))
+ public static class MB07 {
+ @RestMethod(name=GET,path="/path/{foo}",summary="d-summary")
+ public Foo doFoo() {
+ return null;
+ }
+ }
+
+ @Test
+ public void mb07_operation_summary_RestMethod() throws Exception {
+ assertEquals("d-summary", getSwagger(new MB07()).getPaths().get("/path/{foo}").get("get").getSummary());
+ assertEquals("d-summary", getSwaggerWithFile(new MB07()).getPaths().get("/path/{foo}").get("get").getSummary());
+ }
+
+ //-----------------------------------------------------------------------------------------------------------------
// /paths/<path>/<method>/description
//-----------------------------------------------------------------------------------------------------------------
+
+ @RestResource()
+ public static class MC01 {
+
+ @RestMethod(name=GET,path="/path/{foo}")
+ public Foo doFoo() {
+ return null;
+ }
+ }
+
+ @Test
+ public void mc01_operation_description_default() throws Exception {
+ assertEquals(null, getSwagger(new MC01()).getPaths().get("/path/{foo}").get("get").getDescription());
+ assertEquals("s-description", getSwaggerWithFile(new MC01()).getPaths().get("/path/{foo}").get("get").getDescription());
+ }
+
+ @RestResource(swagger=@ResourceSwagger("paths:{'/path/{foo}':{get:{description:'a-description'}}}"))
+ public static class MC02 {
+ @RestMethod(name=GET,path="/path/{foo}")
+ public Foo doFoo() {
+ return null;
+ }
+ }
+
+ @Test
+ public void mc02_operation_description_swaggerOnClass() throws Exception {
+ assertEquals("a-description", getSwagger(new MC02()).getPaths().get("/path/{foo}").get("get").getDescription());
+ assertEquals("a-description", getSwaggerWithFile(new MC02()).getPaths().get("/path/{foo}").get("get").getDescription());
+ }
+
+ @RestResource(swagger=@ResourceSwagger("paths:{'/path/{foo}':{get:{description:'a-description'}}}"))
+ public static class MC03 {
+ @RestMethod(name=GET,path="/path/{foo}",swagger=@MethodSwagger("description:'b-description'"))
+ public Foo doFoo() {
+ return null;
+ }
+ }
+
+ @Test
+ public void mc03_operation_description_swaggerOnMethod() throws Exception {
+ assertEquals("b-description", getSwagger(new MC03()).getPaths().get("/path/{foo}").get("get").getDescription());
+ assertEquals("b-description", getSwaggerWithFile(new MC03()).getPaths().get("/path/{foo}").get("get").getDescription());
+ }
+
+ @RestResource(swagger=@ResourceSwagger("paths:{'/path/{foo}':{get:{description:'a-description'}}}"))
+ public static class MC04 {
+ @RestMethod(name=GET,path="/path/{foo}",swagger=@MethodSwagger(description="c-description"))
+ public Foo doFoo() {
+ return null;
+ }
+ }
+
+ @Test
+ public void mc04_operation_description_swaggerOnAnnotation() throws Exception {
+ assertEquals("c-description", getSwagger(new MC04()).getPaths().get("/path/{foo}").get("get").getDescription());
+ assertEquals("c-description", getSwaggerWithFile(new MC04()).getPaths().get("/path/{foo}").get("get").getDescription());
+ }
+
+ @RestResource(messages="BasicRestInfoProviderTest", swagger=@ResourceSwagger("paths:{'/path/{foo}':{get:{description:'a-description'}}}"))
+ public static class MC05 {
+ @RestMethod(name=GET,path="/path/{foo}",swagger=@MethodSwagger(description="$L{foo}"))
+ public Foo doFoo() {
+ return null;
+ }
+ }
+
+ @Test
+ public void mc05_operation_description_swaggerOnAnnotation_localized() throws Exception {
+ assertEquals("l-foo", getSwagger(new MC05()).getPaths().get("/path/{foo}").get("get").getDescription());
+ assertEquals("l-foo", getSwaggerWithFile(new MC05()).getPaths().get("/path/{foo}").get("get").getDescription());
+ }
+
+ @RestResource(swagger=@ResourceSwagger("paths:{'/path/{foo}':{get:{description:'a-description'}}}"))
+ public static class MC06 {
+ @RestMethod(name=GET,path="/path/{foo}",description="d-description")
+ public Foo doFoo() {
+ return null;
+ }
+ }
+
+ @Test
+ public void mc06_operation_description_RestMethod() throws Exception {
+ assertEquals("a-description", getSwagger(new MC06()).getPaths().get("/path/{foo}").get("get").getDescription());
+ assertEquals("a-description", getSwaggerWithFile(new MC06()).getPaths().get("/path/{foo}").get("get").getDescription());
+ }
+
+ @RestResource(swagger=@ResourceSwagger("paths:{'/path/{foo}':{get:{}}}"))
+ public static class MC07 {
+ @RestMethod(name=GET,path="/path/{foo}",description="d-description")
+ public Foo doFoo() {
+ return null;
+ }
+ }
+
+ @Test
+ public void mc07_operation_description_RestMethod() throws Exception {
+ assertEquals("d-description", getSwagger(new MC07()).getPaths().get("/path/{foo}").get("get").getDescription());
+ assertEquals("d-description", getSwaggerWithFile(new MC07()).getPaths().get("/path/{foo}").get("get").getDescription());
+ }
+
+ //-----------------------------------------------------------------------------------------------------------------
+ // /paths/<path>/<method>/tags
+ //-----------------------------------------------------------------------------------------------------------------
+
+ @RestResource()
+ public static class MD01 {
+
+ @RestMethod(name=GET,path="/path/{foo}")
+ public Foo doFoo() {
+ return null;
+ }
+ }
+
+ @Test
+ public void md01_operation_tags_default() throws Exception {
+ assertObjectEquals("null", getSwagger(new MD01()).getPaths().get("/path/{foo}").get("get").getTags());
+ assertObjectEquals("['s-tag']", getSwaggerWithFile(new MD01()).getPaths().get("/path/{foo}").get("get").getTags());
+ }
+
+ @RestResource(swagger=@ResourceSwagger("paths:{'/path/{foo}':{get:{tags:['a-tag']}}}"))
+ public static class MD02 {
+ @RestMethod(name=GET,path="/path/{foo}")
+ public Foo doFoo() {
+ return null;
+ }
+ }
+
+ @Test
+ public void md02_operation_tags_swaggerOnClass() throws Exception {
+ assertObjectEquals("['a-tag']", getSwagger(new MD02()).getPaths().get("/path/{foo}").get("get").getTags());
+ assertObjectEquals("['a-tag']", getSwaggerWithFile(new MD02()).getPaths().get("/path/{foo}").get("get").getTags());
+ }
+
+ @RestResource(swagger=@ResourceSwagger("paths:{'/path/{foo}':{get:{tags:['a-tag']}}}"))
+ public static class MD03 {
+ @RestMethod(name=GET,path="/path/{foo}",swagger=@MethodSwagger("tags:['b-tag']"))
+ public Foo doFoo() {
+ return null;
+ }
+ }
+
+ @Test
+ public void md03_operation_tags_swaggerOnMethod() throws Exception {
+ assertObjectEquals("['b-tag']", getSwagger(new MD03()).getPaths().get("/path/{foo}").get("get").getTags());
+ assertObjectEquals("['b-tag']", getSwaggerWithFile(new MD03()).getPaths().get("/path/{foo}").get("get").getTags());
+ }
+
+ @RestResource(swagger=@ResourceSwagger("paths:{'/path/{foo}':{get:{tags:['a-tag']}}}"))
+ public static class MD04a {
+ @RestMethod(name=GET,path="/path/{foo}",swagger=@MethodSwagger(tags="['c-tag-1','c-tag-2']"))
+ public Foo doFoo() {
+ return null;
+ }
+ }
+
+ @Test
+ public void md04a_operation_tags_swaggerOnAnnotation() throws Exception {
+ assertObjectEquals("['c-tag-1','c-tag-2']", getSwagger(new MD04a()).getPaths().get("/path/{foo}").get("get").getTags());
+ assertObjectEquals("['c-tag-1','c-tag-2']", getSwaggerWithFile(new MD04a()).getPaths().get("/path/{foo}").get("get").getTags());
+ }
+
+ @RestResource(swagger=@ResourceSwagger("paths:{'/path/{foo}':{get:{tags:['a-tag']}}}"))
+ public static class MD04b {
+ @RestMethod(name=GET,path="/path/{foo}",swagger=@MethodSwagger(tags="c-tag-1, c-tag-2"))
+ public Foo doFoo() {
+ return null;
+ }
+ }
+
+ @Test
+ public void md04b_operation_tags_swaggerOnAnnotation() throws Exception {
+ assertObjectEquals("['c-tag-1','c-tag-2']", getSwagger(new MD04b()).getPaths().get("/path/{foo}").get("get").getTags());
+ assertObjectEquals("['c-tag-1','c-tag-2']", getSwaggerWithFile(new MD04b()).getPaths().get("/path/{foo}").get("get").getTags());
+ }
+
+ @RestResource(messages="BasicRestInfoProviderTest", swagger=@ResourceSwagger("paths:{'/path/{foo}':{get:{tags:'a-tags'}}}"))
+ public static class MD05 {
+ @RestMethod(name=GET,path="/path/{foo}",swagger=@MethodSwagger(tags="$L{foo}"))
+ public Foo doFoo() {
+ return null;
+ }
+ }
+
+ @Test
+ public void md05_operation_tags_swaggerOnAnnotation_localized() throws Exception {
+ assertObjectEquals("['l-foo']", getSwagger(new MD05()).getPaths().get("/path/{foo}").get("get").getTags());
+ assertObjectEquals("['l-foo']", getSwaggerWithFile(new MD05()).getPaths().get("/path/{foo}").get("get").getTags());
+ }
+
+ //-----------------------------------------------------------------------------------------------------------------
+ // /paths/<path>/<method>/externalDocs
+ //-----------------------------------------------------------------------------------------------------------------
+
+ @RestResource()
+ public static class ME01 {
+
+ @RestMethod(name=GET,path="/path/{foo}")
+ public Foo doFoo() {
+ return null;
+ }
+ }
+
+ @Test
+ public void me01_operation_externalDocs_default() throws Exception {
+ assertObjectEquals("null", getSwagger(new ME01()).getPaths().get("/path/{foo}").get("get").getExternalDocs());
+ assertObjectEquals("{description:'s-description',url:'s-url'}", getSwaggerWithFile(new ME01()).getPaths().get("/path/{foo}").get("get").getExternalDocs());
+ }
+
+ @RestResource(swagger=@ResourceSwagger("paths:{'/path/{foo}':{get:{externalDocs:{description:'a-description',url:'a-url'}}}}"))
+ public static class ME02 {
+ @RestMethod(name=GET,path="/path/{foo}")
+ public Foo doFoo() {
+ return null;
+ }
+ }
+
+ @Test
+ public void me02_operation_externalDocs_swaggerOnClass() throws Exception {
+ assertObjectEquals("{description:'a-description',url:'a-url'}", getSwagger(new ME02()).getPaths().get("/path/{foo}").get("get").getExternalDocs());
+ assertObjectEquals("{description:'a-description',url:'a-url'}", getSwaggerWithFile(new ME02()).getPaths().get("/path/{foo}").get("get").getExternalDocs());
+ }
+
+ @RestResource(swagger=@ResourceSwagger("paths:{'/path/{foo}':{get:{externalDocs:{description:'a-description',url:'a-url'}}}}"))
+ public static class ME03 {
+ @RestMethod(name=GET,path="/path/{foo}",swagger=@MethodSwagger("externalDocs:{description:'b-description',url:'b-url'}"))
+ public Foo doFoo() {
+ return null;
+ }
+ }
+
+ @Test
+ public void me03_operation_externalDocs_swaggerOnMethod() throws Exception {
+ assertObjectEquals("{description:'b-description',url:'b-url'}", getSwagger(new ME03()).getPaths().get("/path/{foo}").get("get").getExternalDocs());
+ assertObjectEquals("{description:'b-description',url:'b-url'}", getSwaggerWithFile(new ME03()).getPaths().get("/path/{foo}").get("get").getExternalDocs());
+ }
+
+ @RestResource(swagger=@ResourceSwagger("paths:{'/path/{foo}':{get:{externalDocs:{description:'a-description',url:'a-url'}}}}"))
+ public static class ME04a {
+ @RestMethod(name=GET,path="/path/{foo}",swagger=@MethodSwagger(externalDocs="description:'c-description',url:'c-url'"))
+ public Foo doFoo() {
+ return null;
+ }
+ }
+
+ @Test
+ public void me04a_operation_externalDocs_swaggerOnAnnotation() throws Exception {
+ assertObjectEquals("{description:'c-description',url:'c-url'}", getSwagger(new ME04a()).getPaths().get("/path/{foo}").get("get").getExternalDocs());
+ assertObjectEquals("{description:'c-description',url:'c-url'}", getSwaggerWithFile(new ME04a()).getPaths().get("/path/{foo}").get("get").getExternalDocs());
+ }
+
+ @RestResource(swagger=@ResourceSwagger("paths:{'/path/{foo}':{get:{externalDocs:{description:'a-description',url:'a-url'}}}}"))
+ public static class ME04b {
+ @RestMethod(name=GET,path="/path/{foo}",swagger=@MethodSwagger(externalDocs="{description:'d-description',url:'d-url'}"))
+ public Foo doFoo() {
+ return null;
+ }
+ }
+
+ @Test
+ public void me04b_operation_externalDocs_swaggerOnAnnotation() throws Exception {
+ assertObjectEquals("{description:'d-description',url:'d-url'}", getSwagger(new ME04b()).getPaths().get("/path/{foo}").get("get").getExternalDocs());
+ assertObjectEquals("{description:'d-description',url:'d-url'}", getSwaggerWithFile(new ME04b()).getPaths().get("/path/{foo}").get("get").getExternalDocs());
+ }
+
+ @RestResource(messages="BasicRestInfoProviderTest", swagger=@ResourceSwagger("paths:{'/path/{foo}':{get:{externalDocs:{description:'a-description',url:'a-url'}}}}"))
+ public static class ME05 {
+ @RestMethod(name=GET,path="/path/{foo}",swagger=@MethodSwagger(externalDocs="{description:'$L{foo}',url:'$L{foo}'}"))
+ public Foo doFoo() {
+ return null;
+ }
+ }
+
+ @Test
+ public void me05_operation_externalDocs_swaggerOnAnnotation_localized() throws Exception {
+ assertObjectEquals("{description:'l-foo',url:'l-foo'}", getSwagger(new ME05()).getPaths().get("/path/{foo}").get("get").getExternalDocs());
+ assertObjectEquals("{description:'l-foo',url:'l-foo'}", getSwaggerWithFile(new ME05()).getPaths().get("/path/{foo}").get("get").getExternalDocs());
+ }
+
+ //-----------------------------------------------------------------------------------------------------------------
+ // /paths/<path>/<method>/consumes
+ //-----------------------------------------------------------------------------------------------------------------
+
+ @RestResource()
+ public static class MF01 {
+
+ @RestMethod(name=GET,path="/path/{foo}")
+ public Foo doFoo() {
+ return null;
+ }
+ }
+
+ @Test
+ public void mf01_operation_consumes_default() throws Exception {
+ assertObjectEquals("null", getSwagger(new MF01()).getPaths().get("/path/{foo}").get("get").getConsumes());
+ assertObjectEquals("['s-consumes']", getSwaggerWithFile(new MF01()).getPaths().get("/path/{foo}").get("get").getConsumes());
+ }
+
+ @RestResource(swagger=@ResourceSwagger("paths:{'/path/{foo}':{get:{consumes:['a-consumes']}}}"))
+ public static class MF02 {
+ @RestMethod(name=GET,path="/path/{foo}")
+ public Foo doFoo() {
+ return null;
+ }
+ }
+
+ @Test
+ public void mf02_operation_consumes_swaggerOnClass() throws Exception {
+ assertObjectEquals("['a-consumes']", getSwagger(new MF02()).getPaths().get("/path/{foo}").get("get").getConsumes());
+ assertObjectEquals("['a-consumes']", getSwaggerWithFile(new MF02()).getPaths().get("/path/{foo}").get("get").getConsumes());
+ }
+
+ @RestResource(swagger=@ResourceSwagger("paths:{'/path/{foo}':{get:{consumes:['a-consumes']}}}"))
+ public static class MF03 {
+ @RestMethod(name=GET,path="/path/{foo}",swagger=@MethodSwagger("consumes:['b-consumes']"))
+ public Foo doFoo() {
+ return null;
+ }
+ }
+
+ @Test
+ public void mf03_operation_consumes_swaggerOnMethod() throws Exception {
+ assertObjectEquals("['b-consumes']", getSwagger(new MF03()).getPaths().get("/path/{foo}").get("get").getConsumes());
+ assertObjectEquals("['b-consumes']", getSwaggerWithFile(new MF03()).getPaths().get("/path/{foo}").get("get").getConsumes());
+ }
+
+ @RestResource(swagger=@ResourceSwagger("paths:{'/path/{foo}':{get:{consumes:['a-consumes']}}}"))
+ public static class MF04a {
+ @RestMethod(name=GET,path="/path/{foo}",swagger=@MethodSwagger(consumes="['c-consumes-1','c-consumes-2']"))
+ public Foo doFoo() {
+ return null;
+ }
+ }
+
+ @Test
+ public void mf04a_operation_consumes_swaggerOnAnnotation() throws Exception {
+ assertObjectEquals("['c-consumes-1','c-consumes-2']", getSwagger(new MF04a()).getPaths().get("/path/{foo}").get("get").getConsumes());
+ assertObjectEquals("['c-consumes-1','c-consumes-2']", getSwaggerWithFile(new MF04a()).getPaths().get("/path/{foo}").get("get").getConsumes());
+ }
+
+ @RestResource(swagger=@ResourceSwagger("paths:{'/path/{foo}':{get:{consumes:['a-consumes']}}}"))
+ public static class MF04b {
+ @RestMethod(name=GET,path="/path/{foo}",swagger=@MethodSwagger(consumes="c-consumes-1, c-consumes-2"))
+ public Foo doFoo() {
+ return null;
+ }
+ }
+
+ @Test
+ public void mf04b_operation_consumes_swaggerOnAnnotation() throws Exception {
+ assertObjectEquals("['c-consumes-1','c-consumes-2']", getSwagger(new MF04b()).getPaths().get("/path/{foo}").get("get").getConsumes());
+ assertObjectEquals("['c-consumes-1','c-consumes-2']", getSwaggerWithFile(new MF04b()).getPaths().get("/path/{foo}").get("get").getConsumes());
+ }
+
+ @RestResource(messages="BasicRestInfoProviderTest", swagger=@ResourceSwagger("paths:{'/path/{foo}':{get:{consumes:['a-consumes']}}}"))
+ public static class MF05 {
+ @RestMethod(name=GET,path="/path/{foo}",swagger=@MethodSwagger(consumes="['$L{foo}']"))
+ public Foo doFoo() {
+ return null;
+ }
+ }
+
+ @Test
+ public void me05_operation_consumes_swaggerOnAnnotation_localized() throws Exception {
+ assertObjectEquals("['l-foo']", getSwagger(new MF05()).getPaths().get("/path/{foo}").get("get").getConsumes());
+ assertObjectEquals("['l-foo']", getSwaggerWithFile(new MF05()).getPaths().get("/path/{foo}").get("get").getConsumes());
+ }
+
+ @RestResource(parsers={JsonParser.class})
+ public static class MF06a {
+ @RestMethod(name=PUT,path="/path2/{foo}")
+ public Foo doFoo() {
+ return null;
+ }
+ }
+
+ @Test
+ public void mf06a_operation_consumes_parsersOnClass() throws Exception {
+ assertObjectEquals("null", getSwagger(new MF06a()).getPaths().get("/path2/{foo}").get("put").getConsumes());
+ assertObjectEquals("null", getSwaggerWithFile(new MF06a()).getPaths().get("/path2/{foo}").get("put").getConsumes());
+ }
+
+ @RestResource(parsers={JsonParser.class})
+ public static class MF06b {
+ @RestMethod(name=PUT,path="/path2/{foo}",parsers={XmlParser.class})
+ public Foo doFoo() {
+ return null;
+ }
+ }
+
+ @Test
+ public void mf06b_operation_consumes_parsersOnClassAndMethod() throws Exception {
+ assertObjectEquals("['text/xml','application/xml']", getSwagger(new MF06b()).getPaths().get("/path2/{foo}").get("put").getConsumes());
+ assertObjectEquals("['text/xml','application/xml']", getSwaggerWithFile(new MF06b()).getPaths().get("/path2/{foo}").get("put").getConsumes());
+ }
+
+ @RestResource(parsers={JsonParser.class},swagger=@ResourceSwagger("paths:{'/path2/{foo}':{put:{consumes:['a-consumes']}}}"))
+ public static class MF06c {
+ @RestMethod(name=PUT,path="/path2/{foo}",parsers={XmlParser.class})
+ public Foo doFoo() {
+ return null;
+ }
+ }
+
+ @Test
+ public void mf06c_operation_consumes_parsersOnClassAndMethodWithSwagger() throws Exception {
+ assertObjectEquals("['a-consumes']", getSwagger(new MF06c()).getPaths().get("/path2/{foo}").get("put").getConsumes());
+ assertObjectEquals("['a-consumes']", getSwaggerWithFile(new MF06c()).getPaths().get("/path2/{foo}").get("put").getConsumes());
+ }
+
+ //-----------------------------------------------------------------------------------------------------------------
+ // /paths/<path>/<method>/produces
+ //-----------------------------------------------------------------------------------------------------------------
+
+ @RestResource()
+ public static class MG01 {
+
+ @RestMethod(name=GET,path="/path/{foo}")
+ public Foo doFoo() {
+ return null;
+ }
+ }
+
+ @Test
+ public void mg01_operation_produces_default() throws Exception {
+ assertObjectEquals("null", getSwagger(new MG01()).getPaths().get("/path/{foo}").get("get").getProduces());
+ assertObjectEquals("['s-produces']", getSwaggerWithFile(new MG01()).getPaths().get("/path/{foo}").get("get").getProduces());
+ }
+
+ @RestResource(swagger=@ResourceSwagger("paths:{'/path/{foo}':{get:{produces:['a-produces']}}}"))
+ public static class MG02 {
+ @RestMethod(name=GET,path="/path/{foo}")
+ public Foo doFoo() {
+ return null;
+ }
+ }
+
+ @Test
+ public void mg02_operation_produces_swaggerOnClass() throws Exception {
+ assertObjectEquals("['a-produces']", getSwagger(new MG02()).getPaths().get("/path/{foo}").get("get").getProduces());
+ assertObjectEquals("['a-produces']", getSwaggerWithFile(new MG02()).getPaths().get("/path/{foo}").get("get").getProduces());
+ }
+
+ @RestResource(swagger=@ResourceSwagger("paths:{'/path/{foo}':{get:{produces:['a-produces']}}}"))
+ public static class MG03 {
+ @RestMethod(name=GET,path="/path/{foo}",swagger=@MethodSwagger("produces:['b-produces']"))
+ public Foo doFoo() {
+ return null;
+ }
+ }
+
+ @Test
+ public void mg03_operation_produces_swaggerOnMethod() throws Exception {
+ assertObjectEquals("['b-produces']", getSwagger(new MG03()).getPaths().get("/path/{foo}").get("get").getProduces());
+ assertObjectEquals("['b-produces']", getSwaggerWithFile(new MG03()).getPaths().get("/path/{foo}").get("get").getProduces());
+ }
+
+ @RestResource(swagger=@ResourceSwagger("paths:{'/path/{foo}':{get:{produces:['a-produces']}}}"))
+ public static class MG04a {
+ @RestMethod(name=GET,path="/path/{foo}",swagger=@MethodSwagger(produces="['c-produces-1','c-produces-2']"))
+ public Foo doFoo() {
+ return null;
+ }
+ }
+
+ @Test
+ public void mg04a_operation_produces_swaggerOnAnnotation() throws Exception {
+ assertObjectEquals("['c-produces-1','c-produces-2']", getSwagger(new MG04a()).getPaths().get("/path/{foo}").get("get").getProduces());
+ assertObjectEquals("['c-produces-1','c-produces-2']", getSwaggerWithFile(new MG04a()).getPaths().get("/path/{foo}").get("get").getProduces());
+ }
+
+ @RestResource(swagger=@ResourceSwagger("paths:{'/path/{foo}':{get:{produces:['a-produces']}}}"))
+ public static class MG04b {
+ @RestMethod(name=GET,path="/path/{foo}",swagger=@MethodSwagger(produces="c-produces-1, c-produces-2"))
+ public Foo doFoo() {
+ return null;
+ }
+ }
+
+ @Test
+ public void mg04b_operation_produces_swaggerOnAnnotation() throws Exception {
+ assertObjectEquals("['c-produces-1','c-produces-2']", getSwagger(new MG04b()).getPaths().get("/path/{foo}").get("get").getProduces());
+ assertObjectEquals("['c-produces-1','c-produces-2']", getSwaggerWithFile(new MG04b()).getPaths().get("/path/{foo}").get("get").getProduces());
+ }
+
+ @RestResource(messages="BasicRestInfoProviderTest", swagger=@ResourceSwagger("paths:{'/path/{foo}':{get:{produces:['a-produces']}}}"))
+ public static class MG05 {
+ @RestMethod(name=GET,path="/path/{foo}",swagger=@MethodSwagger(produces="['$L{foo}']"))
+ public Foo doFoo() {
+ return null;
+ }
+ }
+
+ @Test
+ public void mg05_operation_produces_swaggerOnAnnotation_localized() throws Exception {
+ assertObjectEquals("['l-foo']", getSwagger(new MG05()).getPaths().get("/path/{foo}").get("get").getProduces());
+ assertObjectEquals("['l-foo']", getSwaggerWithFile(new MG05()).getPaths().get("/path/{foo}").get("get").getProduces());
+ }
+
+ @RestResource(serializers={JsonSerializer.class})
+ public static class MG06a {
+ @RestMethod(name=PUT,path="/path2/{foo}")
+ public Foo doFoo() {
+ return null;
+ }
+ }
+
+ @Test
+ public void mg06a_operation_produces_serializersOnClass() throws Exception {
+ assertObjectEquals("null", getSwagger(new MG06a()).getPaths().get("/path2/{foo}").get("put").getProduces());
+ assertObjectEquals("null", getSwaggerWithFile(new MG06a()).getPaths().get("/path2/{foo}").get("put").getProduces());
+ }
+
+ @RestResource(serializers={JsonSerializer.class})
+ public static class MG06b {
+ @RestMethod(name=PUT,path="/path2/{foo}",serializers={XmlSerializer.class})
+ public Foo doFoo() {
+ return null;
+ }
+ }
+
+ @Test
+ public void mg06b_operation_produces_serializersOnClassAndMethod() throws Exception {
+ assertObjectEquals("['text/xml']", getSwagger(new MG06b()).getPaths().get("/path2/{foo}").get("put").getProduces());
+ assertObjectEquals("['text/xml']", getSwaggerWithFile(new MG06b()).getPaths().get("/path2/{foo}").get("put").getProduces());
+ }
+
+ @RestResource(serializers={JsonSerializer.class},swagger=@ResourceSwagger("paths:{'/path2/{foo}':{put:{produces:['a-produces']}}}"))
+ public static class MG06c {
+ @RestMethod(name=PUT,path="/path2/{foo}",serializers={XmlSerializer.class})
+ public Foo doFoo() {
+ return null;
+ }
+ }
+
+ @Test
+ public void mg06c_operation_produces_serializersOnClassAndMethodWithSwagger() throws Exception {
+ assertObjectEquals("['a-produces']", getSwagger(new MG06c()).getPaths().get("/path2/{foo}").get("put").getProduces());
+ assertObjectEquals("['a-produces']", getSwaggerWithFile(new MG06c()).getPaths().get("/path2/{foo}").get("put").getProduces());
+ }
+
+ //-----------------------------------------------------------------------------------------------------------------
+ // /paths/<path>/<method>/deprecated
+ //-----------------------------------------------------------------------------------------------------------------
+
+ @RestResource()
+ public static class MH01 {
+ @RestMethod(name=GET,path="/path/{foo}")
+ public Foo doFoo() {
+ return null;
+ }
+ }
+
+ @Test
+ public void mh01_operation_deprecated_default() throws Exception {
+ assertEquals(null, getSwagger(new MH01()).getPaths().get("/path/{foo}").get("get").getDeprecated());
+ assertObjectEquals("true", getSwaggerWithFile(new MH01()).getPaths().get("/path/{foo}").get("get").getDeprecated());
+ }
+
+ @RestResource(swagger=@ResourceSwagger("paths:{'/path/{foo}':{get:{deprecated:false}}}"))
+ public static class MH02 {
+ @RestMethod(name=GET,path="/path/{foo}")
+ public Foo doFoo() {
+ return null;
+ }
+ }
+
+ @Test
+ public void mh02_operation_deprecated_swaggerOnClass() throws Exception {
+ assertObjectEquals("false", getSwagger(new MH02()).getPaths().get("/path/{foo}").get("get").getDeprecated());
+ assertObjectEquals("false", getSwaggerWithFile(new MH02()).getPaths().get("/path/{foo}").get("get").getDeprecated());
+ }
+
+ @RestResource(swagger=@ResourceSwagger("paths:{'/path/{foo}':{get:{deprecated:false}}}"))
+ public static class MH03 {
+ @RestMethod(name=GET,path="/path/{foo}",swagger=@MethodSwagger("deprecated:false"))
+ public Foo doFoo() {
+ return null;
+ }
+ }
+
+ @Test
+ public void mh03_operation_deprecated_swaggerOnMethod() throws Exception {
+ assertObjectEquals("false", getSwagger(new MH03()).getPaths().get("/path/{foo}").get("get").getDeprecated());
+ assertObjectEquals("false", getSwaggerWithFile(new MH03()).getPaths().get("/path/{foo}").get("get").getDeprecated());
+ }
+
+ @RestResource(swagger=@ResourceSwagger("paths:{'/path/{foo}':{get:{deprecated:false}}}"))
+ public static class MH04 {
+ @RestMethod(name=GET,path="/path/{foo}",swagger=@MethodSwagger(deprecated="false"))
+ public Foo doFoo() {
+ return null;
+ }
+ }
+
+ @Test
+ public void mh04_operation_deprecated_swaggerOnAnnotation() throws Exception {
+ assertObjectEquals("false", getSwagger(new MH04()).getPaths().get("/path/{foo}").get("get").getDeprecated());
+ assertObjectEquals("false", getSwaggerWithFile(new MH04()).getPaths().get("/path/{foo}").get("get").getDeprecated());
+ }
+
+ @RestResource(messages="BasicRestInfoProviderTest", swagger=@ResourceSwagger("paths:{'/path/{foo}':{get:{deprecated:false}}}"))
+ public static class MH05 {
+ @RestMethod(name=GET,path="/path/{foo}",swagger=@MethodSwagger(deprecated="$L{false}"))
+ public Foo doFoo() {
+ return null;
+ }
+ }
+
+ @Test
+ public void mh05_operation_deprecated_swaggerOnAnnotation_localized() throws Exception {
+ assertObjectEquals("false", getSwagger(new MH05()).getPaths().get("/path/{foo}").get("get").getDeprecated());
+ assertObjectEquals("false", getSwaggerWithFile(new MH05()).getPaths().get("/path/{foo}").get("get").getDeprecated());
+ }
+
+ @RestResource()
+ public static class MH06 {
+ @RestMethod(name=GET,path="/path2/{foo}")
+ @Deprecated
+ public Foo doFoo() {
+ return null;
+ }
+ }
+
+ @Test
+ public void mh06_operation_deprecated_Deprecated() throws Exception {
+ assertObjectEquals("true", getSwagger(new MH06()).getPaths().get("/path2/{foo}").get("get").getDeprecated());
+ assertObjectEquals("true", getSwaggerWithFile(new MH06()).getPaths().get("/path2/{foo}").get("get").getDeprecated());
+ }
+
+ @RestResource()
+ @Deprecated
+ public static class MH07 {
+ @RestMethod(name=GET,path="/path2/{foo}")
+ public Foo doFoo() {
+ return null;
+ }
+ }
+
+ @Test
+ public void mh07_operation_deprecated_Deprecated() throws Exception {
+ assertObjectEquals("true", getSwagger(new MH07()).getPaths().get("/path2/{foo}").get("get").getDeprecated());
+ assertObjectEquals("true", getSwaggerWithFile(new MH07()).getPaths().get("/path2/{foo}").get("get").getDeprecated());
+ }
+
+ //-----------------------------------------------------------------------------------------------------------------
+ // /paths/<path>/<method>/schemes
+ //-----------------------------------------------------------------------------------------------------------------
+
+ @RestResource()
+ public static class MI01 {
+ @RestMethod(name=GET,path="/path/{foo}")
+ public Foo doFoo() {
+ return null;
+ }
+ }
+
+ @Test
+ public void mi01_operation_schemes_default() throws Exception {
+ assertEquals(null, getSwagger(new MI01()).getPaths().get("/path/{foo}").get("get").getSchemes());
+ assertObjectEquals("['s-scheme']", getSwaggerWithFile(new MI01()).getPaths().get("/path/{foo}").get("get").getSchemes());
+ }
+
+ @RestResource(swagger=@ResourceSwagger("paths:{'/path/{foo}':{get:{schemes:['a-scheme']}}}"))
+ public static class MI02 {
+ @RestMethod(name=GET,path="/path/{foo}")
+ public Foo doFoo() {
+ return null;
+ }
+ }
+
+ @Test
+ public void mi02_operation_schemes_swaggerOnClass() throws Exception {
+ assertObjectEquals("['a-scheme']", getSwagger(new MI02()).getPaths().get("/path/{foo}").get("get").getSchemes());
+ assertObjectEquals("['a-scheme']", getSwaggerWithFile(new MI02()).getPaths().get("/path/{foo}").get("get").getSchemes());
+ }
+
+ @RestResource(swagger=@ResourceSwagger("paths:{'/path/{foo}':{get:{schemes:['a-scheme']}}}"))
+ public static class MI03 {
+ @RestMethod(name=GET,path="/path/{foo}",swagger=@MethodSwagger("schemes:['b-scheme']"))
+ public Foo doFoo() {
+ return null;
+ }
+ }
+
+ @Test
+ public void mi03_operation_schemes_swaggerOnMethod() throws Exception {
+ assertObjectEquals("['b-scheme']", getSwagger(new MI03()).getPaths().get("/path/{foo}").get("get").getSchemes());
+ assertObjectEquals("['b-scheme']", getSwaggerWithFile(new MI03()).getPaths().get("/path/{foo}").get("get").getSchemes());
+ }
+
+ @RestResource(swagger=@ResourceSwagger("paths:{'/path/{foo}':{get:{schemes:['a-scheme']}}}"))
+ public static class MI04a {
+ @RestMethod(name=GET,path="/path/{foo}",swagger=@MethodSwagger(schemes="['c-scheme-1','c-scheme-2']"))
+ public Foo doFoo() {
+ return null;
+ }
+ }
+
+ @Test
+ public void mi04a_operation_schemes_swaggerOnAnnotation() throws Exception {
+ assertObjectEquals("['c-scheme-1','c-scheme-2']", getSwagger(new MI04a()).getPaths().get("/path/{foo}").get("get").getSchemes());
+ assertObjectEquals("['c-scheme-1','c-scheme-2']", getSwaggerWithFile(new MI04a()).getPaths().get("/path/{foo}").get("get").getSchemes());
+ }
+
+ @RestResource(swagger=@ResourceSwagger("paths:{'/path/{foo}':{get:{schemes:['a-scheme']}}}"))
+ public static class MI04b {
+ @RestMethod(name=GET,path="/path/{foo}",swagger=@MethodSwagger(schemes="d-scheme-1, d-scheme-2"))
+ public Foo doFoo() {
+ return null;
+ }
+ }
+
+ @Test
+ public void mi04b_operation_schemes_swaggerOnAnnotation() throws Exception {
+ assertObjectEquals("['d-scheme-1','d-scheme-2']", getSwagger(new MI04b()).getPaths().get("/path/{foo}").get("get").getSchemes());
+ assertObjectEquals("['d-scheme-1','d-scheme-2']", getSwaggerWithFile(new MI04b()).getPaths().get("/path/{foo}").get("get").getSchemes());
+ }
+
+ @RestResource(messages="BasicRestInfoProviderTest", swagger=@ResourceSwagger("paths:{'/path/{foo}':{get:{schemes:['a-scheme']}}}"))
+ public static class MI05 {
+ @RestMethod(name=GET,path="/path/{foo}",swagger=@MethodSwagger(schemes="$L{foo}"))
+ public Foo doFoo() {
+ return null;
+ }
+ }
+
+ @Test
+ public void mi05_operation_schemes_swaggerOnAnnotation_localized() throws Exception {
+ assertObjectEquals("['l-foo']", getSwagger(new MI05()).getPaths().get("/path/{foo}").get("get").getSchemes());
+ assertObjectEquals("['l-foo']", getSwaggerWithFile(new MI05()).getPaths().get("/path/{foo}").get("get").getSchemes());
+ }
+
+ //-----------------------------------------------------------------------------------------------------------------
+ // /paths/<path>/<method>/parameters/query/type
+ //-----------------------------------------------------------------------------------------------------------------
+
+ @RestResource()
+ public static class NA01 {
+ @RestMethod(name=GET,path="/path/{foo}/query")
+ public Foo doFoo(@Query("foo") Foo foo) {
+ return null;
+ }
+ }
+
+ @Test
+ public void na01_query_type_default() throws Exception {
+ assertEquals(null, getSwagger(new NA01()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getType());
+ assertEquals("string", getSwaggerWithFile(new NA01()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getType());
+ }
+
+ @RestResource(swagger=@ResourceSwagger("paths:{'/path/{foo}/query':{get:{parameters:[{'in':'query',name:'foo',type:'int32'}]}}}"))
+ public static class NA02 {
+ @RestMethod(name=GET,path="/path/{foo}/query")
+ public Foo doFoo(@Query("foo") Foo foo) {
+ return null;
+ }
+ }
+
+ @Test
+ public void na02_query_type_swaggerOnClass() throws Exception {
+ assertEquals("int32", getSwagger(new NA02()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getType());
+ assertEquals("int32", getSwaggerWithFile(new NA02()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getType());
+ }
+
+ @RestResource(swagger=@ResourceSwagger("paths:{'/path/{foo}/query':{get:{parameters:[{'in':'query',name:'foo',type:'int32'}]}}}"))
+ public static class NA03 {
+ @RestMethod(name=GET,path="/path/{foo}/query",swagger=@MethodSwagger("parameters:[{'in':'query',name:'foo',type:'int64'}]"))
+ public Foo doFoo() {
+ return null;
+ }
+ }
+
+ @Test
+ public void na03_query_type_swaggerOnMethod() throws Exception {
+ assertEquals("int64", getSwagger(new NA03()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getType());
+ assertEquals("int64", getSwaggerWithFile(new NA03()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getType());
+ }
+
+ @RestResource(swagger=@ResourceSwagger("paths:{'/path/{foo}/query':{get:{parameters:[{'in':'query',name:'foo',type:'int32'}]}}}"))
+ public static class NA04 {
+ @RestMethod(name=GET,path="/path/{foo}/query")
+ public Foo doFoo(@Query(name="foo",type="boolean") Foo foo) {
+ return null;
+ }
+ }
+
+ @Test
+ public void na04_query_type_swaggerOnAnnotation() throws Exception {
+ assertEquals("boolean", getSwagger(new NA04()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getType());
+ assertEquals("boolean", getSwaggerWithFile(new NA04()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getType());
+ }
+
+ @RestResource(messages="BasicRestInfoProviderTest", swagger=@ResourceSwagger("paths:{'/path/{foo}/query':{get:{parameters:[{'in':'query',name:'foo',type:'int32'}]}}}"))
+ public static class NA05 {
+ @RestMethod(name=GET,path="/path/{foo}/query")
+ public Foo doFoo(@Query(name="foo",type="$L{foo}") Foo foo) {
+ return null;
+ }
+ }
+
+ @Test
+ public void na05_query_type_swaggerOnAnnotation_localized() throws Exception {
+ assertEquals("l-foo", getSwagger(new NA05()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getType());
+ assertEquals("l-foo", getSwaggerWithFile(new NA05()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getType());
+ }
+
+ //-----------------------------------------------------------------------------------------------------------------
+ // /paths/<path>/<method>/parameters/query/type
+ //-----------------------------------------------------------------------------------------------------------------
+
+ @RestResource()
+ public static class NB01 {
+ @RestMethod(name=GET,path="/path/{foo}/query")
+ public Foo doFoo(@Query("foo") Foo foo) {
+ return null;
+ }
+ }
+
+ @Test
+ public void nb01_query_description_default() throws Exception {
+ assertEquals(null, getSwagger(new NB01()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getDescription());
+ assertEquals("s-description", getSwaggerWithFile(new NB01()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getDescription());
+ }
+
+ @RestResource(swagger=@ResourceSwagger("paths:{'/path/{foo}/query':{get:{parameters:[{'in':'query',name:'foo',description:'a-description'}]}}}"))
+ public static class NB02 {
+ @RestMethod(name=GET,path="/path/{foo}/query")
+ public Foo doFoo(@Query("foo") Foo foo) {
+ return null;
+ }
+ }
+
+ @Test
+ public void nb02_query_description_swaggerOnClass() throws Exception {
+ assertEquals("a-description", getSwagger(new NB02()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getDescription());
+ assertEquals("a-description", getSwaggerWithFile(new NB02()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getDescription());
+ }
+
+ @RestResource(swagger=@ResourceSwagger("paths:{'/path/{foo}/query':{get:{parameters:[{'in':'query',name:'foo',description:'a-description'}]}}}"))
+ public static class NB03 {
+ @RestMethod(name=GET,path="/path/{foo}/query",swagger=@MethodSwagger("parameters:[{'in':'query',name:'foo',description:'b-description'}]"))
+ public Foo doFoo() {
+ return null;
+ }
+ }
+
+ @Test
+ public void nb03_query_description_swaggerOnMethod() throws Exception {
+ assertEquals("b-description", getSwagger(new NB03()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getDescription());
+ assertEquals("b-description", getSwaggerWithFile(new NB03()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getDescription());
+ }
+
+ @RestResource(swagger=@ResourceSwagger("paths:{'/path/{foo}/query':{get:{parameters:[{'in':'query',name:'foo',description:'a-description'}]}}}"))
+ public static class NB04 {
+ @RestMethod(name=GET,path="/path/{foo}/query")
+ public Foo doFoo(@Query(name="foo",description="c-description") Foo foo) {
+ return null;
+ }
+ }
+
+ @Test
+ public void nb04_query_description_swaggerOnAnnotation() throws Exception {
+ assertEquals("c-description", getSwagger(new NB04()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getDescription());
+ assertEquals("c-description", getSwaggerWithFile(new NB04()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getDescription());
+ }
+
+ @RestResource(messages="BasicRestInfoProviderTest", swagger=@ResourceSwagger("paths:{'/path/{foo}/query':{get:{parameters:[{'in':'query',name:'foo',description:'a-description'}]}}}"))
+ public static class NB05 {
+ @RestMethod(name=GET,path="/path/{foo}/query")
+ public Foo doFoo(@Query(name="foo",description="$L{foo}") Foo foo) {
+ return null;
+ }
+ }
+
+ @Test
+ public void nb05_query_description_swaggerOnAnnotation_localized() throws Exception {
+ assertEquals("l-foo", getSwagger(new NB05()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getDescription());
+ assertEquals("l-foo", getSwaggerWithFile(new NB05()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getDescription());
+ }
+
+ //-----------------------------------------------------------------------------------------------------------------
+ // /paths/<path>/<method>/parameters/query/required
+ //-----------------------------------------------------------------------------------------------------------------
+
+ @RestResource()
+ public static class NC01 {
+ @RestMethod(name=GET,path="/path/{foo}/query")
+ public Foo doFoo(@Query("foo") Foo foo) {
+ return null;
+ }
+ }
+
+ @Test
+ public void nc01_query_required_default() throws Exception {
+ assertEquals(null, getSwagger(new NC01()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getRequired());
+ assertObjectEquals("true", getSwaggerWithFile(new NC01()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getRequired());
+ }
+
+ @RestResource(swagger=@ResourceSwagger("paths:{'/path/{foo}/query':{get:{parameters:[{'in':'query',name:'foo',required:false}]}}}"))
+ public static class NC02 {
+ @RestMethod(name=GET,path="/path/{foo}/query")
+ public Foo doFoo(@Query("foo") Foo foo) {
+ return null;
+ }
+ }
+
+ @Test
+ public void nc02_query_required_swaggerOnClass() throws Exception {
+ assertObjectEquals("false", getSwagger(new NC02()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getRequired());
+ assertObjectEquals("false", getSwaggerWithFile(new NC02()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getRequired());
+ }
+
+ @RestResource(swagger=@ResourceSwagger("paths:{'/path/{foo}/query':{get:{parameters:[{'in':'query',name:'foo',required:false}]}}}"))
+ public static class NC03 {
+ @RestMethod(name=GET,path="/path/{foo}/query",swagger=@MethodSwagger("parameters:[{'in':'query',name:'foo',required:'true'}]"))
+ public Foo doFoo() {
+ return null;
+ }
+ }
+
+ @Test
+ public void nc03_query_required_swaggerOnMethod() throws Exception {
+ assertObjectEquals("true", getSwagger(new NC03()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getRequired());
+ assertObjectEquals("true", getSwaggerWithFile(new NC03()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getRequired());
+ }
+
+ @RestResource(swagger=@ResourceSwagger("paths:{'/path/{foo}/query':{get:{parameters:[{'in':'query',name:'foo',required:false}]}}}"))
+ public static class NC04 {
+ @RestMethod(name=GET,path="/path/{foo}/query")
+ public Foo doFoo(@Query(name="foo",required="true") Foo foo) {
+ return null;
+ }
+ }
+
+ @Test
+ public void nc04_query_required_swaggerOnAnnotation() throws Exception {
+ assertObjectEquals("true", getSwagger(new NC04()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getRequired());
+ assertObjectEquals("true", getSwaggerWithFile(new NC04()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getRequired());
+ }
+
+ @RestResource(messages="BasicRestInfoProviderTest", swagger=@ResourceSwagger("paths:{'/path/{foo}/query':{get:{parameters:[{'in':'query',name:'foo',required:false}]}}}"))
+ public static class NC05 {
+ @RestMethod(name=GET,path="/path/{foo}/query")
+ public Foo doFoo(@Query(name="foo",required="$L{false}") Foo foo) {
+ return null;
+ }
+ }
+
+ @Test
+ public void nc05_query_required_swaggerOnAnnotation_localized() throws Exception {
+ assertObjectEquals("false", getSwagger(new NC05()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getRequired());
+ assertObjectEquals("false", getSwaggerWithFile(new NC05()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getRequired());
+ }
+
+ @RestResource()
+ public static class NC06 {
+ @RestMethod(name=GET,path="/path/{foo}/path")
+ public Foo doFoo(@Path(name="foo") Foo foo) {
+ return null;
+ }
+ }
+
+ @Test
+ public void nc06_path_required_swaggerOnAnnotation() throws Exception {
+ assertObjectEquals("true", getSwagger(new NC06()).getPaths().get("/path/{foo}/path").get("get").getParameter("path", "foo").getRequired());
+ assertObjectEquals("true", getSwaggerWithFile(new NC06()).getPaths().get("/path/{foo}/path").get("get").getParameter("path", "foo").getRequired());
+ }
+
+ @RestResource()
+ public static class NC07 {
+ @RestMethod(name=GET,path="/path/{foo}/body")
+ public Foo doFoo(@Body() Foo foo) {
+ return null;
+ }
+ }
+
+ @Test
+ public void nc07_body_required_swaggerOnAnnotation() throws Exception {
+ assertObjectEquals("true", getSwagger(new NC07()).getPaths().get("/path/{foo}/body").get("get").getParameter("body", null).getRequired());
+ assertObjectEquals("true", getSwaggerWithFile(new NC07()).getPaths().get("/path/{foo}/body").get("get").getParameter("body", null).getRequired());
+ }
+
+ //-----------------------------------------------------------------------------------------------------------------
+ // /paths/<path>/<method>/parameters/query/allowEmptyValue
+ //-----------------------------------------------------------------------------------------------------------------
+
+ @RestResource()
+ public static class ND01 {
+ @RestMethod(name=GET,path="/path/{foo}/query")
+ public Foo doFoo(@Query("foo") Foo foo) {
+ return null;
+ }
+ }
+
+ @Test
+ public void nd01_query_allowEmptyValue_default() throws Exception {
+ assertEquals(null, getSwagger(new ND01()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getAllowEmptyValue());
+ assertObjectEquals("true", getSwaggerWithFile(new ND01()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getAllowEmptyValue());
+ }
+
+ @RestResource(swagger=@ResourceSwagger("paths:{'/path/{foo}/query':{get:{parameters:[{'in':'query',name:'foo',allowEmptyValue:false}]}}}"))
+ public static class ND02 {
+ @RestMethod(name=GET,path="/path/{foo}/query")
+ public Foo doFoo(@Query("foo") Foo foo) {
+ return null;
+ }
+ }
+
+ @Test
+ public void nd02_query_allowEmptyValue_swaggerOnClass() throws Exception {
+ assertObjectEquals("false", getSwagger(new ND02()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getAllowEmptyValue());
+ assertObjectEquals("false", getSwaggerWithFile(new ND02()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getAllowEmptyValue());
+ }
+
+ @RestResource(swagger=@ResourceSwagger("paths:{'/path/{foo}/query':{get:{parameters:[{'in':'query',name:'foo',allowEmptyValue:false}]}}}"))
+ public static class ND03 {
+ @RestMethod(name=GET,path="/path/{foo}/query",swagger=@MethodSwagger("parameters:[{'in':'query',name:'foo',allowEmptyValue:'true'}]"))
+ public Foo doFoo() {
+ return null;
+ }
+ }
+
+ @Test
+ public void nd03_query_allowEmptyValue_swaggerOnMethod() throws Exception {
+ assertObjectEquals("true", getSwagger(new ND03()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getAllowEmptyValue());
+ assertObjectEquals("true", getSwaggerWithFile(new ND03()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getAllowEmptyValue());
+ }
+
+ @RestResource(swagger=@ResourceSwagger("paths:{'/path/{foo}/query':{get:{parameters:[{'in':'query',name:'foo',allowEmptyValue:false}]}}}"))
+ public static class ND04 {
+ @RestMethod(name=GET,path="/path/{foo}/query")
+ public Foo doFoo(@Query(name="foo",allowEmptyValue="true") Foo foo) {
+ return null;
+ }
+ }
+
+ @Test
+ public void nd04_query_allowEmptyValue_swaggerOnAnnotation() throws Exception {
+ assertObjectEquals("true", getSwagger(new ND04()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getAllowEmptyValue());
+ assertObjectEquals("true", getSwaggerWithFile(new ND04()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getAllowEmptyValue());
+ }
+
+ @RestResource(messages="BasicRestInfoProviderTest", swagger=@ResourceSwagger("paths:{'/path/{foo}/query':{get:{parameters:[{'in':'query',name:'foo',allowEmptyValue:false}]}}}"))
+ public static class ND05 {
+ @RestMethod(name=GET,path="/path/{foo}/query")
+ public Foo doFoo(@Query(name="foo",allowEmptyValue="$L{false}") Foo foo) {
+ return null;
+ }
+ }
+
+ @Test
+ public void nd05_query_allowEmptyValue_swaggerOnAnnotation_localized() throws Exception {
+ assertObjectEquals("false", getSwagger(new ND05()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getAllowEmptyValue());
+ assertObjectEquals("false", getSwaggerWithFile(new ND05()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getAllowEmptyValue());
+ }
+
+ //-----------------------------------------------------------------------------------------------------------------
+ // /paths/<path>/<method>/parameters/query/exclusiveMaximum
+ //-----------------------------------------------------------------------------------------------------------------
+
+ @RestResource()
+ public static class NE01 {
+ @RestMethod(name=GET,path="/path/{foo}/query")
+ public Foo doFoo(@Query("foo") Foo foo) {
+ return null;
+ }
+ }
+
+ @Test
+ public void ne01_query_exclusiveMaximum_default() throws Exception {
+ assertEquals(null, getSwagger(new NE01()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getExclusiveMaximum());
+ assertObjectEquals("true", getSwaggerWithFile(new NE01()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getExclusiveMaximum());
+ }
+
+ @RestResource(swagger=@ResourceSwagger("paths:{'/path/{foo}/query':{get:{parameters:[{'in':'query',name:'foo',exclusiveMaximum:false}]}}}"))
+ public static class NE02 {
+ @RestMethod(name=GET,path="/path/{foo}/query")
+ public Foo doFoo(@Query("foo") Foo foo) {
+ return null;
+ }
+ }
+
+ @Test
+ public void ne02_query_exclusiveMaximum_swaggerOnClass() throws Exception {
+ assertObjectEquals("false", getSwagger(new NE02()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getExclusiveMaximum());
+ assertObjectEquals("false", getSwaggerWithFile(new NE02()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getExclusiveMaximum());
+ }
+
+ @RestResource(swagger=@ResourceSwagger("paths:{'/path/{foo}/query':{get:{parameters:[{'in':'query',name:'foo',exclusiveMaximum:false}]}}}"))
+ public static class NE03 {
+ @RestMethod(name=GET,path="/path/{foo}/query",swagger=@MethodSwagger("parameters:[{'in':'query',name:'foo',exclusiveMaximum:'true'}]"))
+ public Foo doFoo() {
+ return null;
+ }
+ }
+
+ @Test
+ public void ne03_query_exclusiveMaximum_swaggerOnMethod() throws Exception {
+ assertObjectEquals("true", getSwagger(new NE03()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getExclusiveMaximum());
+ assertObjectEquals("true", getSwaggerWithFile(new NE03()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getExclusiveMaximum());
+ }
+
+ @RestResource(swagger=@ResourceSwagger("paths:{'/path/{foo}/query':{get:{parameters:[{'in':'query',name:'foo',exclusiveMaximum:false}]}}}"))
+ public static class NE04 {
+ @RestMethod(name=GET,path="/path/{foo}/query")
+ public Foo doFoo(@Query(name="foo",exclusiveMaximum="true") Foo foo) {
+ return null;
+ }
+ }
+
+ @Test
+ public void ne04_query_exclusiveMaximum_swaggerOnAnnotation() throws Exception {
+ assertObjectEquals("true", getSwagger(new NE04()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getExclusiveMaximum());
+ assertObjectEquals("true", getSwaggerWithFile(new NE04()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getExclusiveMaximum());
+ }
+
+ @RestResource(messages="BasicRestInfoProviderTest", swagger=@ResourceSwagger("paths:{'/path/{foo}/query':{get:{parameters:[{'in':'query',name:'foo',exclusiveMaximum:false}]}}}"))
+ public static class NE05 {
+ @RestMethod(name=GET,path="/path/{foo}/query")
+ public Foo doFoo(@Query(name="foo",exclusiveMaximum="$L{false}") Foo foo) {
+ return null;
+ }
+ }
+
+ @Test
+ public void ne05_query_exclusiveMaximum_swaggerOnAnnotation_localized() throws Exception {
+ assertObjectEquals("false", getSwagger(new NE05()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getExclusiveMaximum());
+ assertObjectEquals("false", getSwaggerWithFile(new NE05()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getExclusiveMaximum());
+ }
+
+ //-----------------------------------------------------------------------------------------------------------------
+ // /paths/<path>/<method>/parameters/query/exclusiveMinimum
+ //-----------------------------------------------------------------------------------------------------------------
+
+ @RestResource()
+ public static class NF01 {
+ @RestMethod(name=GET,path="/path/{foo}/query")
+ public Foo doFoo(@Query("foo") Foo foo) {
+ return null;
+ }
+ }
+
+ @Test
+ public void nf01_query_exclusiveMinimum_default() throws Exception {
+ assertEquals(null, getSwagger(new NF01()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getExclusiveMinimum());
+ assertObjectEquals("true", getSwaggerWithFile(new NF01()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getExclusiveMinimum());
+ }
+
+ @RestResource(swagger=@ResourceSwagger("paths:{'/path/{foo}/query':{get:{parameters:[{'in':'query',name:'foo',exclusiveMinimum:false}]}}}"))
+ public static class NF02 {
+ @RestMethod(name=GET,path="/path/{foo}/query")
+ public Foo doFoo(@Query("foo") Foo foo) {
+ return null;
+ }
+ }
+
+ @Test
+ public void nf02_query_exclusiveMinimum_swaggerOnClass() throws Exception {
+ assertObjectEquals("false", getSwagger(new NF02()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getExclusiveMinimum());
+ assertObjectEquals("false", getSwaggerWithFile(new NF02()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getExclusiveMinimum());
+ }
+
+ @RestResource(swagger=@ResourceSwagger("paths:{'/path/{foo}/query':{get:{parameters:[{'in':'query',name:'foo',exclusiveMinimum:false}]}}}"))
+ public static class NF03 {
+ @RestMethod(name=GET,path="/path/{foo}/query",swagger=@MethodSwagger("parameters:[{'in':'query',name:'foo',exclusiveMinimum:'true'}]"))
+ public Foo doFoo() {
+ return null;
+ }
+ }
+
+ @Test
+ public void nf03_query_exclusiveMinimum_swaggerOnMethod() throws Exception {
+ assertObjectEquals("true", getSwagger(new NF03()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getExclusiveMinimum());
+ assertObjectEquals("true", getSwaggerWithFile(new NF03()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getExclusiveMinimum());
+ }
+
+ @RestResource(swagger=@ResourceSwagger("paths:{'/path/{foo}/query':{get:{parameters:[{'in':'query',name:'foo',exclusiveMinimum:false}]}}}"))
+ public static class NF04 {
+ @RestMethod(name=GET,path="/path/{foo}/query")
+ public Foo doFoo(@Query(name="foo",exclusiveMinimum="true") Foo foo) {
+ return null;
+ }
+ }
+
+ @Test
+ public void nf04_query_exclusiveMinimum_swaggerOnAnnotation() throws Exception {
+ assertObjectEquals("true", getSwagger(new NF04()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getExclusiveMinimum());
+ assertObjectEquals("true", getSwaggerWithFile(new NF04()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getExclusiveMinimum());
+ }
+
+ @RestResource(messages="BasicRestInfoProviderTest", swagger=@ResourceSwagger("paths:{'/path/{foo}/query':{get:{parameters:[{'in':'query',name:'foo',exclusiveMinimum:false}]}}}"))
+ public static class NF05 {
+ @RestMethod(name=GET,path="/path/{foo}/query")
+ public Foo doFoo(@Query(name="foo",exclusiveMinimum="$L{false}") Foo foo) {
+ return null;
+ }
+ }
+
+ @Test
+ public void nf05_query_exclusiveMinimum_swaggerOnAnnotation_localized() throws Exception {
+ assertObjectEquals("false", getSwagger(new NF05()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getExclusiveMinimum());
+ assertObjectEquals("false", getSwaggerWithFile(new NF05()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getExclusiveMinimum());
+ }
+
+ //-----------------------------------------------------------------------------------------------------------------
+ // /paths/<path>/<method>/parameters/query/uniqueItems
+ //-----------------------------------------------------------------------------------------------------------------
+
+ @RestResource()
+ public static class NG01 {
+ @RestMethod(name=GET,path="/path/{foo}/query")
+ public Foo doFoo(@Query("foo") Foo foo) {
+ return null;
+ }
+ }
+
+ @Test
+ public void ng01_query_uniqueItems_default() throws Exception {
+ assertEquals(null, getSwagger(new NG01()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getUniqueItems());
+ assertObjectEquals("true", getSwaggerWithFile(new NG01()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getUniqueItems());
+ }
+
+ @RestResource(swagger=@ResourceSwagger("paths:{'/path/{foo}/query':{get:{parameters:[{'in':'query',name:'foo',uniqueItems:false}]}}}"))
+ public static class NG02 {
+ @RestMethod(name=GET,path="/path/{foo}/query")
+ public Foo doFoo(@Query("foo") Foo foo) {
+ return null;
+ }
+ }
+
+ @Test
+ public void ng02_query_uniqueItems_swaggerOnClass() throws Exception {
+ assertObjectEquals("false", getSwagger(new NG02()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getUniqueItems());
+ assertObjectEquals("false", getSwaggerWithFile(new NG02()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getUniqueItems());
+ }
+
+ @RestResource(swagger=@ResourceSwagger("paths:{'/path/{foo}/query':{get:{parameters:[{'in':'query',name:'foo',uniqueItems:false}]}}}"))
+ public static class NG03 {
+ @RestMethod(name=GET,path="/path/{foo}/query",swagger=@MethodSwagger("parameters:[{'in':'query',name:'foo',uniqueItems:'true'}]"))
+ public Foo doFoo() {
+ return null;
+ }
+ }
+
+ @Test
+ public void ng03_query_uniqueItems_swaggerOnMethod() throws Exception {
+ assertObjectEquals("true", getSwagger(new NG03()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getUniqueItems());
+ assertObjectEquals("true", getSwaggerWithFile(new NG03()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getUniqueItems());
+ }
+
+ @RestResource(swagger=@ResourceSwagger("paths:{'/path/{foo}/query':{get:{parameters:[{'in':'query',name:'foo',uniqueItems:false}]}}}"))
+ public static class NG04 {
+ @RestMethod(name=GET,path="/path/{foo}/query")
+ public Foo doFoo(@Query(name="foo",uniqueItems="true") Foo foo) {
+ return null;
+ }
+ }
+
+ @Test
+ public void ng04_query_uniqueItems_swaggerOnAnnotation() throws Exception {
+ assertObjectEquals("true", getSwagger(new NG04()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getUniqueItems());
+ assertObjectEquals("true", getSwaggerWithFile(new NG04()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getUniqueItems());
+ }
+
+ @RestResource(messages="BasicRestInfoProviderTest", swagger=@ResourceSwagger("paths:{'/path/{foo}/query':{get:{parameters:[{'in':'query',name:'foo',uniqueItems:false}]}}}"))
+ public static class NG05 {
+ @RestMethod(name=GET,path="/path/{foo}/query")
+ public Foo doFoo(@Query(name="foo",uniqueItems="$L{false}") Foo foo) {
+ return null;
+ }
+ }
+
+ @Test
+ public void ng05_query_uniqueItems_swaggerOnAnnotation_localized() throws Exception {
+ assertObjectEquals("false", getSwagger(new NG05()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getUniqueItems());
+ assertObjectEquals("false", getSwaggerWithFile(new NG05()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getUniqueItems());
+ }
+
+ //-----------------------------------------------------------------------------------------------------------------
+ // /paths/<path>/<method>/parameters/query/format
+ //-----------------------------------------------------------------------------------------------------------------
+
+ @RestResource()
+ public static class NH01 {
+ @RestMethod(name=GET,path="/path/{foo}/query")
+ public Foo doFoo(@Query("foo") Foo foo) {
+ return null;
+ }
+ }
+
+ @Test
+ public void nh01_query_format_default() throws Exception {
+ assertEquals(null, getSwagger(new NH01()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getFormat());
+ assertEquals("s-format", getSwaggerWithFile(new NH01()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getFormat());
+ }
+
+ @RestResource(swagger=@ResourceSwagger("paths:{'/path/{foo}/query':{get:{parameters:[{'in':'query',name:'foo',format:'a-format'}]}}}"))
+ public static class NH02 {
+ @RestMethod(name=GET,path="/path/{foo}/query")
+ public Foo doFoo(@Query("foo") Foo foo) {
+ return null;
+ }
+ }
+
+ @Test
+ public void nh02_query_format_swaggerOnClass() throws Exception {
+ assertEquals("a-format", getSwagger(new NH02()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getFormat());
+ assertEquals("a-format", getSwaggerWithFile(new NH02()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getFormat());
+ }
+
+ @RestResource(swagger=@ResourceSwagger("paths:{'/path/{foo}/query':{get:{parameters:[{'in':'query',name:'foo',format:'a-format'}]}}}"))
+ public static class NH03 {
+ @RestMethod(name=GET,path="/path/{foo}/query",swagger=@MethodSwagger("parameters:[{'in':'query',name:'foo',format:'b-format'}]"))
+ public Foo doFoo() {
+ return null;
+ }
+ }
+
+ @Test
+ public void nh03_query_format_swaggerOnMethod() throws Exception {
+ assertEquals("b-format", getSwagger(new NH03()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getFormat());
+ assertEquals("b-format", getSwaggerWithFile(new NH03()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getFormat());
+ }
+
+ @RestResource(swagger=@ResourceSwagger("paths:{'/path/{foo}/query':{get:{parameters:[{'in':'query',name:'foo',format:'a-format'}]}}}"))
+ public static class NH04 {
+ @RestMethod(name=GET,path="/path/{foo}/query")
+ public Foo doFoo(@Query(name="foo",format="c-format") Foo foo) {
+ return null;
+ }
+ }
+
+ @Test
+ public void nh04_query_format_swaggerOnAnnotation() throws Exception {
+ assertEquals("c-format", getSwagger(new NH04()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getFormat());
+ assertEquals("c-format", getSwaggerWithFile(new NH04()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getFormat());
+ }
+
+ @RestResource(messages="BasicRestInfoProviderTest", swagger=@ResourceSwagger("paths:{'/path/{foo}/query':{get:{parameters:[{'in':'query',name:'foo',format:'a-format'}]}}}"))
+ public static class NH05 {
+ @RestMethod(name=GET,path="/path/{foo}/query")
+ public Foo doFoo(@Query(name="foo",format="$L{foo}") Foo foo) {
+ return null;
+ }
+ }
+
+ @Test
+ public void nh05_query_format_swaggerOnAnnotation_localized() throws Exception {
+ assertEquals("l-foo", getSwagger(new NH05()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getFormat());
+ assertEquals("l-foo", getSwaggerWithFile(new NH05()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getFormat());
+ }
+
+ //-----------------------------------------------------------------------------------------------------------------
+ // /paths/<path>/<method>/parameters/query/collectionFormat
+ //-----------------------------------------------------------------------------------------------------------------
+
+ @RestResource()
+ public static class NI01 {
+ @RestMethod(name=GET,path="/path/{foo}/query")
+ public Foo doFoo(@Query("foo") Foo foo) {
+ return null;
+ }
+ }
+
+ @Test
+ public void ni01_query_collectionFormat_default() throws Exception {
+ assertEquals(null, getSwagger(new NI01()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getCollectionFormat());
+ assertEquals("s-collectionFormat", getSwaggerWithFile(new NI01()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getCollectionFormat());
+ }
+
+ @RestResource(swagger=@ResourceSwagger("paths:{'/path/{foo}/query':{get:{parameters:[{'in':'query',name:'foo',collectionFormat:'a-collectionFormat'}]}}}"))
+ public static class NI02 {
+ @RestMethod(name=GET,path="/path/{foo}/query")
+ public Foo doFoo(@Query("foo") Foo foo) {
+ return null;
+ }
+ }
+
+ @Test
+ public void ni02_query_collectionFormat_swaggerOnClass() throws Exception {
+ assertEquals("a-collectionFormat", getSwagger(new NI02()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getCollectionFormat());
+ assertEquals("a-collectionFormat", getSwaggerWithFile(new NI02()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getCollectionFormat());
+ }
+
+ @RestResource(swagger=@ResourceSwagger("paths:{'/path/{foo}/query':{get:{parameters:[{'in':'query',name:'foo',collectionFormat:'a-collectionFormat'}]}}}"))
+ public static class NI03 {
+ @RestMethod(name=GET,path="/path/{foo}/query",swagger=@MethodSwagger("parameters:[{'in':'query',name:'foo',collectionFormat:'b-collectionFormat'}]"))
+ public Foo doFoo() {
+ return null;
+ }
+ }
+
+ @Test
+ public void ni03_query_collectionFormat_swaggerOnMethod() throws Exception {
+ assertEquals("b-collectionFormat", getSwagger(new NI03()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getCollectionFormat());
+ assertEquals("b-collectionFormat", getSwaggerWithFile(new NI03()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getCollectionFormat());
+ }
+
+ @RestResource(swagger=@ResourceSwagger("paths:{'/path/{foo}/query':{get:{parameters:[{'in':'query',name:'foo',collectionFormat:'a-collectionFormat'}]}}}"))
+ public static class NI04 {
+ @RestMethod(name=GET,path="/path/{foo}/query")
+ public Foo doFoo(@Query(name="foo",collectionFormat="c-collectionFormat") Foo foo) {
+ return null;
+ }
+ }
+
+ @Test
+ public void ni04_query_collectionFormat_swaggerOnAnnotation() throws Exception {
+ assertEquals("c-collectionFormat", getSwagger(new NI04()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getCollectionFormat());
+ assertEquals("c-collectionFormat", getSwaggerWithFile(new NI04()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getCollectionFormat());
+ }
+
+ @RestResource(messages="BasicRestInfoProviderTest", swagger=@ResourceSwagger("paths:{'/path/{foo}/query':{get:{parameters:[{'in':'query',name:'foo',collectionFormat:'a-collectionFormat'}]}}}"))
+ public static class NI05 {
+ @RestMethod(name=GET,path="/path/{foo}/query")
+ public Foo doFoo(@Query(name="foo",collectionFormat="$L{foo}") Foo foo) {
+ return null;
+ }
+ }
+
+ @Test
+ public void ni05_query_collectionFormat_swaggerOnAnnotation_localized() throws Exception {
+ assertEquals("l-foo", getSwagger(new NI05()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getCollectionFormat());
+ assertEquals("l-foo", getSwaggerWithFile(new NI05()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getCollectionFormat());
+ }
+
+ //-----------------------------------------------------------------------------------------------------------------
+ // /paths/<path>/<method>/parameters/query/pattern
+ //-----------------------------------------------------------------------------------------------------------------
+
+ @RestResource()
+ public static class NJ01 {
+ @RestMethod(name=GET,path="/path/{foo}/query")
+ public Foo doFoo(@Query("foo") Foo foo) {
+ return null;
+ }
+ }
+
+ @Test
+ public void nj01_query_pattern_default() throws Exception {
+ assertEquals(null, getSwagger(new NJ01()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getPattern());
+ assertEquals("s-pattern", getSwaggerWithFile(new NJ01()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getPattern());
+ }
+
+ @RestResource(swagger=@ResourceSwagger("paths:{'/path/{foo}/query':{get:{parameters:[{'in':'query',name:'foo',pattern:'a-pattern'}]}}}"))
+ public static class NJ02 {
+ @RestMethod(name=GET,path="/path/{foo}/query")
+ public Foo doFoo(@Query("foo") Foo foo) {
+ return null;
+ }
+ }
+
+ @Test
+ public void nj02_query_pattern_swaggerOnClass() throws Exception {
+ assertEquals("a-pattern", getSwagger(new NJ02()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getPattern());
+ assertEquals("a-pattern", getSwaggerWithFile(new NJ02()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getPattern());
+ }
+
+ @RestResource(swagger=@ResourceSwagger("paths:{'/path/{foo}/query':{get:{parameters:[{'in':'query',name:'foo',pattern:'a-pattern'}]}}}"))
+ public static class NJ03 {
+ @RestMethod(name=GET,path="/path/{foo}/query",swagger=@MethodSwagger("parameters:[{'in':'query',name:'foo',pattern:'b-pattern'}]"))
+ public Foo doFoo() {
+ return null;
+ }
+ }
+
+ @Test
+ public void nj03_query_pattern_swaggerOnMethod() throws Exception {
+ assertEquals("b-pattern", getSwagger(new NJ03()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getPattern());
+ assertEquals("b-pattern", getSwaggerWithFile(new NJ03()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getPattern());
+ }
+
+ @RestResource(swagger=@ResourceSwagger("paths:{'/path/{foo}/query':{get:{parameters:[{'in':'query',name:'foo',pattern:'a-pattern'}]}}}"))
+ public static class NJ04 {
+ @RestMethod(name=GET,path="/path/{foo}/query")
+ public Foo doFoo(@Query(name="foo",pattern="c-pattern") Foo foo) {
+ return null;
+ }
+ }
+
+ @Test
+ public void nj04_query_pattern_swaggerOnAnnotation() throws Exception {
+ assertEquals("c-pattern", getSwagger(new NJ04()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getPattern());
+ assertEquals("c-pattern", getSwaggerWithFile(new NJ04()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getPattern());
+ }
+
+ @RestResource(messages="BasicRestInfoProviderTest", swagger=@ResourceSwagger("paths:{'/path/{foo}/query':{get:{parameters:[{'in':'query',name:'foo',pattern:'a-pattern'}]}}}"))
+ public static class NJ05 {
+ @RestMethod(name=GET,path="/path/{foo}/query")
+ public Foo doFoo(@Query(name="foo",pattern="$L{foo}") Foo foo) {
+ return null;
+ }
+ }
+
+ @Test
+ public void nj05_query_pattern_swaggerOnAnnotation_localized() throws Exception {
+ assertEquals("l-foo", getSwagger(new NJ05()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getPattern());
+ assertEquals("l-foo", getSwaggerWithFile(new NJ05()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getPattern());
+ }
+
+ //-----------------------------------------------------------------------------------------------------------------
+ // /paths/<path>/<method>/parameters/query/maximum
+ //-----------------------------------------------------------------------------------------------------------------
+
+ @RestResource()
+ public static class NK01 {
+ @RestMethod(name=GET,path="/path/{foo}/query")
+ public Foo doFoo(@Query("foo") Foo foo) {
+ return null;
+ }
+ }
+
+ @Test
+ public void nk01_query_maximum_default() throws Exception {
+ assertEquals(null, getSwagger(new NK01()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getMaximum());
+ assertObjectEquals("1.0", getSwaggerWithFile(new NK01()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getMaximum());
+ }
+
+ @RestResource(swagger=@ResourceSwagger("paths:{'/path/{foo}/query':{get:{parameters:[{'in':'query',name:'foo',maximum:2.0}]}}}"))
+ public static class NK02 {
+ @RestMethod(name=GET,path="/path/{foo}/query")
+ public Foo doFoo(@Query("foo") Foo foo) {
+ return null;
+ }
+ }
+
+ @Test
+ public void nk02_query_maximum_swaggerOnClass() throws Exception {
+ assertObjectEquals("2.0", getSwagger(new NK02()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getMaximum());
+ assertObjectEquals("2.0", getSwaggerWithFile(new NK02()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getMaximum());
+ }
+
+ @RestResource(swagger=@ResourceSwagger("paths:{'/path/{foo}/query':{get:{parameters:[{'in':'query',name:'foo',maximum:2.0}]}}}"))
+ public static class NK03 {
+ @RestMethod(name=GET,path="/path/{foo}/query",swagger=@MethodSwagger("parameters:[{'in':'query',name:'foo',maximum:3.0}]"))
+ public Foo doFoo() {
+ return null;
+ }
+ }
+
+ @Test
+ public void nk03_query_maximum_swaggerOnMethod() throws Exception {
+ assertObjectEquals("3.0", getSwagger(new NK03()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getMaximum());
+ assertObjectEquals("3.0", getSwaggerWithFile(new NK03()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getMaximum());
+ }
+
+ @RestResource(swagger=@ResourceSwagger("paths:{'/path/{foo}/query':{get:{parameters:[{'in':'query',name:'foo',maximum:2.0}]}}}"))
+ public static class NK04 {
+ @RestMethod(name=GET,path="/path/{foo}/query")
+ public Foo doFoo(@Query(name="foo",maximum="4.0") Foo foo) {
+ return null;
+ }
+ }
+
+ @Test
+ public void nk04_query_maximum_swaggerOnAnnotation() throws Exception {
+ assertObjectEquals("4.0", getSwagger(new NK04()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getMaximum());
+ assertObjectEquals("4.0", getSwaggerWithFile(new NK04()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getMaximum());
+ }
+
+ @RestResource(messages="BasicRestInfoProviderTest", swagger=@ResourceSwagger("paths:{'/path/{foo}/query':{get:{parameters:[{'in':'query',name:'foo',maximum:2.0}]}}}"))
+ public static class NK05 {
+ @RestMethod(name=GET,path="/path/{foo}/query")
+ public Foo doFoo(@Query(name="foo",maximum="$L{50}") Foo foo) {
+ return null;
+ }
+ }
+
+ @Test
+ public void nk05_query_maximum_swaggerOnAnnotation_localized() throws Exception {
+ assertObjectEquals("5.0", getSwagger(new NK05()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getMaximum());
+ assertObjectEquals("5.0", getSwaggerWithFile(new NK05()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getMaximum());
+ }
+
+ //-----------------------------------------------------------------------------------------------------------------
+ // /paths/<path>/<method>/parameters/query/minimum
+ //-----------------------------------------------------------------------------------------------------------------
+
+ @RestResource()
+ public static class NL01 {
+ @RestMethod(name=GET,path="/path/{foo}/query")
+ public Foo doFoo(@Query("foo") Foo foo) {
+ return null;
+ }
+ }
+
+ @Test
+ public void nl01_query_minimum_default() throws Exception {
+ assertEquals(null, getSwagger(new NL01()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getMinimum());
+ assertObjectEquals("1.0", getSwaggerWithFile(new NL01()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getMinimum());
+ }
+
+ @RestResource(swagger=@ResourceSwagger("paths:{'/path/{foo}/query':{get:{parameters:[{'in':'query',name:'foo',minimum:2.0}]}}}"))
+ public static class NL02 {
+ @RestMethod(name=GET,path="/path/{foo}/query")
+ public Foo doFoo(@Query("foo") Foo foo) {
+ return null;
+ }
+ }
+
+ @Test
+ public void nl02_query_minimum_swaggerOnClass() throws Exception {
+ assertObjectEquals("2.0", getSwagger(new NL02()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getMinimum());
+ assertObjectEquals("2.0", getSwaggerWithFile(new NL02()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getMinimum());
+ }
+
+ @RestResource(swagger=@ResourceSwagger("paths:{'/path/{foo}/query':{get:{parameters:[{'in':'query',name:'foo',minimum:2.0}]}}}"))
+ public static class NL03 {
+ @RestMethod(name=GET,path="/path/{foo}/query",swagger=@MethodSwagger("parameters:[{'in':'query',name:'foo',minimum:3.0}]"))
+ public Foo doFoo() {
+ return null;
+ }
+ }
+
+ @Test
+ public void nl03_query_minimum_swaggerOnMethod() throws Exception {
+ assertObjectEquals("3.0", getSwagger(new NL03()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getMinimum());
+ assertObjectEquals("3.0", getSwaggerWithFile(new NL03()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getMinimum());
+ }
+
+ @RestResource(swagger=@ResourceSwagger("paths:{'/path/{foo}/query':{get:{parameters:[{'in':'query',name:'foo',minimum:2.0}]}}}"))
+ public static class NL04 {
+ @RestMethod(name=GET,path="/path/{foo}/query")
+ public Foo doFoo(@Query(name="foo",minimum="4.0") Foo foo) {
+ return null;
+ }
+ }
+
+ @Test
+ public void nl04_query_minimum_swaggerOnAnnotation() throws Exception {
+ assertObjectEquals("4.0", getSwagger(new NL04()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getMinimum());
+ assertObjectEquals("4.0", getSwaggerWithFile(new NL04()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getMinimum());
+ }
+
+ @RestResource(messages="BasicRestInfoProviderTest", swagger=@ResourceSwagger("paths:{'/path/{foo}/query':{get:{parameters:[{'in':'query',name:'foo',minimum:2.0}]}}}"))
+ public static class NL05 {
+ @RestMethod(name=GET,path="/path/{foo}/query")
+ public Foo doFoo(@Query(name="foo",minimum="$L{50}") Foo foo) {
+ return null;
+ }
+ }
+
+ @Test
+ public void nl05_query_minimum_swaggerOnAnnotation_localized() throws Exception {
+ assertObjectEquals("5.0", getSwagger(new NL05()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getMinimum());
+ assertObjectEquals("5.0", getSwaggerWithFile(new NL05()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getMinimum());
+ }
+
+ //-----------------------------------------------------------------------------------------------------------------
+ // /paths/<path>/<method>/parameters/query/multipleOf
+ //-----------------------------------------------------------------------------------------------------------------
+
+ @RestResource()
+ public static class NM01 {
+ @RestMethod(name=GET,path="/path/{foo}/query")
+ public Foo doFoo(@Query("foo") Foo foo) {
+ return null;
+ }
+ }
+
+ @Test
+ public void nm01_query_multipleOf_default() throws Exception {
+ assertEquals(null, getSwagger(new NM01()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getMultipleOf());
+ assertObjectEquals("1.0", getSwaggerWithFile(new NM01()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getMultipleOf());
+ }
+
+ @RestResource(swagger=@ResourceSwagger("paths:{'/path/{foo}/query':{get:{parameters:[{'in':'query',name:'foo',multipleOf:2.0}]}}}"))
+ public static class NM02 {
+ @RestMethod(name=GET,path="/path/{foo}/query")
+ public Foo doFoo(@Query("foo") Foo foo) {
+ return null;
+ }
+ }
+
+ @Test
+ public void nm02_query_multipleOf_swaggerOnClass() throws Exception {
+ assertObjectEquals("2.0", getSwagger(new NM02()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getMultipleOf());
+ assertObjectEquals("2.0", getSwaggerWithFile(new NM02()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getMultipleOf());
+ }
+
+ @RestResource(swagger=@ResourceSwagger("paths:{'/path/{foo}/query':{get:{parameters:[{'in':'query',name:'foo',multipleOf:2.0}]}}}"))
+ public static class NM03 {
+ @RestMethod(name=GET,path="/path/{foo}/query",swagger=@MethodSwagger("parameters:[{'in':'query',name:'foo',multipleOf:3.0}]"))
+ public Foo doFoo() {
+ return null;
+ }
+ }
+
+ @Test
+ public void nm03_query_multipleOf_swaggerOnMethod() throws Exception {
+ assertObjectEquals("3.0", getSwagger(new NM03()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getMultipleOf());
+ assertObjectEquals("3.0", getSwaggerWithFile(new NM03()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getMultipleOf());
+ }
+
+ @RestResource(swagger=@ResourceSwagger("paths:{'/path/{foo}/query':{get:{parameters:[{'in':'query',name:'foo',multipleOf:2.0}]}}}"))
+ public static class NM04 {
+ @RestMethod(name=GET,path="/path/{foo}/query")
+ public Foo doFoo(@Query(name="foo",multipleOf="4.0") Foo foo) {
+ return null;
+ }
+ }
+
+ @Test
+ public void nm04_query_multipleOf_swaggerOnAnnotation() throws Exception {
+ assertObjectEquals("4.0", getSwagger(new NM04()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getMultipleOf());
+ assertObjectEquals("4.0", getSwaggerWithFile(new NM04()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getMultipleOf());
+ }
+
+ @RestResource(messages="BasicRestInfoProviderTest", swagger=@ResourceSwagger("paths:{'/path/{foo}/query':{get:{parameters:[{'in':'query',name:'foo',multipleOf:2.0}]}}}"))
+ public static class NM05 {
+ @RestMethod(name=GET,path="/path/{foo}/query")
+ public Foo doFoo(@Query(name="foo",multipleOf="$L{50}") Foo foo) {
+ return null;
+ }
+ }
+
+ @Test
+ public void nm05_query_multipleOf_swaggerOnAnnotation_localized() throws Exception {
+ assertObjectEquals("5.0", getSwagger(new NM05()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getMultipleOf());
+ assertObjectEquals("5.0", getSwaggerWithFile(new NM05()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getMultipleOf());
+ }
+
+ //-----------------------------------------------------------------------------------------------------------------
+ // /paths/<path>/<method>/parameters/query/maxLength
+ //-----------------------------------------------------------------------------------------------------------------
+
+ @RestResource()
+ public static class NN01 {
+ @RestMethod(name=GET,path="/path/{foo}/query")
+ public Foo doFoo(@Query("foo") Foo foo) {
+ return null;
+ }
+ }
+
+ @Test
+ public void nn01_query_maxLength_default() throws Exception {
+ assertEquals(null, getSwagger(new NN01()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getMaxLength());
+ assertObjectEquals("1", getSwaggerWithFile(new NN01()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getMaxLength());
+ }
+
+ @RestResource(swagger=@ResourceSwagger("paths:{'/path/{foo}/query':{get:{parameters:[{'in':'query',name:'foo',maxLength:2}]}}}"))
+ public static class NN02 {
+ @RestMethod(name=GET,path="/path/{foo}/query")
+ public Foo doFoo(@Query("foo") Foo foo) {
+ return null;
+ }
+ }
+
+ @Test
+ public void nn02_query_maxLength_swaggerOnClass() throws Exception {
+ assertObjectEquals("2", getSwagger(new NN02()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getMaxLength());
+ assertObjectEquals("2", getSwaggerWithFile(new NN02()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getMaxLength());
+ }
+
+ @RestResource(swagger=@ResourceSwagger("paths:{'/path/{foo}/query':{get:{parameters:[{'in':'query',name:'foo',maxLength:2}]}}}"))
+ public static class NN03 {
+ @RestMethod(name=GET,path="/path/{foo}/query",swagger=@MethodSwagger("parameters:[{'in':'query',name:'foo',maxLength:3}]"))
+ public Foo doFoo() {
+ return null;
+ }
+ }
+
+ @Test
+ public void nn03_query_maxLength_swaggerOnMethod() throws Exception {
+ assertObjectEquals("3", getSwagger(new NN03()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getMaxLength());
+ assertObjectEquals("3", getSwaggerWithFile(new NN03()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getMaxLength());
+ }
+
+ @RestResource(swagger=@ResourceSwagger("paths:{'/path/{foo}/query':{get:{parameters:[{'in':'query',name:'foo',maxLength:2}]}}}"))
+ public static class NN04 {
+ @RestMethod(name=GET,path="/path/{foo}/query")
+ public Foo doFoo(@Query(name="foo",maxLength="4") Foo foo) {
+ return null;
+ }
+ }
+
+ @Test
+ public void nn04_query_maxLength_swaggerOnAnnotation() throws Exception {
+ assertObjectEquals("4", getSwagger(new NN04()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getMaxLength());
+ assertObjectEquals("4", getSwaggerWithFile(new NN04()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getMaxLength());
+ }
+
+ @RestResource(messages="BasicRestInfoProviderTest", swagger=@ResourceSwagger("paths:{'/path/{foo}/query':{get:{parameters:[{'in':'query',name:'foo',maxLength:2}]}}}"))
+ public static class NN05 {
+ @RestMethod(name=GET,path="/path/{foo}/query")
+ public Foo doFoo(@Query(name="foo",maxLength="$L{5}") Foo foo) {
+ return null;
+ }
+ }
+
+ @Test
+ public void nn05_query_maxLength_swaggerOnAnnotation_localized() throws Exception {
+ assertObjectEquals("5", getSwagger(new NN05()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getMaxLength());
+ assertObjectEquals("5", getSwaggerWithFile(new NN05()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getMaxLength());
+ }
+
+ //-----------------------------------------------------------------------------------------------------------------
+ // /paths/<path>/<method>/parameters/query/minLength
+ //-----------------------------------------------------------------------------------------------------------------
+
+ @RestResource()
+ public static class NO01 {
+ @RestMethod(name=GET,path="/path/{foo}/query")
+ public Foo doFoo(@Query("foo") Foo foo) {
+ return null;
+ }
+ }
+
+ @Test
+ public void no01_query_minLength_default() throws Exception {
+ assertEquals(null, getSwagger(new NO01()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getMinLength());
+ assertObjectEquals("1", getSwaggerWithFile(new NO01()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getMinLength());
+ }
+
+ @RestResource(swagger=@ResourceSwagger("paths:{'/path/{foo}/query':{get:{parameters:[{'in':'query',name:'foo',minLength:2}]}}}"))
+ public static class NO02 {
+ @RestMethod(name=GET,path="/path/{foo}/query")
+ public Foo doFoo(@Query("foo") Foo foo) {
+ return null;
+ }
+ }
+
+ @Test
+ public void no02_query_minLength_swaggerOnClass() throws Exception {
+ assertObjectEquals("2", getSwagger(new NO02()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getMinLength());
+ assertObjectEquals("2", getSwaggerWithFile(new NO02()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getMinLength());
+ }
+
+ @RestResource(swagger=@ResourceSwagger("paths:{'/path/{foo}/query':{get:{parameters:[{'in':'query',name:'foo',minLength:2}]}}}"))
+ public static class NO03 {
+ @RestMethod(name=GET,path="/path/{foo}/query",swagger=@MethodSwagger("parameters:[{'in':'query',name:'foo',minLength:3}]"))
+ public Foo doFoo() {
+ return null;
+ }
+ }
+
+ @Test
+ public void no03_query_minLength_swaggerOnMethod() throws Exception {
+ assertObjectEquals("3", getSwagger(new NO03()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getMinLength());
+ assertObjectEquals("3", getSwaggerWithFile(new NO03()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getMinLength());
+ }
+
+ @RestResource(swagger=@ResourceSwagger("paths:{'/path/{foo}/query':{get:{parameters:[{'in':'query',name:'foo',minLength:2}]}}}"))
+ public static class NO04 {
+ @RestMethod(name=GET,path="/path/{foo}/query")
+ public Foo doFoo(@Query(name="foo",minLength="4") Foo foo) {
+ return null;
+ }
+ }
+
+ @Test
+ public void no04_query_minLength_swaggerOnAnootation() throws Exception {
+ assertObjectEquals("4", getSwagger(new NO04()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getMinLength());
+ assertObjectEquals("4", getSwaggerWithFile(new NO04()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getMinLength());
+ }
+
+ @RestResource(messages="BasicRestInfoProviderTest", swagger=@ResourceSwagger("paths:{'/path/{foo}/query':{get:{parameters:[{'in':'query',name:'foo',minLength:2}]}}}"))
+ public static class NO05 {
+ @RestMethod(name=GET,path="/path/{foo}/query")
+ public Foo doFoo(@Query(name="foo",minLength="$L{5}") Foo foo) {
+ return null;
+ }
+ }
+
+ @Test
+ public void no05_query_minLength_swaggerOnAnootation_localized() throws Exception {
+ assertObjectEquals("5", getSwagger(new NO05()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getMinLength());
+ assertObjectEquals("5", getSwaggerWithFile(new NO05()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getMinLength());
+ }
+
+ //-----------------------------------------------------------------------------------------------------------------
+ // /paths/<path>/<method>/parameters/query/maxItems
+ //-----------------------------------------------------------------------------------------------------------------
+
+ @RestResource()
+ public static class NP01 {
+ @RestMethod(name=GET,path="/path/{foo}/query")
+ public Foo doFoo(@Query("foo") Foo foo) {
+ return null;
+ }
+ }
+
+ @Test
+ public void np01_query_maxItems_default() throws Exception {
+ assertEquals(null, getSwagger(new NP01()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getMaxItems());
+ assertObjectEquals("1", getSwaggerWithFile(new NP01()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getMaxItems());
+ }
+
+ @RestResource(swagger=@ResourceSwagger("paths:{'/path/{foo}/query':{get:{parameters:[{'in':'query',name:'foo',maxItems:2}]}}}"))
+ public static class NP02 {
+ @RestMethod(name=GET,path="/path/{foo}/query")
+ public Foo doFoo(@Query("foo") Foo foo) {
+ return null;
+ }
+ }
+
+ @Test
+ public void np02_query_maxItems_swaggerOnClass() throws Exception {
+ assertObjectEquals("2", getSwagger(new NP02()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getMaxItems());
+ assertObjectEquals("2", getSwaggerWithFile(new NP02()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getMaxItems());
+ }
+
+ @RestResource(swagger=@ResourceSwagger("paths:{'/path/{foo}/query':{get:{parameters:[{'in':'query',name:'foo',maxItems:2}]}}}"))
+ public static class NP03 {
+ @RestMethod(name=GET,path="/path/{foo}/query",swagger=@MethodSwagger("parameters:[{'in':'query',name:'foo',maxItems:3}]"))
+ public Foo doFoo() {
+ return null;
+ }
+ }
+
+ @Test
+ public void np03_query_maxItems_swaggerOnMethod() throws Exception {
+ assertObjectEquals("3", getSwagger(new NP03()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getMaxItems());
+ assertObjectEquals("3", getSwaggerWithFile(new NP03()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getMaxItems());
+ }
+
+ @RestResource(swagger=@ResourceSwagger("paths:{'/path/{foo}/query':{get:{parameters:[{'in':'query',name:'foo',maxItems:2}]}}}"))
+ public static class NP04 {
+ @RestMethod(name=GET,path="/path/{foo}/query")
+ public Foo doFoo(@Query(name="foo",maxItems="4") Foo foo) {
+ return null;
+ }
+ }
+
+ @Test
+ public void np04_query_maxItems_swaggerOnAnpotation() throws Exception {
+ assertObjectEquals("4", getSwagger(new NP04()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getMaxItems());
+ assertObjectEquals("4", getSwaggerWithFile(new NP04()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getMaxItems());
+ }
+
+ @RestResource(messages="BasicRestInfoProviderTest", swagger=@ResourceSwagger("paths:{'/path/{foo}/query':{get:{parameters:[{'in':'query',name:'foo',maxItems:2}]}}}"))
+ public static class NP05 {
+ @RestMethod(name=GET,path="/path/{foo}/query")
+ public Foo doFoo(@Query(name="foo",maxItems="$L{5}") Foo foo) {
+ return null;
+ }
+ }
+
+ @Test
+ public void np05_query_maxItems_swaggerOnAnpotation_localized() throws Exception {
+ assertObjectEquals("5", getSwagger(new NP05()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getMaxItems());
+ assertObjectEquals("5", getSwaggerWithFile(new NP05()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getMaxItems());
+ }
+
+ //-----------------------------------------------------------------------------------------------------------------
+ // /paths/<path>/<method>/parameters/query/minItems
+ //-----------------------------------------------------------------------------------------------------------------
+
+ @RestResource()
+ public static class NQ01 {
+ @RestMethod(name=GET,path="/path/{foo}/query")
+ public Foo doFoo(@Query("foo") Foo foo) {
+ return null;
+ }
+ }
+
+ @Test
+ public void nq01_query_minItems_default() throws Exception {
+ assertEquals(null, getSwagger(new NQ01()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getMinItems());
+ assertObjectEquals("1", getSwaggerWithFile(new NQ01()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getMinItems());
+ }
+
+ @RestResource(swagger=@ResourceSwagger("paths:{'/path/{foo}/query':{get:{parameters:[{'in':'query',name:'foo',minItems:2}]}}}"))
+ public static class NQ02 {
+ @RestMethod(name=GET,path="/path/{foo}/query")
+ public Foo doFoo(@Query("foo") Foo foo) {
+ return null;
+ }
+ }
+
+ @Test
+ public void nq02_query_minItems_swaggerOnClass() throws Exception {
+ assertObjectEquals("2", getSwagger(new NQ02()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getMinItems());
+ assertObjectEquals("2", getSwaggerWithFile(new NQ02()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getMinItems());
+ }
+
+ @RestResource(swagger=@ResourceSwagger("paths:{'/path/{foo}/query':{get:{parameters:[{'in':'query',name:'foo',minItems:2}]}}}"))
+ public static class NQ03 {
+ @RestMethod(name=GET,path="/path/{foo}/query",swagger=@MethodSwagger("parameters:[{'in':'query',name:'foo',minItems:3}]"))
+ public Foo doFoo() {
+ return null;
+ }
+ }
+
+ @Test
+ public void nq03_query_minItems_swaggerOnMethod() throws Exception {
+ assertObjectEquals("3", getSwagger(new NQ03()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getMinItems());
+ assertObjectEquals("3", getSwaggerWithFile(new NQ03()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getMinItems());
+ }
+
+ @RestResource(swagger=@ResourceSwagger("paths:{'/path/{foo}/query':{get:{parameters:[{'in':'query',name:'foo',minItems:2}]}}}"))
+ public static class NQ04 {
+ @RestMethod(name=GET,path="/path/{foo}/query")
+ public Foo doFoo(@Query(name="foo",minItems="4") Foo foo) {
+ return null;
+ }
+ }
+
+ @Test
+ public void nq04_query_minItems_swaggerOnAnqotation() throws Exception {
+ assertObjectEquals("4", getSwagger(new NQ04()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getMinItems());
+ assertObjectEquals("4", getSwaggerWithFile(new NQ04()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getMinItems());
+ }
+
+ @RestResource(messages="BasicRestInfoProviderTest", swagger=@ResourceSwagger("paths:{'/path/{foo}/query':{get:{parameters:[{'in':'query',name:'foo',minItems:2}]}}}"))
+ public static class NQ05 {
+ @RestMethod(name=GET,path="/path/{foo}/query")
+ public Foo doFoo(@Query(name="foo",minItems="$L{5}") Foo foo) {
+ return null;
+ }
+ }
+
+ @Test
+ public void nq05_query_minItems_swaggerOnAnqotation_localized() throws Exception {
+ assertObjectEquals("5", getSwagger(new NQ05()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getMinItems());
+ assertObjectEquals("5", getSwaggerWithFile(new NQ05()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getMinItems());
+ }
+
+ //-----------------------------------------------------------------------------------------------------------------
+ // /paths/<path>/<method>/parameters/query/example
+ //-----------------------------------------------------------------------------------------------------------------
+
+ @RestResource()
+ public static class NR01 {
+ @RestMethod(name=GET,path="/path/{foo}/query")
+ public Foo doFoo(@Query("foo") Foo foo) {
+ return null;
+ }
+ }
+
+ @Test
+ public void nr01_query_example_default() throws Exception {
+ assertEquals(null, getSwagger(new NR01()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getExample());
+ assertObjectEquals("{id:1}", getSwaggerWithFile(new NR01()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getExample());
+ }
+
+ @RestResource(swagger=@ResourceSwagger("paths:{'/path/{foo}/query':{get:{parameters:[{'in':'query',name:'foo',x-example:{id:2}}]}}}"))
+ public static class NR02 {
+ @RestMethod(name=GET,path="/path/{foo}/query")
+ public Foo doFoo(@Query("foo") Foo foo) {
+ return null;
+ }
+ }
+
+ @Test
+ public void nr02_query_example_swaggerOnClass() throws Exception {
+ assertObjectEquals("{id:2}", getSwagger(new NR02()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getExample());
+ assertObjectEquals("{id:2}", getSwaggerWithFile(new NR02()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getExample());
+ }
+
+ @RestResource(swagger=@ResourceSwagger("paths:{'/path/{foo}/query':{get:{parameters:[{'in':'query',name:'foo',x-example:{id:2}}]}}}"))
+ public static class NR03 {
+ @RestMethod(name=GET,path="/path/{foo}/query",swagger=@MethodSwagger("parameters:[{'in':'query',name:'foo',x-example:{id:3}}]"))
+ public Foo doFoo() {
+ return null;
+ }
+ }
+
+ @Test
+ public void nr03_query_example_swaggerOnMethod() throws Exception {
+ assertObjectEquals("{id:3}", getSwagger(new NR03()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getExample());
+ assertObjectEquals("{id:3}", getSwaggerWithFile(new NR03()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getExample());
+ }
+
+ @RestResource(swagger=@ResourceSwagger("paths:{'/path/{foo}/query':{get:{parameters:[{'in':'query',name:'foo',x-example:{id:2}}]}}}"))
+ public static class NR04 {
+ @RestMethod(name=GET,path="/path/{foo}/query")
+ public Foo doFoo(@Query(name="foo",example="{id:4}") Foo foo) {
+ return null;
+ }
+ }
+
+ @Test
+ public void nr04_query_example_swaggerOnAnnotation() throws Exception {
+ assertObjectEquals("{id:4}", getSwagger(new NR04()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getExample());
+ assertObjectEquals("{id:4}", getSwaggerWithFile(new NR04()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getExample());
+ }
+
+ @RestResource(messages="BasicRestInfoProviderTest", swagger=@ResourceSwagger("paths:{'/path/{foo}/query':{get:{parameters:[{'in':'query',name:'foo',x-example:{id:2}}]}}}"))
+ public static class NR05 {
+ @RestMethod(name=GET,path="/path/{foo}/query")
+ public Foo doFoo(@Query(name="foo",example="{id:$L{5}}") Foo foo) {
+ return null;
+ }
+ }
+
+ @Test
+ public void nr05_query_example_swaggerOnAnnotation_localized() throws Exception {
+ assertObjectEquals("{id:5}", getSwagger(new NR05()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getExample());
+ assertObjectEquals("{id:5}", getSwaggerWithFile(new NR05()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getExample());
+ }
+
+ //-----------------------------------------------------------------------------------------------------------------
+ // /paths/<path>/<method>/parameters/body/examples
+ //-----------------------------------------------------------------------------------------------------------------
+
+ @RestResource()
+ public static class NS01 {
+ @RestMethod(name=GET,path="/path/{foo}/body")
+ public Foo doFoo(@Body Foo foo) {
+ return null;
+ }
+ }
+
+ @Test
+ public void ns01_body_examples_default() throws Exception {
+ assertEquals(null, getSwagger(new NS01()).getPaths().get("/path/{foo}/body").get("get").getParameter("body",null).getExamples());
+ assertObjectEquals("{foo:'a'}", getSwaggerWithFile(new NS01()).getPaths().get("/path/{foo}/body").get("get").getParameter("body",null).getExamples());
+ }
+
+ @RestResource(swagger=@ResourceSwagger("paths:{'/path/{foo}/body':{get:{parameters:[{'in':'body',x-examples:{foo:'b'}}]}}}"))
+ public static class NS02 {
+ @RestMethod(name=GET,path="/path/{foo}/body")
+ public Foo doFoo(@Body Foo foo) {
+ return null;
+ }
+ }
+
+ @Test
+ public void ns02_body_examples_swaggerOnClass() throws Exception {
+ assertObjectEquals("{foo:'b'}", getSwagger(new NS02()).getPaths().get("/path/{foo}/body").get("get").getParameter("body",null).getExamples());
+ assertObjectEquals("{foo:'b'}", getSwaggerWithFile(new NS02()).getPaths().get("/path/{foo}/body").get("get").getParameter("body",null).getExamples());
+ }
+
+ @RestResource(swagger=@ResourceSwagger("paths:{'/path/{foo}/body':{get:{parameters:[{'in':'body',x-examples:{foo:'b'}}]}}}"))
+ public static class NS03 {
+ @RestMethod(name=GET,path="/path/{foo}/body",swagger=@MethodSwagger("parameters:[{'in':'body',x-examples:{foo:'c'}}]"))
+ public Foo doFoo() {
+ return null;
+ }
+ }
+
+ @Test
+ public void ns03_body_examples_swaggerOnMethns() throws Exception {
+ assertObjectEquals("{foo:'c'}", getSwagger(new NS03()).getPaths().get("/path/{foo}/body").get("get").getParameter("body",null).getExamples());
+ assertObjectEquals("{foo:'c'}", getSwaggerWithFile(new NS03()).getPaths().get("/path/{foo}/body").get("get").getParameter("body",null).getExamples());
+ }
+
+ @RestResource(swagger=@ResourceSwagger("paths:{'/path/{foo}/body':{get:{parameters:[{'in':'body',x-examples:{foo:'b'}}]}}}"))
+ public static class NS04 {
+ @RestMethod(name=GET,path="/path/{foo}/body")
+ public Foo doFoo(@Body(examples="{foo:'d'}") Foo foo) {
+ return null;
+ }
+ }
+
+ @Test
+ public void ns04_body_examples_swaggerOnAnnotation() throws Exception {
+ assertObjectEquals("{foo:'d'}", getSwagger(new NS04()).getPaths().get("/path/{foo}/body").get("get").getParameter("body",null).getExamples());
+ assertObjectEquals("{foo:'d'}", getSwaggerWithFile(new NS04()).getPaths().get("/path/{foo}/body").get("get").getParameter("body",null).getExamples());
+ }
+
+ @RestResource(messages="BasicRestInfoProviderTest", swagger=@ResourceSwagger("paths:{'/path/{foo}/body':{get:{parameters:[{'in':'body',examples:{foo:'b'}}]}}}"))
+ public static class NS05 {
+ @RestMethod(name=GET,path="/path/{foo}/body")
+ public Foo doFoo(@Body(examples="{foo:'$L{foo}'}") Foo foo) {
+ return null;
+ }
+ }
+
+ @Test
+ public void ns05_body_examples_swaggerOnAnnotation_localized() throws Exception {
+ assertObjectEquals("{foo:'l-foo'}", getSwagger(new NS05()).getPaths().get("/path/{foo}/body").get("get").getParameter("body",null).getExamples());
+ assertObjectEquals("{foo:'l-foo'}", getSwaggerWithFile(new NS05()).getPaths().get("/path/{foo}/body").get("get").getParameter("body",null).getExamples());
+ }
+
+ //-----------------------------------------------------------------------------------------------------------------
+ // /paths/<path>/<method>/parameters/query/schema
+ //-----------------------------------------------------------------------------------------------------------------
+
+ // TODO
+
+ //-----------------------------------------------------------------------------------------------------------------
+ // /paths/<path>/<method>/responses/<response>/description
+ //-----------------------------------------------------------------------------------------------------------------
+
+ @RestResource()
+ public static class OA01 {
+ @RestMethod(name=GET,path="/path/{foo}/responses/100")
+ public Foo doFoo(@Response(code=100) Value<Foo> foo) {
+ return null;
+ }
+ }
+
+ @Test
+ public void oa01_responses_100_description_default() throws Exception {
+ assertEquals("Continue", getSwagger(new OA01()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getDescription());
+ assertEquals("s-100-description", getSwaggerWithFile(new OA01()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getDescription());
+ }
+
+ @RestResource(swagger=@ResourceSwagger("paths:{'/path/{foo}/responses/100':{get:{responses:{100:{description:'a-100-description'}}}}}"))
+ public static class OA02 {
+ @RestMethod(name=GET,path="/path/{foo}/responses/100")
+ public Foo doFoo(@ResponseStatus Value<Integer> foo) {
+ return null;
+ }
+ }
+
+ @Test
+ public void oa02_response_100_description_swaggerOnClass() throws Exception {
+ assertEquals("a-100-description", getSwagger(new OA02()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getDescription());
+ assertEquals("a-100-description", getSwaggerWithFile(new OA02()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getDescription());
+ }
+
+ @RestResource(swagger=@ResourceSwagger("paths:{'/path/{foo}/responses/100':{get:{responses:{100:{description:'a-100-description'}}}}}"))
+ public static class OA03 {
+ @RestMethod(name=GET,path="/path/{foo}/responses/100",swagger=@MethodSwagger("responses:{100:{description:'b-100-description'}}"))
+ public Foo doFoo(@ResponseStatus Value<Integer> foo) {
+ return null;
+ }
+ }
+
+ @Test
+ public void oa03_response_100_description_swaggerOnMethod() throws Exception {
+ assertEquals("b-100-description", getSwagger(new OA03()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getDescription());
+ assertEquals("b-100-description", getSwaggerWithFile(new OA03()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getDescription());
+ }
+
+ @RestResource(swagger=@ResourceSwagger("paths:{'/path/{foo}/responses/100':{get:{responses:{100:{description:'a-100-description'}}}}}"))
+ public static class OA04 {
+ @RestMethod(name=GET,path="/path/{foo}/responses/100")
+ public Foo doFoo(@Response(code=100,description="c-100-description") Value<Foo> foo) {
+ return null;
+ }
+ }
+
+ @Test
+ public void oa04_response_100_description_swaggerOnAnnotation() throws Exception {
+ assertEquals("c-100-description", getSwagger(new OA04()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getDescription());
+ assertEquals("c-100-description", getSwaggerWithFile(new OA04()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getDescription());
+ }
+
+ @RestResource(messages="BasicRestInfoProviderTest", swagger=@ResourceSwagger("paths:{'/path/{foo}/responses/100':{get:{responses:{100:{description:'a-100-description'}}}}}"))
+ public static class OA05 {
+ @RestMethod(name=GET,path="/path/{foo}/responses/100")
+ public Foo doFoo(@Response(code=100,description="$L{foo}") Value<Foo> foo) {
+ return null;
+ }
+ }
+
+ @Test
+ public void oa05_response_100_description_swaggerOnAnnotation_localized() throws Exception {
+ assertEquals("l-foo", getSwagger(new OA05()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getDescription());
+ assertEquals("l-foo", getSwaggerWithFile(new OA05()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getDescription());
+ }
+
+ //-----------------------------------------------------------------------------------------------------------------
+ // /paths/<path>/<method>/responses/<response>/headers
+ //-----------------------------------------------------------------------------------------------------------------
+
+ @RestResource()
+ public static class OB01 {
+ @RestMethod(name=GET,path="/path/{foo}/responses/100")
+ public Foo doFoo(@Response(code=100) Value<Foo> foo) {
+ return null;
+ }
+ }
+
+ @Test
+ public void ob01_responses_100_headers_default() throws Exception {
+ assertEquals(null, getSwagger(new OB01()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getHeaders());
+ assertObjectEquals("{'X-Foo':{description:'s-description',type:'integer',format:'int32'}}", getSwaggerWithFile(new OB01()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getHeaders());
+ }
+
+ @RestResource(swagger=@ResourceSwagger("paths:{'/path/{foo}/responses/100':{get:{responses:{100:{headers:{'X-Foo':{description:'b-description',type:'integer',format:'int32'}}}}}}}"))
+ public static class OB02 {
+ @RestMethod(name=GET,path="/path/{foo}/responses/100")
+ public Foo doFoo(@ResponseStatus Value<Integer> foo) {
+ return null;
+ }
+ }
+
+ @Test
+ public void ob02_response_100_headers_swaggerOnClass() throws Exception {
+ assertObjectEquals("{'X-Foo':{description:'b-description',type:'integer',format:'int32'}}", getSwagger(new OB02()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getHeaders());
+ assertObjectEquals("{'X-Foo':{description:'b-description',type:'integer',format:'int32'}}", getSwaggerWithFile(new OB02()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getHeaders());
+ }
+
+ @RestResource(swagger=@ResourceSwagger("paths:{'/path/{foo}/responses/100':{get:{responses:{100:{headers:{'X-Foo':{description:'b-description',type:'integer',format:'int32'}}}}}}}"))
+ public static class OB03 {
+ @RestMethod(name=GET,path="/path/{foo}/responses/100",swagger=@MethodSwagger("responses:{100:{headers:{'X-Foo':{description:'c-description',type:'integer',format:'int32'}}}}"))
+ public Foo doFoo(@ResponseStatus Value<Integer> foo) {
+ return null;
+ }
+ }
+
+ @Test
+ public void ob03_response_100_headers_swaggerOnMethod() throws Exception {
+ assertObjectEquals("{'X-Foo':{description:'c-description',type:'integer',format:'int32'}}", getSwagger(new OB03()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getHeaders());
+ assertObjectEquals("{'X-Foo':{description:'c-description',type:'integer',format:'int32'}}", getSwaggerWithFile(new OB03()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getHeaders());
+ }
+
+ @RestResource(swagger=@ResourceSwagger("paths:{'/path/{foo}/responses/100':{get:{responses:{100:{headers:{'X-Foo':{description:'b-description',type:'integer',format:'int32'}}}}}}}"))
+ public static class OB04 {
+ @RestMethod(name=GET,path="/path/{foo}/responses/100")
+ public Foo doFoo(@Response(code=100,headers="'X-Foo':{description:'d-description',type:'integer',format:'int32'}") Value<Foo> foo) {
+ return null;
+ }
+ }
+
+ @Test
+ public void ob04_response_100_headers_swaggerOnAnnotation() throws Exception {
+ assertObjectEquals("{'X-Foo':{description:'d-description',type:'integer',format:'int32'}}", getSwagger(new OB04()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getHeaders());
+ assertObjectEquals("{'X-Foo':{description:'d-description',type:'integer',format:'int32'}}", getSwaggerWithFile(new OB04()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getHeaders());
+ }
+
+ @RestResource(messages="BasicRestInfoProviderTest", swagger=@ResourceSwagger("paths:{'/path/{foo}/responses/100':{get:{responses:{100:{headers:{'X-Foo':{description:'b-description',type:'integer',format:'int32'}}}}}}}"))
+ public static class OB05 {
+ @RestMethod(name=GET,path="/path/{foo}/responses/100")
+ public Foo doFoo(@Response(code=100,headers="'X-Foo':{description:'$L{foo}',type:'integer',format:'int32'}") Value<Foo> foo) {
+ return null;
+ }
+ }
+
+ @Test
+ public void ob05_response_100_headers_swaggerOnAnnotation_localized() throws Exception {
+ assertObjectEquals("{'X-Foo':{description:'l-foo',type:'integer',format:'int32'}}", getSwagger(new OB05()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getHeaders());
+ assertObjectEquals("{'X-Foo':{description:'l-foo',type:'integer',format:'int32'}}", getSwaggerWithFile(new OB05()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getHeaders());
+ }
+
+ //-----------------------------------------------------------------------------------------------------------------
+ // /paths/<path>/<method>/responses/<response>/example
+ //-----------------------------------------------------------------------------------------------------------------
+
+ @RestResource()
+ public static class OC01 {
+ @RestMethod(name=GET,path="/path/{foo}/responses/100")
+ public Foo doFoo(@Response(code=100) Value<Foo> foo) {
+ return null;
+ }
+ }
+
+ @Test
+ public void oc01_responses_100_example_default() throws Exception {
+ assertEquals(null, getSwagger(new OC01()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getExample());
+ assertObjectEquals("{foo:'a'}", getSwaggerWithFile(new OC01()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getExample());
+ }
+
+ @RestResource(swagger=@ResourceSwagger("paths:{'/path/{foo}/responses/100':{get:{responses:{100:{example:{foo:'b'}}}}}}"))
+ public static class OC02 {
+ @RestMethod(name=GET,path="/path/{foo}/responses/100")
+ public Foo doFoo(@ResponseStatus Value<Integer> foo) {
+ return null;
+ }
+ }
+
+ @Test
+ public void oc02_response_100_example_swaggerOnClass() throws Exception {
+ assertObjectEquals("{foo:'b'}", getSwagger(new OC02()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getExample());
+ assertObjectEquals("{foo:'b'}", getSwaggerWithFile(new OC02()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getExample());
+ }
+
+ @RestResource(swagger=@ResourceSwagger("paths:{'/path/{foo}/responses/100':{get:{responses:{100:{example:{foo:'b'}}}}}}"))
+ public static class OC03 {
+ @RestMethod(name=GET,path="/path/{foo}/responses/100",swagger=@MethodSwagger("responses:{100:{example:{foo:'c'}}}"))
+ public Foo doFoo(@ResponseStatus Value<Integer> foo) {
+ return null;
+ }
+ }
+
+ @Test
+ public void oc03_response_100_example_swaggerOnMethod() throws Exception {
+ assertObjectEquals("{foo:'c'}", getSwagger(new OC03()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getExample());
+ assertObjectEquals("{foo:'c'}", getSwaggerWithFile(new OC03()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getExample());
+ }
+
+ @RestResource(swagger=@ResourceSwagger("paths:{'/path/{foo}/responses/100':{get:{responses:{100:{example:{foo:'b'}}}}}}"))
+ public static class OC04 {
+ @RestMethod(name=GET,path="/path/{foo}/responses/100")
+ public Foo doFoo(@Response(code=100,example="{foo:'d'}") Value<Foo> foo) {
+ return null;
+ }
+ }
+
+ @Test
+ public void oc04_response_100_example_swaggerOnAnnotation() throws Exception {
+ assertObjectEquals("{foo:'d'}", getSwagger(new OC04()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getExample());
+ assertObjectEquals("{foo:'d'}", getSwaggerWithFile(new OC04()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getExample());
+ }
+
+ @RestResource(messages="BasicRestInfoProviderTest", swagger=@ResourceSwagger("paths:{'/path/{foo}/responses/100':{get:{responses:{100:{example:{foo:'b'}}}}}}"))
+ public static class OC05 {
+ @RestMethod(name=GET,path="/path/{foo}/responses/100")
+ public Foo doFoo(@Response(code=100,example="{foo:'$L{foo}'}") Value<Foo> foo) {
+ return null;
+ }
+ }
+
+ @Test
+ public void oc05_response_100_example_swaggerOnAnnotation_localized() throws Exception {
+ assertObjectEquals("{foo:'l-foo'}", getSwagger(new OC05()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getExample());
+ assertObjectEquals("{foo:'l-foo'}", getSwaggerWithFile(new OC05()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getExample());
+ }
+
+ //-----------------------------------------------------------------------------------------------------------------
+ // /paths/<path>/<method>/responses/<response>/examples
+ //-----------------------------------------------------------------------------------------------------------------
+
+ @RestResource()
+ public static class OD01 {
+ @RestMethod(name=GET,path="/path/{foo}/responses/100")
+ public Foo doFoo(@Response(code=100) Value<Foo> foo) {
+ return null;
+ }
+ }
+
+ @Test
+ public void od01_responses_100_examples_default() throws Exception {
+ assertEquals(null, getSwagger(new OD01()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getExamples());
+ assertObjectEquals("{foo:'a'}", getSwaggerWithFile(new OD01()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getExamples());
+ }
+
+ @RestResource(swagger=@ResourceSwagger("paths:{'/path/{foo}/responses/100':{get:{responses:{100:{examples:{foo:{bar:'b'}}}}}}}"))
+ public static class OD02 {
+ @RestMethod(name=GET,path="/path/{foo}/responses/100")
+ public Foo doFoo(@ResponseStatus Value<Integer> foo) {
+ return null;
+ }
+ }
+
+ @Test
+ public void od02_response_100_examples_swaggerOnClass() throws Exception {
+ assertObjectEquals("{foo:{bar:'b'}}", getSwagger(new OD02()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getExamples());
+ assertObjectEquals("{foo:{bar:'b'}}", getSwaggerWithFile(new OD02()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getExamples());
+ }
+
+ @RestResource(swagger=@ResourceSwagger("paths:{'/path/{foo}/responses/100':{get:{responses:{100:{examples:{foo:{bar:'b'}}}}}}}"))
+ public static class OD03 {
+ @RestMethod(name=GET,path="/path/{foo}/responses/100",swagger=@MethodSwagger("responses:{100:{examples:{foo:{bar:'c'}}}}"))
+ public Foo doFoo(@ResponseStatus Value<Integer> foo) {
+ return null;
+ }
+ }
+
+ @Test
+ public void od03_response_100_examples_swaggerOnMethod() throws Exception {
+ assertObjectEquals("{foo:{bar:'c'}}", getSwagger(new OD03()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getExamples());
+ assertObjectEquals("{foo:{bar:'c'}}", getSwaggerWithFile(new OD03()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getExamples());
+ }
+
+ @RestResource(swagger=@ResourceSwagger("paths:{'/path/{foo}/responses/100':{get:{responses:{100:{examples:{foo:{bar:'b'}}}}}}}"))
+ public static class OD04 {
+ @RestMethod(name=GET,path="/path/{foo}/responses/100")
+ public Foo doFoo(@Response(code=100,examples="{foo:{bar:'d'}}") Value<Foo> foo) {
+ return null;
+ }
+ }
+
+ @Test
+ public void od04_response_100_examples_swaggerOnAnnotation() throws Exception {
+ assertObjectEquals("{foo:{bar:'d'}}", getSwagger(new OD04()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getExamples());
+ assertObjectEquals("{foo:{bar:'d'}}", getSwaggerWithFile(new OD04()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getExamples());
+ }
+
+ @RestResource(messages="BasicRestInfoProviderTest", swagger=@ResourceSwagger("paths:{'/path/{foo}/responses/100':{get:{responses:{100:{examples:{foo:{bar:'b'}}}}}}}"))
+ public static class OD05 {
+ @RestMethod(name=GET,path="/path/{foo}/responses/100")
+ public Foo doFoo(@Response(code=100,examples="{foo:{bar:'$L{foo}'}}") Value<Foo> foo) {
+ return null;
+ }
+ }
+
+ @Test
+ public void od05_response_100_examples_swaggerOnAnnotation_lodalized() throws Exception {
+ assertObjectEquals("{foo:{bar:'l-foo'}}", getSwagger(new OD05()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getExamples());
+ assertObjectEquals("{foo:{bar:'l-foo'}}", getSwaggerWithFile(new OD05()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getExamples());
+ }
+
+ //-----------------------------------------------------------------------------------------------------------------
+ // /paths/<path>/<method>/responses/<response>/schema
+ //-----------------------------------------------------------------------------------------------------------------
+
+ // TODO
+
- // paths: {
-// '/path/{foo}': {
-// get: {
-// summary: 's-summary',
-// description: 's-description',
-// operationId: 's-operationId',
-// deprecated: true,
-// consumes: ['s-consumes'],
-// produces: ['s-produces'],
-// tags: ['s-tag'],
-// schemes: ['s-scheme'],
-// externalDocs: {
-// description: 's-description',
-// url: 's-url'
-// },
-// parameters: [
-// {
-// name: 's-query-name',
-// in: 'query',
-// description: 's-description',
-// type: 'string',
-// format: 's-format',
-// pattern: 's-pattern',
-// collectionFormat: 's-collectionFormat',
-// minimum: 1.0,
-// maximum: 2.0,
-// multipleOf: 3.0,
-// minLength: 1,
-// maxLength: 2,
-// minItems: 3,
-// maxItems: 4,
-// required: true,
-// allowEmptyValue: true,
-// exclusiveMinimum: true,
-// exclusiveMaximum: true,
-// uniqueItems: true,
-// schemaInfo: {
-// }
-// },
-// {
-// name: 's-header-name',
-// in: 'header',
-// description: 's-description',
-// type: 'string',
-// format: 's-format',
-// pattern: 's-pattern',
-// collectionFormat: 's-collectionFormat',
-// minimum: 1.0,
-// maximum: 2.0,
-// multipleOf: 3.0,
-// minLength: 1,
-// maxLength: 2,
-// minItems: 3,
-// maxItems: 4,
-// required: true,
-// allowEmptyValue: true,
-// exclusiveMinimum: true,
-// exclusiveMaximum: true,
-// uniqueItems: true,
-// schemaInfo: {
-// $ref: '#/definitions/Foo'
-// }
-// },
-// {
-// name: 's-path-name',
-// in: 'path',
-// description: 's-description',
-// type: 'string',
-// format: 's-format',
-// pattern: 's-pattern',
-// collectionFormat: 's-collectionFormat',
-// minimum: 1.0,
-// maximum: 2.0,
-// multipleOf: 3.0,
-// minLength: 1,
-// maxLength: 2,
-// minItems: 3,
-// maxItems: 4,
-// required: true,
-// allowEmptyValue: true,
-// exclusiveMinimum: true,
-// exclusiveMaximum: true,
-// uniqueItems: true,
-// schemaInfo: {
-// $ref: '#/definitions/Foo'
-// }
-// },
-// {
-// name: 's-formData-name',
-// in: 'formData',
-// description: 's-description',
-// type: 'string',
-// format: 's-format',
-// pattern: 's-pattern',
-// collectionFormat: 's-collectionFormat',
-// minimum: 1.0,
-// maximum: 2.0,
-// multipleOf: 3.0,
-// minLength: 1,
-// maxLength: 2,
-// minItems: 3,
-// maxItems: 4,
-// required: true,
-// allowEmptyValue: true,
-// exclusiveMinimum: true,
-// exclusiveMaximum: true,
-// uniqueItems: true,
-// schemaInfo: {
-// $ref: '#/definitions/Foo'
-// }
-// },
-// {
-// name: 's-body-name',
-// in: 'body',
-// description: 's-description',
-// type: 'string',
-// format: 's-format',
-// pattern: 's-pattern',
-// collectionFormat: 's-collectionFormat',
-// minimum: 1.0,
-// maximum: 2.0,
-// multipleOf: 3.0,
-// minLength: 1,
-// maxLength: 2,
-// minItems: 3,
-// maxItems: 4,
-// required: true,
-// allowEmptyValue: true,
-// exclusiveMinimum: true,
-// exclusiveMaximum: true,
-// uniqueItems: true,
-// schemaInfo: {
-// $ref: '#/definitions/Foo'
-// }
-// }
-// ],
-// responses: {
-// 100: {
-// description:'s-100-description',
-// schema: {
-// type: array,
-// items: {
-// $ref: '#/definitions/Foo'
-// }
-// },
-// headers: {
-// X-Foo: {
-// type: 'integer',
-// format: 'int32',
-// description: 's-description'
-// }
-// },
-// examples: {
-// foo: {bar:123},
-// bar: 'baz'
-// }
-// }
-// },
-// security: [
-// {foo_auth:['read:foo','write-foo']}
-// ]
-// }
-// }
-// },
-// definitions: {
-// Foo: {
-// type: 'object',
-// properties: {
-// id: {
-// type: 'integer',
-// format: 'int64'
-// }
-// },
-// xml: {
-// name: 'Foo'
-// }
-// }
-// }
@Bean(typeName="Foo")
public static class Foo {
diff --git a/juneau-rest/juneau-rest-server/src/test/resources/org/apache/juneau/rest/BasicRestInfoProviderTest.properties b/juneau-rest/juneau-rest-server/src/test/resources/org/apache/juneau/rest/BasicRestInfoProviderTest.properties
index cea1452..8d2e2c4 100644
--- a/juneau-rest/juneau-rest-server/src/test/resources/org/apache/juneau/rest/BasicRestInfoProviderTest.properties
+++ b/juneau-rest/juneau-rest-server/src/test/resources/org/apache/juneau/rest/BasicRestInfoProviderTest.properties
@@ -14,4 +14,6 @@
foo = l-foo
bar = l-bar
-baz = l-baz
\ No newline at end of file
+baz = l-baz
+50 = 5.0
+5 = 5
\ No newline at end of file
diff --git a/juneau-rest/juneau-rest-server/src/test/resources/org/apache/juneau/rest/BasicRestInfoProviderTest_swagger.json b/juneau-rest/juneau-rest-server/src/test/resources/org/apache/juneau/rest/BasicRestInfoProviderTest_swagger.json
index 5047b03..7db7fe2 100644
--- a/juneau-rest/juneau-rest-server/src/test/resources/org/apache/juneau/rest/BasicRestInfoProviderTest_swagger.json
+++ b/juneau-rest/juneau-rest-server/src/test/resources/org/apache/juneau/rest/BasicRestInfoProviderTest_swagger.json
@@ -68,7 +68,7 @@
get: {
parameters: [
{
- name: 's-query-name',
+ name: 'foo',
in: 'query',
description: 's-description',
type: 'string',
@@ -76,110 +76,23 @@
pattern: 's-pattern',
collectionFormat: 's-collectionFormat',
minimum: 1.0,
- maximum: 2.0,
- multipleOf: 3.0,
+ maximum: 1.0,
+ multipleOf: 1.0,
minLength: 1,
- maxLength: 2,
- minItems: 3,
- maxItems: 4,
+ maxLength: 1,
+ minItems: 1,
+ maxItems: 1,
required: true,
allowEmptyValue: true,
exclusiveMinimum: true,
exclusiveMaximum: true,
uniqueItems: true,
- schemaInfo: {
- $ref: '#/definitions/Foo'
- }
- }
- ]
- }
- },
- '/path/{foo}/header': {
- get: {
- parameters: [
- {
- name: 's-header-name',
- in: 'header',
- description: 's-description',
- type: 'string',
- format: 's-format',
- pattern: 's-pattern',
- collectionFormat: 's-collectionFormat',
- minimum: 1.0,
- maximum: 2.0,
- multipleOf: 3.0,
- minLength: 1,
- maxLength: 2,
- minItems: 3,
- maxItems: 4,
- required: true,
- allowEmptyValue: true,
- exclusiveMinimum: true,
- exclusiveMaximum: true,
- uniqueItems: true,
- schemaInfo: {
- $ref: '#/definitions/Foo'
- }
- }
- ]
- }
- },
- '/path/{foo}/path': {
- get: {
- parameters: [
- {
- name: 's-path-name',
- in: 'path',
- description: 's-description',
- type: 'string',
- format: 's-format',
- pattern: 's-pattern',
- collectionFormat: 's-collectionFormat',
- minimum: 1.0,
- maximum: 2.0,
- multipleOf: 3.0,
- minLength: 1,
- maxLength: 2,
- minItems: 3,
- maxItems: 4,
- required: true,
- allowEmptyValue: true,
- exclusiveMinimum: true,
- exclusiveMaximum: true,
- uniqueItems: true,
- schemaInfo: {
- $ref: '#/definitions/Foo'
- }
- }
- ]
- }
- },
- '/path/{foo}/formData': {
- get: {
- parameters: [
- {
- name: 's-formData-name',
- in: 'formData',
- description: 's-description',
- type: 'string',
- format: 's-format',
- pattern: 's-pattern',
- collectionFormat: 's-collectionFormat',
- minimum: 1.0,
- maximum: 2.0,
- multipleOf: 3.0,
- minLength: 1,
- maxLength: 2,
- minItems: 3,
- maxItems: 4,
- required: true,
- allowEmptyValue: true,
- exclusiveMinimum: true,
- exclusiveMaximum: true,
- uniqueItems: true,
- schemaInfo: {
+ schema: {
$ref: '#/definitions/Foo'
- }
+ },
+ 'x-example': {
+ id:1
+ }
}
]
}
@@ -188,7 +101,6 @@
get: {
parameters: [
{
- name: 's-body-name',
in: 'body',
description: 's-description',
type: 'string',
@@ -196,19 +108,24 @@
pattern: 's-pattern',
collectionFormat: 's-collectionFormat',
minimum: 1.0,
- maximum: 2.0,
- multipleOf: 3.0,
+ maximum: 1.0,
+ multipleOf: 1.0,
minLength: 1,
- maxLength: 2,
- minItems: 3,
- maxItems: 4,
- required: true,
+ maxLength: 1,
+ minItems: 1,
+ maxItems: 1,
allowEmptyValue: true,
exclusiveMinimum: true,
exclusiveMaximum: true,
uniqueItems: true,
- schemaInfo: {
+ schema: {
$ref: '#/definitions/Foo'
+ },
+ 'x-example': {
+ id:1
+ },
+ 'x-examples': {
+ foo: 'a'
}
}
]
@@ -232,9 +149,9 @@
description: 's-description'
}
},
+ x-example: {foo:'a'},
examples: {
- foo: {bar:123},
- bar: 'baz'
+ foo: 'a'
}
}
}
--
To stop receiving notification emails like this one, please contact
jamesbognar@apache.org.