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 9efaf86 Tests.
9efaf86 is described below
commit 9efaf865fbe1bd657bcf76558ad6f67e0313e804
Author: JamesBognar <[email protected]>
AuthorDate: Sun May 6 14:34:03 2018 -0400
Tests.
---
.../apache/juneau/rest/BasicRestInfoProvider.java | 2 +-
.../java/org/apache/juneau/rest/RestContext.java | 28 +-
.../org/apache/juneau/rest/RestMethodThrown.java | 1 +
.../org/apache/juneau/rest/RestParamDefaults.java | 8 +-
.../juneau/rest/annotation/ResponseHeaders.java | 37 --
.../juneau/rest/annotation/ResponseStatus.java | 170 ++----
.../juneau/rest/annotation/ResponseStatuses.java | 37 --
.../{ResponseStatus.java => Status.java} | 21 +-
.../juneau/rest/BasicRestInfoProviderTest.java | 663 +++++++++++++++++++--
9 files changed, 679 insertions(+), 288 deletions(-)
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 82b35bd..148bdca 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
@@ -64,7 +64,7 @@ public class BasicRestInfoProvider implements
RestInfoProvider {
*
* <h5 class='section'>Property:</h5>
* <ul>
- * <li><b>Name:</b> <js>"BasicRestInfoProvider.ignoreTypes.b"</js>
+ * <li><b>Name:</b> <js>"BasicRestInfoProvider.ignoreTypes.s"</js>
* <li><b>Data type:</b> <code>String</code> (comma-delimited)
* <li><b>Default:</b> <jk>null</jk>.
* <li><b>Session-overridable:</b> <jk>false</jk>
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 3e8e096..e8f258d 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
@@ -4295,17 +4295,15 @@ public final class RestContext extends BeanContext {
rp[i] = new
RestParamDefaults.ResponseObject(method, (Response)a, t, ps, rp[i]);
else if (a instanceof ResponseHeader)
rp[i] = new
RestParamDefaults.ResponseHeaderObject(method, (ResponseHeader)a, t, ps,
rp[i]);
- else if (a instanceof ResponseStatus)
- rp[i] = new
RestParamDefaults.ResponseStatusObject(method, (ResponseStatus)a, t, ps,
rp[i]);
else if (a instanceof Responses)
for (Response r :
((Responses)a).value())
rp[i] = new
RestParamDefaults.ResponseObject(method, r, t, ps, rp[i]);
- else if (a instanceof ResponseStatuses)
- for (ResponseStatus rs :
((ResponseStatuses)a).value())
+ else if (a instanceof ResponseStatus) {
+ for (Status rs :
((ResponseStatus)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)
+ rp[i] = new
RestParamDefaults.ResponseStatusObject(method, null, t, ps, rp[i]);
+ }
}
}
@@ -4332,21 +4330,19 @@ public final class RestContext extends BeanContext {
rp[i] = new
RestParamDefaults.ResponseObject(method, (Response)a, t, ps, rp[i]);
else if (a instanceof ResponseHeader)
rp[i] = new
RestParamDefaults.ResponseHeaderObject(method, (ResponseHeader)a, t, ps, rp[i]);
- else if (a instanceof ResponseStatus)
- rp[i] = new
RestParamDefaults.ResponseStatusObject(method, (ResponseStatus)a, t, ps, rp[i]);
else if (a instanceof Responses)
for (Response r :
((Responses)a).value())
rp[i] = new
RestParamDefaults.ResponseObject(method, r, t, ps, rp[i]);
- 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]);
+ else if (a instanceof ResponseStatus) {
+ for (Status rs :
((ResponseStatus)a).value())
+ rp[i] = new
RestParamDefaults.ResponseStatusObject(method, rs, t, ps, rp[i]);
+ if (rp[i] == null)
+ rp[i] = new
RestParamDefaults.ResponseStatusObject(method, null, t, ps, rp[i]);
+ }
}
if (rp[i] == null) {
- if (isPreOrPost)
+ if (! isPreOrPost)
throw new RestServletException("Invalid
parameter specified for method ''{0}'' at index position {1}", method, i);
} else {
rp[i].validate();
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestMethodThrown.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestMethodThrown.java
index 7fb8e73..a7c7dc1 100644
---
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestMethodThrown.java
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestMethodThrown.java
@@ -38,6 +38,7 @@ public class RestMethodThrown {
code = ObjectUtils.firstNonZero(ri.code(), ri.value(),
code);
metaData.appendSkipEmpty("description",
joinnl(ri.description()));
metaData.appendSkipEmpty("example",
joinnl(ri.example()));
+ metaData.appendSkipEmpty("examples",
joinnl(ri.examples()));
metaData.appendSkipEmpty("headers",
joinnl(ri.headers()));
metaData.appendSkipEmpty("schema", joinnl(ri.schema()));
}
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 d8caed2..3d6770b 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
@@ -819,7 +819,7 @@ class RestParamDefaults {
static final class ResponseStatusObject extends RestMethodParam {
- protected ResponseStatusObject(Method method, ResponseStatus a,
Type type, PropertyStore ps, RestMethodParam existing) {
+ protected ResponseStatusObject(Method method, Status a, Type
type, PropertyStore ps, RestMethodParam existing) {
super(RESPONSE_STATUS, "", type, getMetaData(a,
castOrNull(existing, ResponseStatusObject.class)));
}
@@ -845,14 +845,14 @@ class RestParamDefaults {
return v;
} catch (Exception e) {
- throw new RestException(500,
"Invalid type {0} specified with @ResponseStatus annotation. It must have a
public no-arg constructor.", type);
+ throw new RestException(500,
"Invalid type {0} specified with @Status annotation. It must have a public
no-arg constructor.", type);
}
}
}
- throw new RestException(500, "Invalid type {0}
specified with @ResponseStatus annotation. It must be a subclass of Value.",
type);
+ throw new RestException(500, "Invalid type {0}
specified with @Status annotation. It must be a subclass of Value.", type);
}
- private static ObjectMap getMetaData(ResponseStatus a,
ResponseStatusObject existing) {
+ private static ObjectMap getMetaData(Status a,
ResponseStatusObject existing) {
ObjectMap om = existing == null ? new ObjectMap() :
existing.metaData;
if (a == null)
return om;
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
deleted file mode 100644
index bc4ca8d..0000000
---
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/ResponseHeaders.java
+++ /dev/null
@@ -1,37 +0,0 @@
-//
***************************************************************************************************************************
-// * Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file *
-// * distributed with this work for additional information regarding copyright
ownership. The ASF licenses this file *
-// * to you under the Apache License, Version 2.0 (the "License"); you may not
use this file except in compliance *
-// * with the License. You may obtain a copy of the License at
*
-// *
*
-// * http://www.apache.org/licenses/LICENSE-2.0
*
-// *
*
-// * Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an *
-// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
express or implied. See the License for the *
-// * specific language governing permissions and limitations under the
License. *
-//
***************************************************************************************************************************
-package org.apache.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/annotation/ResponseStatus.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/ResponseStatus.java
index b97ff9f..a06a94c 100644
---
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/ResponseStatus.java
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/ResponseStatus.java
@@ -1,133 +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.*;
-
-import org.apache.juneau.utils.*;
-
-/**
- * Annotation that can be applied to parameters and types to denote them as an
HTTP response status.
- *
- * <p>
- * This can only be applied to parameters and subclasses of the {@link Value}
class with an {@link Integer} type.
- * <br>The {@link Value} object is mean to be a place-holder for the set value.
- *
- * <p class='bcode'>
- * <ja>@RestMethod</ja>(name=<js>"GET"</js>, path=<js>"/user/login"</js>)
- * <jk>public void</jk> login(String username, String password,
- * <ja>@ResponseStatus</ja>(code=401,
description=<js>"Invalid user/pw"</js>) Value<Integer> status) {
- * <jk>if</jk> (! isValid(username, password))
- * status.set(401);
- * }
- * </p>
- *
- * <p>
- * The {@link Responses @Responses} annotation can be used to represent
multiple possible response types.
- *
- * <p class='bcode'>
- * <ja>@RestMethod</ja>(name=<js>"GET"</js>, path=<js>"/user/login"</js>)
- * <jk>public void</jk> login(String username, String password,
- * <ja>@ResponseStatuses</ja>{
- * <ja>@ResponseStatus</ja>(200)
- * <ja>@ResponseStatus</ja>(code=401,
description=<js>"Invalid user/pw"</js>)
- * }
- * Value<Integer> status) {
- *
- * <jk>if</jk> (! isValid(username, password))
- * status.set(401);
- * <jk>else</jk>
- * status.set(200);
- * }
- * </p>
- *
- * <p>
- * The other option is to apply this annotation to a subclass of {@link Value}
which often leads to a cleaner
- * REST method:
- *
- * <p class='bcode'>
- * <ja>@ResponseStatuses</ja>{
- * <ja>@ResponseStatus</ja>(200)
- * <ja>@ResponseStatus</ja>(code=401, description=<js>"Invalid
user/pw"</js>)
- * }
- * <jk>public class</jk> LoginStatus <jk>extends</jk> Value<Integer>
{}
- *
- * <ja>@RestMethod</ja>(name=<js>"GET"</js>, path=<js>"/user/login"</js>)
- * <jk>public void</jk> login(String username, String password,
LoginStatus status) {
- * <jk>if</jk> (! isValid(username, password))
- * status.set(401);
- * <jk>else</jk>
- * status.set(200);
- * }
- * </p>
- *
- * <p>
- * The attributes on this annotation are used to populate the generated
Swagger for the method.
- * <br>In this case, the Swagger is populated with the following:
- *
- * <p class='bcode'>
- * <js>'/user/login'</js>: {
- * get: {
- * responses: {
- * 200: {
- * description: <js>'OK'</js>
- * },
- * 401: {
- * description: <js>'Invalid user/pw'</js>
- * }
- * }
- * }
- * }
- * </p>
- */
-@Documented
-@Target({PARAMETER,TYPE})
-@Retention(RUNTIME)
-@Inherited
-public @interface ResponseStatus {
-
- /**
- * The HTTP status of the response.
- */
- int code() default 0;
-
- /**
- * A synonym to {@link #code()}.
- *
- * <p>
- * Useful if you only want to specify a code only.
- *
- * <p class='bcode'>
- * <ja>@ResponseStatus</ja>(200)
- * </p>
- */
- int value() default 0;
-
- /**
- * Defines the swagger value
<code>/paths/{path}/{method}/responses/{status-code}/description</code>.
- *
- * <h5 class='section'>Notes:</h5>
- * <ul class='spaced-list'>
- * <li>
- * The format of the value is plain-text.
- * <br>Multiple lines are concatenated with newlines.
- * <li>
- * Supports <a class="doclink"
href="../../../../../overview-summary.html#DefaultRestSvlVariables">initialization-time
and request-time variables</a>
- * (e.g. <js>"$L{my.localized.variable}"</js>).
- * </ul>
- */
- String[] description() default {};
-}
+//
***************************************************************************************************************************
+// * 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 Status @Status} 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 ResponseStatus {
+
+ /**
+ * Specifies one or more {@link Status @Status} annotations to apply to
the same parameter or class.
+ */
+ Status[] value() default {};
+}
\ No newline at end of file
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/ResponseStatuses.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/ResponseStatuses.java
deleted file mode 100644
index 1111aeb..0000000
---
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/ResponseStatuses.java
+++ /dev/null
@@ -1,37 +0,0 @@
-//
***************************************************************************************************************************
-// * Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file *
-// * distributed with this work for additional information regarding copyright
ownership. The ASF licenses this file *
-// * to you under the Apache License, Version 2.0 (the "License"); you may not
use this file except in compliance *
-// * with the License. You may obtain a copy of the License at
*
-// *
*
-// * http://www.apache.org/licenses/LICENSE-2.0
*
-// *
*
-// * Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an *
-// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
express or implied. See the License for the *
-// * specific language governing permissions and limitations under the
License. *
-//
***************************************************************************************************************************
-package org.apache.juneau.rest.annotation;
-
-import static java.lang.annotation.ElementType.*;
-import static java.lang.annotation.RetentionPolicy.*;
-
-import java.lang.annotation.*;
-
-/**
- * Used to associate multiple {@link ResponseStatus @ResponseStatus}
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 ResponseStatuses {
-
- /**
- * Specifies one or more {@link ResponseStatus @ResponseStatus}
annotations to apply to the same parameter or class.
- */
- ResponseStatus[] value() default {};
-}
\ No newline at end of file
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/ResponseStatus.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/Status.java
similarity index 89%
copy from
juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/ResponseStatus.java
copy to
juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/Status.java
index b97ff9f..e8aedd0 100644
---
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/ResponseStatus.java
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/Status.java
@@ -12,7 +12,6 @@
//
***************************************************************************************************************************
package org.apache.juneau.rest.annotation;
-import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.*;
import java.lang.annotation.*;
@@ -29,7 +28,7 @@ import org.apache.juneau.utils.*;
* <p class='bcode'>
* <ja>@RestMethod</ja>(name=<js>"GET"</js>, path=<js>"/user/login"</js>)
* <jk>public void</jk> login(String username, String password,
- * <ja>@ResponseStatus</ja>(code=401,
description=<js>"Invalid user/pw"</js>) Value<Integer> status) {
+ * <ja>@Status</ja>(code=401, description=<js>"Invalid
user/pw"</js>) Value<Integer> status) {
* <jk>if</jk> (! isValid(username, password))
* status.set(401);
* }
@@ -41,9 +40,9 @@ import org.apache.juneau.utils.*;
* <p class='bcode'>
* <ja>@RestMethod</ja>(name=<js>"GET"</js>, path=<js>"/user/login"</js>)
* <jk>public void</jk> login(String username, String password,
- * <ja>@ResponseStatuses</ja>{
- * <ja>@ResponseStatus</ja>(200)
- * <ja>@ResponseStatus</ja>(code=401,
description=<js>"Invalid user/pw"</js>)
+ * <ja>@ResponseStatus</ja>{
+ * <ja>@Status</ja>(200)
+ * <ja>@Status</ja>(code=401,
description=<js>"Invalid user/pw"</js>)
* }
* Value<Integer> status) {
*
@@ -59,9 +58,9 @@ import org.apache.juneau.utils.*;
* REST method:
*
* <p class='bcode'>
- * <ja>@ResponseStatuses</ja>{
- * <ja>@ResponseStatus</ja>(200)
- * <ja>@ResponseStatus</ja>(code=401, description=<js>"Invalid
user/pw"</js>)
+ * <ja>@ResponseStatus</ja>{
+ * <ja>@Status</ja>(200)
+ * <ja>@Status</ja>(code=401, description=<js>"Invalid
user/pw"</js>)
* }
* <jk>public class</jk> LoginStatus <jk>extends</jk> Value<Integer>
{}
*
@@ -94,10 +93,10 @@ import org.apache.juneau.utils.*;
* </p>
*/
@Documented
-@Target({PARAMETER,TYPE})
+@Target({})
@Retention(RUNTIME)
@Inherited
-public @interface ResponseStatus {
+public @interface Status {
/**
* The HTTP status of the response.
@@ -111,7 +110,7 @@ public @interface ResponseStatus {
* Useful if you only want to specify a code only.
*
* <p class='bcode'>
- * <ja>@ResponseStatus</ja>(200)
+ * <ja>@Status</ja>(200)
* </p>
*/
int value() default 0;
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 4583cd2..de66bc6 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
@@ -5360,15 +5360,15 @@ public class BasicRestInfoProviderTest {
assertEquals("P", getSwagger(new
SB()).getPaths().get("/name/{P}").get("get").getParameter("path",
"P").getName());
}
@Test
- public void sb02_Path_onParameter_() throws Exception {
+ public void sb02_Path_onParameter_value() throws Exception {
assertEquals("P", getSwagger(new
SB()).getPaths().get("/value/{P}").get("get").getParameter("path",
"P").getName());
}
@Test
- public void sb03_Path_onParameter_() throws Exception {
+ public void sb03_Path_onParameter_description1() throws Exception {
assertEquals("a", getSwagger(new
SB()).getPaths().get("/description1/{P}").get("get").getParameter("path",
"P").getDescription());
}
@Test
- public void sb04_Path_onParameter_() throws Exception {
+ public void sb04_Path_onParameter_description2() throws Exception {
assertEquals("a\nb", getSwagger(new
SB()).getPaths().get("/description2/{P}").get("get").getParameter("path",
"P").getDescription());
}
@Test
@@ -5384,7 +5384,7 @@ public class BasicRestInfoProviderTest {
assertEquals("a", getSwagger(new
SB()).getPaths().get("/pattern/{P}").get("get").getParameter("path",
"P").getPattern());
}
@Test
- public void sb08_Path_onParameter_() throws Exception {
+ public void sb08_Path_onParameter_maximum() throws Exception {
assertObjectEquals("1", getSwagger(new
SB()).getPaths().get("/maximum/{P}").get("get").getParameter("path",
"P").getMaximum());
}
@Test
@@ -5392,11 +5392,11 @@ public class BasicRestInfoProviderTest {
assertObjectEquals("1", getSwagger(new
SB()).getPaths().get("/minimum/{P}").get("get").getParameter("path",
"P").getMinimum());
}
@Test
- public void sb10_Path_onParameter_() throws Exception {
+ public void sb10_Path_onParameter_multipleOf() throws Exception {
assertObjectEquals("1", getSwagger(new
SB()).getPaths().get("/multipleOf/{P}").get("get").getParameter("path",
"P").getMultipleOf());
}
@Test
- public void sb11_Path_onParameter_() throws Exception {
+ public void sb11_Path_onParameter_maxLength() throws Exception {
assertObjectEquals("1", getSwagger(new
SB()).getPaths().get("/maxLength/{P}").get("get").getParameter("path",
"P").getMaxLength());
}
@Test
@@ -6023,82 +6023,650 @@ public class BasicRestInfoProviderTest {
@RestResource()
public static class UA {
-// int code() default 0;
-// int value() default 0;
-// String[] description() default {};
-// String[] schema() default {};
-// String[] headers() default {};
-// String[] example() default {};
-// String[] examples() default {};
+
+ @Response(code=100)
+ public static class UA01 {}
+
+ @RestMethod(name=GET,path="/code")
+ public void ua01(UA01 r) {}
+
+ @Response(100)
+ public static class UA02 {}
+
+ @RestMethod(name=GET,path="/value")
+ public void ua02(UA02 r) {}
+
+ @Response(description="a")
+ public static class UA03a {}
+
+ @RestMethod(name=GET,path="/description1")
+ public void ua03a(UA03a r) {}
+
+ @Response(description={"a","b"})
+ public static class UA03b {}
+
+ @RestMethod(name=GET,path="/description2")
+ public void ua03b(UA03b r) {}
+
+ @Response(schema=" {type:'a'} ")
+ public static class UA04a {}
+
+ @RestMethod(name=GET,path="/schema1")
+ public void ua04a(UA04a r) {}
+
+ @Response(schema={" type:'b' "})
+ public static class UA04b {}
+
+ @RestMethod(name=GET,path="/schema2")
+ public void ua04b(UA04b r) {}
+
+ @Response(headers=" {foo:{type:'a'}} ")
+ public static class UA05a {}
+
+ @RestMethod(name=GET,path="/headers1")
+ public void ua05a(UA05a r) {}
+
+ @Response(headers={" foo:{type:'b'} "})
+ public static class UA05b {}
+
+ @RestMethod(name=GET,path="/headers2")
+ public void ua05b(UA05b r) {}
+
+ @Response(example="'a'")
+ public static class UA06a {}
+
+ @RestMethod(name=GET,path="/example1")
+ public void ua06a(UA06a r) {}
+
+ @Response(example="{f1:'a'}")
+ public static class UA06b {}
+
+ @RestMethod(name=GET,path="/example2")
+ public void ua06b(UA06b r) {}
+
+ @Response(examples=" {foo:'a'} ")
+ public static class UA07a {}
+
+ @RestMethod(name=GET,path="/examples1")
+ public void ua07a(UA07a r) {}
+
+ @Response(examples={" foo:'b' "})
+ public static class UA07b {}
+
+ @RestMethod(name=GET,path="/examples2")
+ public void ua07b(UA07b r) {}
+ }
+
+ @Test
+ public void ua01_Response_onPojo_code() throws Exception {
+ assertEquals("Continue", getSwagger(new
UA()).getPaths().get("/code").get("get").getResponse(100).getDescription());
+ }
+ @Test
+ public void ua02_Response_onPojo_() throws Exception {
+ assertEquals("Continue", getSwagger(new
UA()).getPaths().get("/value").get("get").getResponse(100).getDescription());
+ }
+ @Test
+ public void ua03a_Response_onPojo_description1() throws Exception {
+ assertEquals("a", getSwagger(new
UA()).getPaths().get("/description1").get("get").getResponse(200).getDescription());
+ }
+ @Test
+ public void ua03b_Response_onPojo_description2() throws Exception {
+ assertEquals("a\nb", getSwagger(new
UA()).getPaths().get("/description2").get("get").getResponse(200).getDescription());
+ }
+ @Test
+ public void ua04a_Response_onPojo_schema1() throws Exception {
+ assertObjectEquals("{type:'a'}", getSwagger(new
UA()).getPaths().get("/schema1").get("get").getResponse(200).getSchema());
+ }
+ @Test
+ public void ua04b_Response_onPojo_schema2() throws Exception {
+ assertObjectEquals("{type:'b'}", getSwagger(new
UA()).getPaths().get("/schema2").get("get").getResponse(200).getSchema());
+ }
+ @Test
+ public void ua05a_Response_onPojo_headers1() throws Exception {
+ assertObjectEquals("{foo:{type:'a'}}", getSwagger(new
UA()).getPaths().get("/headers1").get("get").getResponse(200).getHeaders());
+ }
+ @Test
+ public void ua05b_Response_onPojo_headers2() throws Exception {
+ assertObjectEquals("{foo:{type:'b'}}", getSwagger(new
UA()).getPaths().get("/headers2").get("get").getResponse(200).getHeaders());
+ }
+ @Test
+ public void ua06a_Response_onPojo_example1() throws Exception {
+ assertObjectEquals("'a'", getSwagger(new
UA()).getPaths().get("/example1").get("get").getResponse(200).getExample());
+ }
+ @Test
+ public void ua06b_Response_onPojo_example2() throws Exception {
+ assertObjectEquals("{f1:'a'}", getSwagger(new
UA()).getPaths().get("/example2").get("get").getResponse(200).getExample());
+ }
+ @Test
+ public void ua07a_Response_onPojo_examples1() throws Exception {
+ assertObjectEquals("{foo:'a'}", getSwagger(new
UA()).getPaths().get("/examples1").get("get").getResponse(200).getExamples());
+ }
+ @Test
+ public void ua07b_Response_onPojo_examples2() throws Exception {
+ assertObjectEquals("{foo:'b'}", getSwagger(new
UA()).getPaths().get("/examples2").get("get").getResponse(200).getExamples());
}
//-----------------------------------------------------------------------------------------------------------------
- // @Response on parameter of type Value
+ // @Response on parameter
//-----------------------------------------------------------------------------------------------------------------
@RestResource()
public static class UB {
-// int code() default 0;
-// int value() default 0;
-// String[] description() default {};
-// String[] schema() default {};
-// String[] headers() default {};
-// String[] example() default {};
-// String[] examples() default {};
+
+ public static class UB01 {}
+
+ @RestMethod(name=GET,path="/code")
+ public void ub01(@Response(code=100) UB01 r) {}
+
+ public static class UB02 {}
+
+ @RestMethod(name=GET,path="/value")
+ public void ub02(@Response(100) UB02 r) {}
+
+ public static class UB03 {}
+
+ @RestMethod(name=GET,path="/description1")
+ public void ub03(@Response(description="a") UB03 r) {}
+
+ public static class UB04 {}
+
+ @RestMethod(name=GET,path="/description2")
+ public void ub04(@Response(description={"a","b"}) UB04 r) {}
+
+ public static class UB05 {}
+
+ @RestMethod(name=GET,path="/schema1")
+ public void ub05(@Response(schema=" {type:'a'} ") UB05 r) {}
+
+ public static class UB06 {}
+
+ @RestMethod(name=GET,path="/schema2")
+ public void ub06(@Response(schema={" type:'b' "}) UB06 r) {}
+
+ public static class UB07 {}
+
+ @RestMethod(name=GET,path="/headers1")
+ public void ub07(@Response(headers=" {foo:{type:'a'}} ") UB07
r) {}
+
+ public static class UB08 {}
+
+ @RestMethod(name=GET,path="/headers2")
+ public void ub08(@Response(headers={" foo:{type:'b'} "}) UB08
r) {}
+
+ public static class UB09 {}
+
+ @RestMethod(name=GET,path="/example1")
+ public void ub09(@Response(example=" 'a' ") UB09 r) {}
+
+ public static class UB10 {}
+
+ @RestMethod(name=GET,path="/example2")
+ public void ub10(@Response(example=" {f1:'b'} ") UB10 r) {}
+
+ public static class UB11 {}
+
+ @RestMethod(name=GET,path="/examples1")
+ public void ub11(@Response(examples=" {foo:'a'} ") UB11 r) {}
+
+ public static class UB12 {}
+
+ @RestMethod(name=GET,path="/examples2")
+ public void ub12(@Response(examples={" foo:'b' "}) UB12 r) {}
}
+ @Test
+ public void ub01_Response_onParameter_code() throws Exception {
+ assertEquals("Continue", getSwagger(new
UB()).getPaths().get("/code").get("get").getResponse(100).getDescription());
+ }
+ @Test
+ public void ub02_Response_onParameter_value() throws Exception {
+ assertEquals("Continue", getSwagger(new
UB()).getPaths().get("/value").get("get").getResponse(100).getDescription());
+ }
+ @Test
+ public void ub03_Response_onParameter_description1() throws Exception {
+ assertEquals("a", getSwagger(new
UB()).getPaths().get("/description1").get("get").getResponse(200).getDescription());
+ }
+ @Test
+ public void ub04_Response_onParameter_description2() throws Exception {
+ assertEquals("a\nb", getSwagger(new
UB()).getPaths().get("/description2").get("get").getResponse(200).getDescription());
+ }
+ @Test
+ public void ub05_Response_onParameter_schema1() throws Exception {
+ assertObjectEquals("{type:'a'}", getSwagger(new
UB()).getPaths().get("/schema1").get("get").getResponse(200).getSchema());
+ }
+ @Test
+ public void ub06_Response_onParameter_schema2() throws Exception {
+ assertObjectEquals("{type:'b'}", getSwagger(new
UB()).getPaths().get("/schema2").get("get").getResponse(200).getSchema());
+ }
+ @Test
+ public void ub07_Response_onParameter_headers1() throws Exception {
+ assertObjectEquals("{foo:{type:'a'}}", getSwagger(new
UB()).getPaths().get("/headers1").get("get").getResponse(200).getHeaders());
+ }
+ @Test
+ public void ub08_Response_onParameter_headers2() throws Exception {
+ assertObjectEquals("{foo:{type:'b'}}", getSwagger(new
UB()).getPaths().get("/headers2").get("get").getResponse(200).getHeaders());
+ }
+ @Test
+ public void ub09_Response_onParameter_example1() throws Exception {
+ assertObjectEquals("'a'", getSwagger(new
UB()).getPaths().get("/example1").get("get").getResponse(200).getExample());
+ }
+ @Test
+ public void ub10_Response_onParameter_example2() throws Exception {
+ assertObjectEquals("{f1:'b'}", getSwagger(new
UB()).getPaths().get("/example2").get("get").getResponse(200).getExample());
+ }
+ @Test
+ public void ub11_Response_onParameter_examples1() throws Exception {
+ assertObjectEquals("{foo:'a'}", getSwagger(new
UB()).getPaths().get("/examples1").get("get").getResponse(200).getExamples());
+ }
+ @Test
+ public void ub12_Response_onParameter_examples2() throws Exception {
+ assertObjectEquals("{foo:'b'}", getSwagger(new
UB()).getPaths().get("/examples2").get("get").getResponse(200).getExamples());
+ }
+
//-----------------------------------------------------------------------------------------------------------------
- // @Response on parameter of type other than Value
+ // @Response on throwable
//-----------------------------------------------------------------------------------------------------------------
@RestResource()
- public static class UC {
-// int code() default 0;
-// int value() default 0;
-// String[] description() default {};
-// String[] schema() default {};
-// String[] headers() default {};
-// String[] example() default {};
-// String[] examples() default {};
+ @SuppressWarnings({"unused","serial"})
+ public static class UC {
+
+ @Response(code=100)
+ public static class UC01 extends Throwable {}
+
+ @RestMethod(name=GET,path="/code")
+ public void uc01() throws UC01 {}
+
+ @Response(100)
+ public static class UC02 extends Throwable {}
+
+ @RestMethod(name=GET,path="/value")
+ public void uc02() throws UC02 {}
+
+ @Response(description="a")
+ public static class UC03 extends Throwable {}
+
+ @RestMethod(name=GET,path="/description1")
+ public void uc03() throws UC03 {}
+
+ @Response(description= {"a","b"})
+ public static class UC04 extends Throwable {}
+
+ @RestMethod(name=GET,path="/description2")
+ public void uc04() throws UC04 {}
+
+ @Response(schema=" {type:'a'} ")
+ public static class UC05 extends Throwable {}
+
+ @RestMethod(name=GET,path="/schema1")
+ public void uc05() throws UC05 {}
+
+ @Response(schema={" type:'b' "})
+ public static class UC06 extends Throwable {}
+
+ @RestMethod(name=GET,path="/schema2")
+ public void uc06() throws UC06 {}
+
+ @Response(headers=" {foo:{type:'a'}} ")
+ public static class UC07 extends Throwable {}
+
+ @RestMethod(name=GET,path="/headers1")
+ public void uc07() throws UC07 {}
+
+ @Response(headers={" foo:{type:'b'} "})
+ public static class UC08 extends Throwable {}
+
+ @RestMethod(name=GET,path="/headers2")
+ public void uc08() throws UC08 {}
+
+ @Response(example=" 'a' ")
+ public static class UC09 extends Throwable {}
+
+ @RestMethod(name=GET,path="/example1")
+ public void uc09() throws UC09 {}
+
+ @Response(example={" {f1:'b'} "})
+ public static class UC10 extends Throwable {}
+
+ @RestMethod(name=GET,path="/example2")
+ public void uc10() throws UC10 {}
+
+ @Response(examples=" {foo:'a'} ")
+ public static class UC11 extends Throwable {}
+
+ @RestMethod(name=GET,path="/examples1")
+ public void uc11() throws UC11 {}
+
+ @Response(examples={" foo:'b' "})
+ public static class UC12 extends Throwable {}
+
+ @RestMethod(name=GET,path="/examples2")
+ public void uc12() throws UC12 {}
}
+ @Test
+ public void uc01_Response_onThrowable_code() throws Exception {
+ assertEquals("Continue", getSwagger(new
UC()).getPaths().get("/code").get("get").getResponse(100).getDescription());
+ }
+ @Test
+ public void uc02_Response_onThrowable_value() throws Exception {
+ assertEquals("Continue", getSwagger(new
UC()).getPaths().get("/value").get("get").getResponse(100).getDescription());
+ }
+ @Test
+ public void uc03_Response_onThrowable_description1() throws Exception {
+ assertEquals("a", getSwagger(new
UC()).getPaths().get("/description1").get("get").getResponse(500).getDescription());
+ }
+ @Test
+ public void uc04_Response_onThrowable_description2() throws Exception {
+ assertEquals("a\nb", getSwagger(new
UC()).getPaths().get("/description2").get("get").getResponse(500).getDescription());
+ }
+ @Test
+ public void uc05_Response_onThrowable_schema1() throws Exception {
+ assertObjectEquals("{type:'a'}", getSwagger(new
UC()).getPaths().get("/schema1").get("get").getResponse(500).getSchema());
+ }
+ @Test
+ public void uc06_Response_onThrowable_schema2() throws Exception {
+ assertObjectEquals("{type:'b'}", getSwagger(new
UC()).getPaths().get("/schema2").get("get").getResponse(500).getSchema());
+ }
+ @Test
+ public void uc07_Response_onThrowable_headers1() throws Exception {
+ assertObjectEquals("{foo:{type:'a'}}", getSwagger(new
UC()).getPaths().get("/headers1").get("get").getResponse(500).getHeaders());
+ }
+ @Test
+ public void uc08_Response_onThrowable_headers2() throws Exception {
+ assertObjectEquals("{foo:{type:'b'}}", getSwagger(new
UC()).getPaths().get("/headers2").get("get").getResponse(500).getHeaders());
+ }
+ @Test
+ public void uc09_Response_onThrowable_example1() throws Exception {
+ assertObjectEquals("'a'", getSwagger(new
UC()).getPaths().get("/example1").get("get").getResponse(500).getExample());
+ }
+ @Test
+ public void uc10_Response_onThrowable_example2() throws Exception {
+ assertObjectEquals("{f1:'b'}", getSwagger(new
UC()).getPaths().get("/example2").get("get").getResponse(500).getExample());
+ }
+ @Test
+ public void uc11_Response_onThrowable_examples1() throws Exception {
+ assertObjectEquals("{foo:'a'}", getSwagger(new
UC()).getPaths().get("/examples1").get("get").getResponse(500).getExamples());
+ }
+ @Test
+ public void uc12_Response_onThrowable_examples2() throws Exception {
+ assertObjectEquals("{foo:'b'}", getSwagger(new
UC()).getPaths().get("/examples2").get("get").getResponse(500).getExamples());
+ }
+
//-----------------------------------------------------------------------------------------------------------------
- // @Response on throwable
+ // @Responses on POJO
//-----------------------------------------------------------------------------------------------------------------
-
+
@RestResource()
public static class UD {
-// int code() default 0;
-// int value() default 0;
-// String[] description() default {};
-// String[] schema() default {};
-// String[] headers() default {};
-// String[] example() default {};
-// String[] examples() default {};
+
+ @Responses({
+ @Response(code=100),
+ @Response(code=101)
+ })
+ public static class UD01 {}
+
+ @RestMethod(name=GET,path="/code")
+ public void ud01(UD01 r) {}
+
+ @Responses({
+ @Response(100),
+ @Response(101)
+ })
+ public static class UD02 {}
+
+ @RestMethod(name=GET,path="/value")
+ public void ud02(UD02 r) {}
+
+ @Responses({
+ @Response(code=100, description="a"),
+ @Response(code=101, description={"a","b"})
+ })
+ public static class UD03 {}
+
+ @RestMethod(name=GET,path="/description")
+ public void ud03(UD03 r) {}
+
+ @Responses({
+ @Response(code=100, schema=" {type:'a'} "),
+ @Response(code=101, schema={" type:'b' "})
+ })
+ public static class UD04 {}
+
+ @RestMethod(name=GET,path="/schema")
+ public void ud04(UD04 r) {}
+
+ @Responses({
+ @Response(code=100, headers=" {foo:{type:'a'}} "),
+ @Response(code=101, headers={" foo:{type:'b'} "})
+ })
+ public static class UD05 {}
+
+ @RestMethod(name=GET,path="/headers")
+ public void ud05(UD05 r) {}
+
+ @Responses({
+ @Response(code=100, example="'a'"),
+ @Response(code=101, example="{f1:'a'}")
+ })
+ public static class UD06 {}
+
+ @RestMethod(name=GET,path="/example")
+ public void ud06(UD06 r) {}
+
+ @Responses({
+ @Response(code=100, examples=" {foo:'a'} "),
+ @Response(code=101, examples={" foo:'b' "})
+ })
+ public static class UD07 {}
+
+ @RestMethod(name=GET,path="/examples")
+ public void ud07(UD07 r) {}
+ }
+
+ @Test
+ public void ud01_Responses_onPojo_code() throws Exception {
+ assertEquals("Continue", getSwagger(new
UD()).getPaths().get("/code").get("get").getResponse(100).getDescription());
+ assertEquals("Switching Protocols", getSwagger(new
UD()).getPaths().get("/code").get("get").getResponse(101).getDescription());
+ }
+ @Test
+ public void ud02_Responses_onPojo_value() throws Exception {
+ assertEquals("Continue", getSwagger(new
UD()).getPaths().get("/value").get("get").getResponse(100).getDescription());
+ assertEquals("Switching Protocols", getSwagger(new
UD()).getPaths().get("/value").get("get").getResponse(101).getDescription());
+ }
+ @Test
+ public void ud03_Responses_onPojo_description() throws Exception {
+ assertEquals("a", getSwagger(new
UD()).getPaths().get("/description").get("get").getResponse(100).getDescription());
+ assertEquals("a\nb", getSwagger(new
UD()).getPaths().get("/description").get("get").getResponse(101).getDescription());
+ }
+ @Test
+ public void ud04_Responses_onPojo_schema() throws Exception {
+ assertObjectEquals("{type:'a'}", getSwagger(new
UD()).getPaths().get("/schema").get("get").getResponse(100).getSchema());
+ assertObjectEquals("{type:'b'}", getSwagger(new
UD()).getPaths().get("/schema").get("get").getResponse(101).getSchema());
+ }
+ @Test
+ public void ud05_Responses_onPojo_headers() throws Exception {
+ assertObjectEquals("{foo:{type:'a'}}", getSwagger(new
UD()).getPaths().get("/headers").get("get").getResponse(100).getHeaders());
+ assertObjectEquals("{foo:{type:'b'}}", getSwagger(new
UD()).getPaths().get("/headers").get("get").getResponse(101).getHeaders());
+ }
+ @Test
+ public void ud06_Responses_onPojo_example() throws Exception {
+ assertObjectEquals("'a'", getSwagger(new
UD()).getPaths().get("/example").get("get").getResponse(100).getExample());
+ assertObjectEquals("{f1:'a'}", getSwagger(new
UD()).getPaths().get("/example").get("get").getResponse(101).getExample());
+ }
+ @Test
+ public void ud07_Responses_onPojo_examples() throws Exception {
+ assertObjectEquals("{foo:'a'}", getSwagger(new
UD()).getPaths().get("/examples").get("get").getResponse(100).getExamples());
+ assertObjectEquals("{foo:'b'}", getSwagger(new
UD()).getPaths().get("/examples").get("get").getResponse(101).getExamples());
}
//-----------------------------------------------------------------------------------------------------------------
- // @Responses on POJO
+ // @Responses on parameter
//-----------------------------------------------------------------------------------------------------------------
-
+
@RestResource()
public static class UE {
-
+
+ public static class UE01 {}
+
+ @RestMethod(name=GET,path="/code")
+ public void ue01(
+ @Responses({
+ @Response(code=100),
+ @Response(code=101)
+ })
+ UE01 r) {}
+
+ public static class UE02 {}
+
+ @RestMethod(name=GET,path="/value")
+ public void ue02(
+ @Responses({
+ @Response(100),
+ @Response(101)
+ })
+ UE02 r) {}
+
+ public static class UE03 {}
+
+ @RestMethod(name=GET,path="/description")
+ public void ue03(
+ @Responses({
+ @Response(code=100, description="a"),
+ @Response(code=101, description={"a","b"})
+ })
+ UE03 r) {}
+
+ public static class UE04 {}
+
+ @RestMethod(name=GET,path="/schema")
+ public void ue04(
+ @Responses({
+ @Response(code=100, schema=" {type:'a'} "),
+ @Response(code=101, schema={" type:'b' "})
+ })
+ UE04 r) {}
+
+ public static class UE05 {}
+
+ @RestMethod(name=GET,path="/headers")
+ public void ue05(
+ @Responses({
+ @Response(code=100, headers=" {foo:{type:'a'}}
"),
+ @Response(code=101, headers={" foo:{type:'b'}
"})
+ })
+ UE05 r) {}
+
+ public static class UE06 {}
+
+ @RestMethod(name=GET,path="/example")
+ public void ue06(
+ @Responses({
+ @Response(code=100, example=" 'a' "),
+ @Response(code=101, example=" {f1:'b'} ")
+ })
+ UE06 r) {}
+
+ public static class UE07 {}
+
+ @RestMethod(name=GET,path="/examples")
+ public void ue07(
+ @Responses({
+ @Response(code=100, examples=" {foo:'a'} "),
+ @Response(code=101, examples={" foo:'b' "})
+ })
+ UE07 r) {}
}
+ @Test
+ public void ue01_Responses_onParameter_code() throws Exception {
+ assertEquals("Continue", getSwagger(new
UE()).getPaths().get("/code").get("get").getResponse(100).getDescription());
+ assertEquals("Switching Protocols", getSwagger(new
UE()).getPaths().get("/code").get("get").getResponse(101).getDescription());
+ }
+ @Test
+ public void ue02_Responses_onParameter_value() throws Exception {
+ assertEquals("Continue", getSwagger(new
UE()).getPaths().get("/value").get("get").getResponse(100).getDescription());
+ assertEquals("Switching Protocols", getSwagger(new
UE()).getPaths().get("/value").get("get").getResponse(101).getDescription());
+ }
+ @Test
+ public void ue03_Responses_onParameter_description() throws Exception {
+ assertEquals("a", getSwagger(new
UE()).getPaths().get("/description").get("get").getResponse(100).getDescription());
+ assertEquals("a\nb", getSwagger(new
UE()).getPaths().get("/description").get("get").getResponse(101).getDescription());
+ }
+ @Test
+ public void ue04_Responses_onParameter_schema() throws Exception {
+ assertObjectEquals("{type:'a'}", getSwagger(new
UE()).getPaths().get("/schema").get("get").getResponse(100).getSchema());
+ assertObjectEquals("{type:'b'}", getSwagger(new
UE()).getPaths().get("/schema").get("get").getResponse(101).getSchema());
+ }
+ @Test
+ public void ue05_Responses_onParameter_headers() throws Exception {
+ assertObjectEquals("{foo:{type:'a'}}", getSwagger(new
UE()).getPaths().get("/headers").get("get").getResponse(100).getHeaders());
+ assertObjectEquals("{foo:{type:'b'}}", getSwagger(new
UE()).getPaths().get("/headers").get("get").getResponse(101).getHeaders());
+ }
+ @Test
+ public void ue06_Responses_onParameter_example() throws Exception {
+ assertObjectEquals("'a'", getSwagger(new
UE()).getPaths().get("/example").get("get").getResponse(100).getExample());
+ assertObjectEquals("{f1:'b'}", getSwagger(new
UE()).getPaths().get("/example").get("get").getResponse(101).getExample());
+ }
+ @Test
+ public void ue07_Responses_onParameter_examples() throws Exception {
+ assertObjectEquals("{foo:'a'}", getSwagger(new
UE()).getPaths().get("/examples").get("get").getResponse(100).getExamples());
+ assertObjectEquals("{foo:'b'}", getSwagger(new
UE()).getPaths().get("/examples").get("get").getResponse(101).getExamples());
+ }
+
+
//-----------------------------------------------------------------------------------------------------------------
// @ResponseStatus on POJO
//-----------------------------------------------------------------------------------------------------------------
@RestResource()
public static class VA {
-// int code() default 0;
-// int value() default 0;
-// String[] description() default {};
+ @ResponseStatus({
+ @Status(code=100),
+ @Status(code=101)
+ })
+ public static class VA01 {}
+
+ @RestMethod(name=GET,path="/code")
+ public void va01(VA01 r) {}
+
+ @ResponseStatus({
+ @Status(100),
+ @Status(101)
+ })
+ public static class VA02 {}
+
+ @RestMethod(name=GET,path="/value")
+ public void va02(VA02 r) {}
+
+ @ResponseStatus({
+ @Status(code=100, description="a"),
+ @Status(code=101, description="a\nb")
+ })
+ public static class VA03 {}
+
+ @RestMethod(name=GET,path="/description")
+ public void va03(VA03 r) {}
+ }
+
+ @Test
+ public void va01_ResponseStatuses_onPojo_code() throws Exception {
+ assertEquals("Continue", getSwagger(new
VA()).getPaths().get("/code").get("get").getResponse(100).getDescription());
+ assertEquals("Switching Protocols", getSwagger(new
VA()).getPaths().get("/code").get("get").getResponse(101).getDescription());
+ }
+ @Test
+ public void va02_ResponseStatuses_onPojo_value() throws Exception {
+ assertEquals("Continue", getSwagger(new
VA()).getPaths().get("/value").get("get").getResponse(100).getDescription());
+ assertEquals("Switching Protocols", getSwagger(new
VA()).getPaths().get("/value").get("get").getResponse(101).getDescription());
+ }
+ @Test
+ public void va03_ResponseStatuses_onPojo_description() throws Exception
{
+ assertEquals("a", getSwagger(new
VA()).getPaths().get("/description").get("get").getResponse(100).getDescription());
+ assertEquals("a\nb", getSwagger(new
VA()).getPaths().get("/description").get("get").getResponse(101).getDescription());
}
//-----------------------------------------------------------------------------------------------------------------
- // @ResponseStatuses on POJO
+ // @ResponseStatus on parameter
//-----------------------------------------------------------------------------------------------------------------
@RestResource()
@@ -6136,9 +6704,6 @@ public class BasicRestInfoProviderTest {
// String[] example() default {};
}
-
//-----------------------------------------------------------------------------------------------------------------
- // @ResponseHeaders on POJO
-
//-----------------------------------------------------------------------------------------------------------------
@Bean(typeName="Foo")
public static class Foo {
--
To stop receiving notification emails like this one, please contact
[email protected].