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 5888104 Remove redundancy in HttpPart annotations.
5888104 is described below
commit 5888104b877dc1037cc7fb8b878348820bad2d02
Author: JamesBognar <[email protected]>
AuthorDate: Fri Nov 26 15:25:16 2021 -0500
Remove redundancy in HttpPart annotations.
---
.../java/org/apache/juneau/http/HttpParts.java | 8 -
.../apache/juneau/http/annotation/FormData.java | 5 -
.../juneau/http/annotation/FormDataAnnotation.java | 41 +-
.../apache/juneau/http/annotation/HasFormData.java | 5 -
.../http/annotation/HasFormDataAnnotation.java | 42 +-
.../apache/juneau/http/annotation/HasQuery.java | 5 -
.../juneau/http/annotation/HasQueryAnnotation.java | 42 +-
.../org/apache/juneau/http/annotation/Header.java | 5 -
.../juneau/http/annotation/HeaderAnnotation.java | 41 +-
.../org/apache/juneau/http/annotation/Path.java | 5 -
.../juneau/http/annotation/PathAnnotation.java | 41 +-
.../org/apache/juneau/http/annotation/Query.java | 5 -
.../juneau/http/annotation/QueryAnnotation.java | 41 +-
.../apache/juneau/http/annotation/Response.java | 10 -
.../juneau/http/annotation/ResponseAnnotation.java | 38 +-
.../juneau/http/annotation/ResponseHeader.java | 5 -
.../http/annotation/ResponseHeaderAnnotation.java | 40 +-
.../org/apache/juneau/httppart/HttpPartSchema.java | 14 +-
.../04.HttpParts/06.ResponseBeans.html | 499 +++++++++++++++++++++
...Params_RequestFormParams_RequestPathParams.html | 20 +
.../rest/test/client/ThirdPartyProxyResource.java | 196 ++++----
.../juneau/rest/BasicSwaggerProviderSession.java | 36 +-
.../java/org/apache/juneau/rest/RestOpContext.java | 6 +-
.../org/apache/juneau/rest/args/FormDataArg.java | 28 +-
.../apache/juneau/rest/args/HasFormDataArg.java | 19 +-
.../org/apache/juneau/rest/args/HasQueryArg.java | 19 +-
.../org/apache/juneau/rest/args/HeaderArg.java | 28 +-
.../java/org/apache/juneau/rest/args/PathArg.java | 19 +-
.../java/org/apache/juneau/rest/args/QueryArg.java | 27 +-
.../apache/juneau/rest/args/ResponseHeaderArg.java | 27 +-
.../http/annotation/AnnotationUtils_Test.java | 9 -
.../http/annotation/FormDataAnnotation_Test.java | 5 -
.../annotation/HasFormDataAnnotation_Test.java | 4 -
.../http/annotation/HasQueryAnnotation_Test.java | 3 -
.../http/annotation/HeaderAnnotation_Test.java | 5 -
.../http/annotation/PathAnnotation_Test.java | 5 -
.../http/annotation/QueryAnnotation_Test.java | 5 -
.../http/annotation/ResponseAnnotation_Test.java | 10 -
.../annotation/ResponseHeaderAnnotation_Test.java | 5 -
.../remote/Remote_FormDataAnnotation_Test.java | 6 +-
.../http/remote/Remote_HeaderAnnotation_Test.java | 2 +-
.../http/remote/Remote_PathAnnotation_Test.java | 8 +-
.../http/remote/Remote_QueryAnnotation_Test.java | 6 +-
.../httppart/HttpPartSchema_FormData_Test.java | 12 +-
.../httppart/HttpPartSchema_Header_Test.java | 12 +-
.../juneau/httppart/HttpPartSchema_Path_Test.java | 12 +-
.../juneau/httppart/HttpPartSchema_Query_Test.java | 16 +-
.../HttpPartSchema_ResponseHeader_Test.java | 12 +-
.../apache/juneau/rest/annotation/Query_Test.java | 12 +-
.../juneau/rest/annotation/Swagger_Path_Test.java | 47 +-
.../juneau/rest/annotation/Swagger_Query_Test.java | 27 +-
51 files changed, 918 insertions(+), 622 deletions(-)
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/HttpParts.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/HttpParts.java
index 3081674..98ea901 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/HttpParts.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/HttpParts.java
@@ -417,8 +417,6 @@ public class HttpParts {
for (org.apache.juneau.http.annotation.Header a :
x.getAnnotations(org.apache.juneau.http.annotation.Header.class)) {
if (! a.value().isEmpty())
return a.value();
- if (! a.n().isEmpty())
- return a.n();
if (! a.name().isEmpty())
return a.name();
}
@@ -429,8 +427,6 @@ public class HttpParts {
for (org.apache.juneau.http.annotation.Query a :
x.getAnnotations(org.apache.juneau.http.annotation.Query.class)) {
if (! a.value().isEmpty())
return a.value();
- if (! a.n().isEmpty())
- return a.n();
if (! a.name().isEmpty())
return a.name();
}
@@ -441,8 +437,6 @@ public class HttpParts {
for (org.apache.juneau.http.annotation.FormData a :
x.getAnnotations(org.apache.juneau.http.annotation.FormData.class)) {
if (! a.value().isEmpty())
return a.value();
- if (! a.n().isEmpty())
- return a.n();
if (! a.name().isEmpty())
return a.name();
}
@@ -453,8 +447,6 @@ public class HttpParts {
for (org.apache.juneau.http.annotation.Path a :
x.getAnnotations(org.apache.juneau.http.annotation.Path.class)) {
if (! a.value().isEmpty())
return a.value();
- if (! a.n().isEmpty())
- return a.n();
if (! a.name().isEmpty())
return a.name();
}
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/FormData.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/FormData.java
index 6284f23..a216d68 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/FormData.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/FormData.java
@@ -136,11 +136,6 @@ public @interface FormData {
boolean multi() default false;
/**
- * Synonym for {@link #name()}.
- */
- String n() default "";
-
- /**
* FORM parameter name.
*
* <p>
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/FormDataAnnotation.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/FormDataAnnotation.java
index f0df437..9209152 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/FormDataAnnotation.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/FormDataAnnotation.java
@@ -14,9 +14,11 @@ package org.apache.juneau.http.annotation;
import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.*;
+import static org.apache.juneau.internal.StringUtils.*;
import java.lang.annotation.*;
import java.lang.reflect.*;
+import java.util.*;
import org.apache.juneau.*;
import org.apache.juneau.annotation.*;
@@ -75,6 +77,24 @@ public class FormDataAnnotation {
return a == null || DEFAULT.equals(a);
}
+ /**
+ * Finds the name from the specified lists of annotations.
+ *
+ * <p>
+ * The last matching name found is returned.
+ *
+ * @param lists The lists to search.
+ * @return The last matching name, or {@link Optional#empty()} if not
found.
+ */
+ @SafeVarargs
+ public static Optional<String> findName(List<FormData>...lists) {
+ String n = null;
+ for (List<FormData> l : lists)
+ for (FormData h : l)
+ n = firstNonEmpty(h.name(), h.value(), n);
+ return Optional.ofNullable(n);
+ }
+
//-----------------------------------------------------------------------------------------------------------------
// Builder
//-----------------------------------------------------------------------------------------------------------------
@@ -92,7 +112,7 @@ public class FormDataAnnotation {
Class<? extends HttpPartParser> parser =
HttpPartParser.Null.class;
Class<? extends HttpPartSerializer> serializer =
HttpPartSerializer.Null.class;
Schema schema = SchemaAnnotation.DEFAULT;
- String n="", name="", value="";
+ String name="", value="";
/**
* Constructor.
@@ -122,17 +142,6 @@ public class FormDataAnnotation {
}
/**
- * Sets the {@link FormData#n} property on this annotation.
- *
- * @param value The new value for this property.
- * @return This object.
- */
- public Builder n(String value) {
- this.n = value;
- return this;
- }
-
- /**
* Sets the {@link FormData#name} property on this annotation.
*
* @param value The new value for this property.
@@ -231,13 +240,12 @@ public class FormDataAnnotation {
private final boolean multi;
private final Class<? extends HttpPartParser> parser;
private final Class<? extends HttpPartSerializer> serializer;
- private final String n, name, value;
+ private final String name, value;
private final Schema schema;
Impl(Builder b) {
super(b);
this.multi = b.multi;
- this.n = b.n;
this.name = b.name;
this.parser = b.parser;
this.schema = b.schema;
@@ -252,11 +260,6 @@ public class FormDataAnnotation {
}
@Override /* FormData */
- public String n() {
- return n;
- }
-
- @Override /* FormData */
public String name() {
return name;
}
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/HasFormData.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/HasFormData.java
index d81116b..2a6469a 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/HasFormData.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/HasFormData.java
@@ -103,11 +103,6 @@ import java.lang.annotation.*;
public @interface HasFormData {
/**
- * Synonym for {@link #name()}.
- */
- String n() default "";
-
- /**
* FORM parameter name.
*
* Required. The name of the parameter. Parameter names are case
sensitive.
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/HasFormDataAnnotation.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/HasFormDataAnnotation.java
index 9d37ec3..aa36956 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/HasFormDataAnnotation.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/HasFormDataAnnotation.java
@@ -12,7 +12,10 @@
//
***************************************************************************************************************************
package org.apache.juneau.http.annotation;
+import static org.apache.juneau.internal.StringUtils.*;
+
import java.lang.annotation.*;
+import java.util.*;
import org.apache.juneau.annotation.*;
@@ -37,6 +40,24 @@ public class HasFormDataAnnotation {
return new Builder();
}
+ /**
+ * Finds the name from the specified lists of annotations.
+ *
+ * <p>
+ * The last matching name found is returned.
+ *
+ * @param lists The lists to search.
+ * @return The last matching name, or {@link Optional#empty()} if not
found.
+ */
+ @SafeVarargs
+ public static Optional<String> findName(List<HasFormData>...lists) {
+ String n = null;
+ for (List<HasFormData> l : lists)
+ for (HasFormData h : l)
+ n = firstNonEmpty(h.name(), h.value(), n);
+ return Optional.ofNullable(n);
+ }
+
//-----------------------------------------------------------------------------------------------------------------
// Builder
//-----------------------------------------------------------------------------------------------------------------
@@ -50,7 +71,7 @@ public class HasFormDataAnnotation {
*/
public static class Builder extends AnnotationBuilder {
- String n="", name="", value="";
+ String name="", value="";
/**
* Constructor.
@@ -69,17 +90,6 @@ public class HasFormDataAnnotation {
}
/**
- * Sets the {@link HasFormData#n} property on this annotation.
- *
- * @param value The new value for this property.
- * @return This object.
- */
- public Builder n(String value) {
- this.n = value;
- return this;
- }
-
- /**
* Sets the {@link HasFormData#name} property on this
annotation.
*
* @param value The new value for this property.
@@ -111,22 +121,16 @@ public class HasFormDataAnnotation {
private static class Impl extends AnnotationImpl implements HasFormData
{
- private final String n, name, value;
+ private final String name, value;
Impl(Builder b) {
super(b);
- this.n = b.n;
this.name = b.name;
this.value = b.value;
postConstruct();
}
@Override
- public String n() {
- return n;
- }
-
- @Override
public String name() {
return name;
}
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/HasQuery.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/HasQuery.java
index 174df8a..1420d66 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/HasQuery.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/HasQuery.java
@@ -98,11 +98,6 @@ import java.lang.annotation.*;
public @interface HasQuery {
/**
- * Synonym for {@link #name()}.
- */
- String n() default "";
-
- /**
* URL query parameter name.
*
* Required. The name of the parameter. Parameter names are case
sensitive.
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/HasQueryAnnotation.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/HasQueryAnnotation.java
index 1c4cf47..e9308f6 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/HasQueryAnnotation.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/HasQueryAnnotation.java
@@ -12,7 +12,10 @@
//
***************************************************************************************************************************
package org.apache.juneau.http.annotation;
+import static org.apache.juneau.internal.StringUtils.*;
+
import java.lang.annotation.*;
+import java.util.*;
import org.apache.juneau.annotation.*;
@@ -37,6 +40,24 @@ public class HasQueryAnnotation {
return new Builder();
}
+ /**
+ * Finds the name from the specified lists of annotations.
+ *
+ * <p>
+ * The last matching name found is returned.
+ *
+ * @param lists The lists to search.
+ * @return The last matching name, or {@link Optional#empty()} if not
found.
+ */
+ @SafeVarargs
+ public static Optional<String> findName(List<HasQuery>...lists) {
+ String n = null;
+ for (List<HasQuery> l : lists)
+ for (HasQuery h : l)
+ n = firstNonEmpty(h.name(), h.value(), n);
+ return Optional.ofNullable(n);
+ }
+
//-----------------------------------------------------------------------------------------------------------------
// Builder
//-----------------------------------------------------------------------------------------------------------------
@@ -50,7 +71,7 @@ public class HasQueryAnnotation {
*/
public static class Builder extends AnnotationBuilder {
- String n="", name="", value="";
+ String name="", value="";
/**
* Constructor.
@@ -69,17 +90,6 @@ public class HasQueryAnnotation {
}
/**
- * Sets the {@link HasQuery#n} property on this annotation.
- *
- * @param value The new value for this property.
- * @return This object.
- */
- public Builder n(String value) {
- this.n = value;
- return this;
- }
-
- /**
* Sets the {@link HasQuery#name} property on this annotation.
*
* @param value The new value for this property.
@@ -111,22 +121,16 @@ public class HasQueryAnnotation {
private static class Impl extends AnnotationImpl implements HasQuery {
- private final String n, name, value;
+ private final String name, value;
Impl(Builder b) {
super(b);
- this.n = b.n;
this.name = b.name;
this.value = b.value;
postConstruct();
}
@Override
- public String n() {
- return n;
- }
-
- @Override
public String name() {
return name;
}
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/Header.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/Header.java
index 0cb4e28..1019886 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/Header.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/Header.java
@@ -102,11 +102,6 @@ public @interface Header {
boolean multi() default false;
/**
- * Synonym for {@link #name()}.
- */
- String n() default "";
-
- /**
* HTTP header name.
* <p>
* A blank value (the default) indicates to reuse the bean property
name when used on a request bean property.
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/HeaderAnnotation.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/HeaderAnnotation.java
index a3c2f27..03867df 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/HeaderAnnotation.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/HeaderAnnotation.java
@@ -14,9 +14,11 @@ package org.apache.juneau.http.annotation;
import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.*;
+import static org.apache.juneau.internal.StringUtils.*;
import java.lang.annotation.*;
import java.lang.reflect.*;
+import java.util.*;
import org.apache.juneau.*;
import org.apache.juneau.annotation.*;
@@ -75,6 +77,24 @@ public class HeaderAnnotation {
return a == null || DEFAULT.equals(a);
}
+ /**
+ * Finds the name from the specified lists of annotations.
+ *
+ * <p>
+ * The last matching name found is returned.
+ *
+ * @param lists The lists to search.
+ * @return The last matching name, or {@link Optional#empty()} if not
found.
+ */
+ @SafeVarargs
+ public static Optional<String> findName(List<Header>...lists) {
+ String n = null;
+ for (List<Header> l : lists)
+ for (Header h : l)
+ n = firstNonEmpty(h.name(), h.value(), n);
+ return Optional.ofNullable(n);
+ }
+
//-----------------------------------------------------------------------------------------------------------------
// Builder
//-----------------------------------------------------------------------------------------------------------------
@@ -92,7 +112,7 @@ public class HeaderAnnotation {
Class<? extends HttpPartParser> parser =
HttpPartParser.Null.class;
Class<? extends HttpPartSerializer> serializer =
HttpPartSerializer.Null.class;
Schema schema = SchemaAnnotation.DEFAULT;
- String n="", name="", value="";
+ String name="", value="";
/**
* Constructor.
@@ -122,17 +142,6 @@ public class HeaderAnnotation {
}
/**
- * Sets the {@link Header#n} property on this annotation.
- *
- * @param value The new value for this property.
- * @return This object.
- */
- public Builder n(String value) {
- this.n = value;
- return this;
- }
-
- /**
* Sets the {@link Header#name} property on this annotation.
*
* @param value The new value for this property.
@@ -231,13 +240,12 @@ public class HeaderAnnotation {
private final boolean multi;
private final Class<? extends HttpPartParser> parser;
private final Class<? extends HttpPartSerializer> serializer;
- private final String n, name, value;
+ private final String name, value;
private final Schema schema;
Impl(Builder b) {
super(b);
this.multi = b.multi;
- this.n = b.n;
this.name = b.name;
this.parser = b.parser;
this.schema = b.schema;
@@ -252,11 +260,6 @@ public class HeaderAnnotation {
}
@Override /* Header */
- public String n() {
- return n;
- }
-
- @Override /* Header */
public String name() {
return name;
}
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/Path.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/Path.java
index 9e5bc43..0964fa5 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/Path.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/Path.java
@@ -82,11 +82,6 @@ import org.apache.juneau.oapi.*;
public @interface Path {
/**
- * Synonym for {@link #name()}.
- */
- String n() default "";
-
- /**
* URL path variable name.
*
* <p>
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/PathAnnotation.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/PathAnnotation.java
index a6dd387..f7a6f2f 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/PathAnnotation.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/PathAnnotation.java
@@ -14,9 +14,11 @@ package org.apache.juneau.http.annotation;
import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.*;
+import static org.apache.juneau.internal.StringUtils.*;
import java.lang.annotation.*;
import java.lang.reflect.*;
+import java.util.*;
import org.apache.juneau.*;
import org.apache.juneau.annotation.*;
@@ -75,6 +77,24 @@ public class PathAnnotation {
return a == null || DEFAULT.equals(a);
}
+ /**
+ * Finds the name from the specified lists of annotations.
+ *
+ * <p>
+ * The last matching name found is returned.
+ *
+ * @param lists The lists to search.
+ * @return The last matching name, or {@link Optional#empty()} if not
found.
+ */
+ @SafeVarargs
+ public static Optional<String> findName(List<Path>...lists) {
+ String n = null;
+ for (List<Path> l : lists)
+ for (Path h : l)
+ n = firstNonEmpty(h.name(), h.value(), n);
+ return Optional.ofNullable(n);
+ }
+
//-----------------------------------------------------------------------------------------------------------------
// Builder
//-----------------------------------------------------------------------------------------------------------------
@@ -91,7 +111,7 @@ public class PathAnnotation {
Class<? extends HttpPartParser> parser =
HttpPartParser.Null.class;
Class<? extends HttpPartSerializer> serializer =
HttpPartSerializer.Null.class;
Schema schema = SchemaAnnotation.DEFAULT;
- String n="", name="", value="";
+ String name="", value="";
/**
* Constructor.
@@ -110,17 +130,6 @@ public class PathAnnotation {
}
/**
- * Sets the {@link Path#n} property on this annotation.
- *
- * @param value The new value for this property.
- * @return This object.
- */
- public Builder n(String value) {
- this.n = value;
- return this;
- }
-
- /**
* Sets the {@link Path#name} property on this annotation.
*
* @param value The new value for this property.
@@ -218,12 +227,11 @@ public class PathAnnotation {
private final Class<? extends HttpPartParser> parser;
private final Class<? extends HttpPartSerializer> serializer;
- private final String n, name, value;
+ private final String name, value;
private final Schema schema;
Impl(Builder b) {
super(b);
- this.n = b.n;
this.name = b.name;
this.parser = b.parser;
this.schema = b.schema;
@@ -233,11 +241,6 @@ public class PathAnnotation {
}
@Override /* Path */
- public String n() {
- return n;
- }
-
- @Override /* Path */
public String name() {
return name;
}
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/Query.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/Query.java
index bd75e76..ed52489 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/Query.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/Query.java
@@ -110,11 +110,6 @@ public @interface Query {
boolean multi() default false;
/**
- * Synonym for {@link #name()}.
- */
- String n() default "";
-
- /**
* URL query parameter name.
*
* Required. The name of the parameter. Parameter names are case
sensitive.
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/QueryAnnotation.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/QueryAnnotation.java
index deeaba6..c21802d 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/QueryAnnotation.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/QueryAnnotation.java
@@ -14,9 +14,11 @@ package org.apache.juneau.http.annotation;
import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.*;
+import static org.apache.juneau.internal.StringUtils.*;
import java.lang.annotation.*;
import java.lang.reflect.*;
+import java.util.*;
import org.apache.juneau.*;
import org.apache.juneau.annotation.*;
@@ -75,6 +77,24 @@ public class QueryAnnotation {
return a == null || DEFAULT.equals(a);
}
+ /**
+ * Finds the name from the specified lists of annotations.
+ *
+ * <p>
+ * The last matching name found is returned.
+ *
+ * @param lists The lists to search.
+ * @return The last matching name, or {@link Optional#empty()} if not
found.
+ */
+ @SafeVarargs
+ public static Optional<String> findName(List<Query>...lists) {
+ String n = null;
+ for (List<Query> l : lists)
+ for (Query h : l)
+ n = firstNonEmpty(h.name(), h.value(), n);
+ return Optional.ofNullable(n);
+ }
+
//-----------------------------------------------------------------------------------------------------------------
// Builder
//-----------------------------------------------------------------------------------------------------------------
@@ -92,7 +112,7 @@ public class QueryAnnotation {
Class<? extends HttpPartParser> parser =
HttpPartParser.Null.class;
Class<? extends HttpPartSerializer> serializer =
HttpPartSerializer.Null.class;
Schema schema = SchemaAnnotation.DEFAULT;
- String n="", name="", value="";
+ String name="", value="";
/**
* Constructor.
@@ -122,17 +142,6 @@ public class QueryAnnotation {
}
/**
- * Sets the {@link Query#n} property on this annotation.
- *
- * @param value The new value for this property.
- * @return This object.
- */
- public Builder n(String value) {
- this.n = value;
- return this;
- }
-
- /**
* Sets the {@link Query#name} property on this annotation.
*
* @param value The new value for this property.
@@ -231,13 +240,12 @@ public class QueryAnnotation {
private final boolean multi;
private final Class<? extends HttpPartParser> parser;
private final Class<? extends HttpPartSerializer> serializer;
- private final String n, name, value;
+ private final String name, value;
private final Schema schema;
Impl(Builder b) {
super(b);
this.multi = b.multi;
- this.n = b.n;
this.name = b.name;
this.parser = b.parser;
this.schema = b.schema;
@@ -252,11 +260,6 @@ public class QueryAnnotation {
}
@Override /* Query */
- public String n() {
- return n;
- }
-
- @Override /* Query */
public String name() {
return name;
}
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/Response.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/Response.java
index 55ecd1f..61c5676 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/Response.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/Response.java
@@ -62,11 +62,6 @@ public @interface Response {
int[] code() default {};
/**
- * Synonym for {@link #example()}.
- */
- String[] ex() default {};
-
- /**
* A serialized example of the body of a response.
*
* <p>
@@ -223,11 +218,6 @@ public @interface Response {
String[] examples() default {};
/**
- * Synonym for {@link #examples()}.
- */
- String[] exs() default {};
-
- /**
* <mk>headers</mk> field of the {@doc ExtSwaggerResponseObject}.
*
* <h5 class='section'>Used for:</h5>
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/ResponseAnnotation.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/ResponseAnnotation.java
index 7a265d6..b0c1c92 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/ResponseAnnotation.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/ResponseAnnotation.java
@@ -95,7 +95,7 @@ public class ResponseAnnotation {
int[] code={}, value={};
ResponseHeader[] headers={};
Schema schema = SchemaAnnotation.DEFAULT;
- String[] ex={}, example={}, examples={}, exs={};
+ String[] example={}, examples={};
/**
* Constructor.
@@ -125,17 +125,6 @@ public class ResponseAnnotation {
}
/**
- * Sets the {@link Response#ex} property on this annotation.
- *
- * @param value The new value for this property.
- * @return This object.
- */
- public Builder ex(String...value) {
- this.ex = value;
- return this;
- }
-
- /**
* Sets the {@link Response#example} property on this
annotation.
*
* @param value The new value for this property.
@@ -158,17 +147,6 @@ public class ResponseAnnotation {
}
/**
- * Sets the {@link Response#exs} property on this annotation.
- *
- * @param value The new value for this property.
- * @return This object.
- */
- public Builder exs(String...value) {
- this.exs = value;
- return this;
- }
-
- /**
* Sets the {@link Response#headers} property on this
annotation.
*
* @param value The new value for this property.
@@ -263,15 +241,13 @@ public class ResponseAnnotation {
private final int[] code, value;
private final ResponseHeader[] headers;
private final Schema schema;
- private final String[] ex, example, examples, exs;
+ private final String[] example, examples;
Impl(Builder b) {
super(b);
this.code = Arrays.copyOf(b.code, b.code.length);
- this.ex = copyOf(b.ex);
this.example = copyOf(b.example);
this.examples = copyOf(b.examples);
- this.exs = copyOf(b.exs);
this.headers = copyOf(b.headers);
this.parser = b.parser;
this.schema = b.schema;
@@ -286,11 +262,6 @@ public class ResponseAnnotation {
}
@Override /* Response */
- public String[] ex() {
- return ex;
- }
-
- @Override /* Response */
public String[] example() {
return example;
}
@@ -301,11 +272,6 @@ public class ResponseAnnotation {
}
@Override /* Response */
- public String[] exs() {
- return exs;
- }
-
- @Override /* Response */
public ResponseHeader[] headers() {
return headers;
}
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/ResponseHeader.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/ResponseHeader.java
index ca4f038..2ae34e9 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/ResponseHeader.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/ResponseHeader.java
@@ -144,11 +144,6 @@ public @interface ResponseHeader {
int[] code() default {};
/**
- * Synonym for {@link #name()}.
- */
- String n() default "";
-
- /**
* The HTTP header name.
*
* <ul class='notes'>
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/ResponseHeaderAnnotation.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/ResponseHeaderAnnotation.java
index c6e8b13..bef338d 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/ResponseHeaderAnnotation.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/ResponseHeaderAnnotation.java
@@ -14,6 +14,7 @@ package org.apache.juneau.http.annotation;
import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.*;
+import static org.apache.juneau.internal.StringUtils.*;
import java.lang.annotation.*;
import java.lang.reflect.*;
@@ -76,6 +77,24 @@ public class ResponseHeaderAnnotation {
return a == null || DEFAULT.equals(a);
}
+ /**
+ * Finds the name from the specified lists of annotations.
+ *
+ * <p>
+ * The last matching name found is returned.
+ *
+ * @param lists The lists to search.
+ * @return The last matching name, or {@link Optional#empty()} if not
found.
+ */
+ @SafeVarargs
+ public static Optional<String> findName(List<ResponseHeader>...lists) {
+ String n = null;
+ for (List<ResponseHeader> l : lists)
+ for (ResponseHeader h : l)
+ n = firstNonEmpty(h.name(), h.value(), n);
+ return Optional.ofNullable(n);
+ }
+
//-----------------------------------------------------------------------------------------------------------------
// Builder
//-----------------------------------------------------------------------------------------------------------------
@@ -92,7 +111,7 @@ public class ResponseHeaderAnnotation {
Class<? extends HttpPartSerializer> serializer =
HttpPartSerializer.Null.class;
int[] code={};
Schema schema = SchemaAnnotation.DEFAULT;
- String n="", name="", value="";
+ String name="", value="";
/**
* Constructor.
@@ -122,17 +141,6 @@ public class ResponseHeaderAnnotation {
}
/**
- * Sets the {@link ResponseHeader#n} property on this
annotation.
- *
- * @param value The new value for this property.
- * @return This object.
- */
- public Builder n(String value) {
- this.n = value;
- return this;
- }
-
- /**
* Sets the {@link ResponseHeader#name} property on this
annotation.
*
* @param value The new value for this property.
@@ -213,13 +221,12 @@ public class ResponseHeaderAnnotation {
private final Class<? extends HttpPartSerializer> serializer;
private final int[] code;
- private final String n, name, value;
+ private final String name, value;
private final Schema schema;
Impl(Builder b) {
super(b);
this.code = Arrays.copyOf(b.code, b.code.length);
- this.n = b.n;
this.name = b.name;
this.schema = b.schema;
this.serializer = b.serializer;
@@ -233,11 +240,6 @@ public class ResponseHeaderAnnotation {
}
@Override /* ResponseHeader */
- public String n() {
- return n;
- }
-
- @Override /* ResponseHeader */
public String name() {
return name;
}
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/HttpPartSchema.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/HttpPartSchema.java
index 3f4de03..e481d7f 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/HttpPartSchema.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/HttpPartSchema.java
@@ -742,7 +742,7 @@ public class HttpPartSchema {
Builder apply(Header a) {
if (! SchemaAnnotation.empty(a.schema()))
apply(a.schema());
- name(firstNonEmpty(a.name(), a.n(), a.value()));
+ name(firstNonEmpty(a.name(), a.value()));
parser(a.parser());
serializer(a.serializer());
return this;
@@ -752,7 +752,7 @@ public class HttpPartSchema {
if (! SchemaAnnotation.empty(a.schema()))
apply(a.schema());
allowEmptyValue(false);
- name(firstNonEmpty(a.name(), a.n(), a.value()));
+ name(firstNonEmpty(a.name(), a.value()));
serializer(a.serializer());
return this;
}
@@ -760,7 +760,7 @@ public class HttpPartSchema {
Builder apply(FormData a) {
if (! SchemaAnnotation.empty(a.schema()))
apply(a.schema());
- name(firstNonEmpty(a.name(), a.n(), a.value()));
+ name(firstNonEmpty(a.name(), a.value()));
parser(a.parser());
serializer(a.serializer());
return this;
@@ -769,7 +769,7 @@ public class HttpPartSchema {
Builder apply(Query a) {
if (! SchemaAnnotation.empty(a.schema()))
apply(a.schema());
- name(firstNonEmpty(a.name(), a.n(), a.value()));
+ name(firstNonEmpty(a.name(), a.value()));
parser(a.parser());
serializer(a.serializer());
return this;
@@ -778,7 +778,7 @@ public class HttpPartSchema {
Builder apply(Path a) {
if (! SchemaAnnotation.empty(a.schema()))
apply(a.schema());
- name(firstNonEmpty(a.name(), a.n(), a.value()));
+ name(firstNonEmpty(a.name(), a.value()));
parser(a.parser());
serializer(a.serializer());
@@ -872,12 +872,12 @@ public class HttpPartSchema {
}
Builder apply(HasQuery a) {
- name(firstNonEmpty(a.name(), a.n(), a.value()));
+ name(firstNonEmpty(a.name(), a.value()));
return this;
}
Builder apply(HasFormData a) {
- name(firstNonEmpty(a.name(), a.n(), a.value()));
+ name(firstNonEmpty(a.name(), a.value()));
return this;
}
diff --git
a/juneau-doc/docs/Topics/06.juneau-rest-server/04.HttpParts/06.ResponseBeans.html
b/juneau-doc/docs/Topics/06.juneau-rest-server/04.HttpParts/06.ResponseBeans.html
new file mode 100644
index 0000000..86c2764
--- /dev/null
+++
b/juneau-doc/docs/Topics/06.juneau-rest-server/04.HttpParts/06.ResponseBeans.html
@@ -0,0 +1,499 @@
+<!--
+/***************************************************************************************************************************
+ * 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.
+
***************************************************************************************************************************/
+ -->
+
+{title:'@Response beans', updated:'8.1.0,9.0.0'}
+
+<p>
+ The {@link oaj.http.annotation.Response} annotation can also be used in
the following locations:
+</p>
+<ul>
+ <li>Argument/exception/return types of <ja>@RestOp</ja>-annotated
methods.
+ <li><ja>@RestOp</ja>-annotated methods themselves.
+</ul>
+
+<p>
+ When the <ja>@Response</ja> annotation is applied to classes, the
following annotations can be used on
+ public non-static methods of the class to identify parts of a response:
+</p>
+<ul class='javatree'>
+ <li class='ja'>{@link oaj.http.annotation.ResponseStatus}
+ <li class='ja'>{@link oaj.http.annotation.ResponseHeader}
+ <li class='ja'>{@link oaj.http.annotation.ResponseBody}
+</ul>
+
+<h5 class='topic'>@Resource on exception classes</h5>
+<p>
+ When applied to an exception class, this annotation defines Swagger
schema and information on non-200 return types.
+</p>
+<p>
+ The following example shows the <ja>@Response</ja> annotation used to
define an exception for an invalid login attempt:
+</p>
+<p class='bpcode w800'>
+ <jc>// Our annotated exception.</jc>
+ <ja>@Response</ja>(
+ code=401,
+ description=<js>"Invalid username or password provided"</js>
<jc>// Description show in Swagger</jc>
+ )
+ <jk>public class</jk> InvalidLogin <jk>extends</jk> Exception {
+ <jk>public</jk> InvalidLogin() {
+ <jk>super</jk>(<js>"Invalid username or
password."</js>); <jc>// Message sent in response</jc>
+ }
+ }
+
+ <jc>// Our REST method that throws an annotated exception.</jc>
+ <ja>@RestGet</ja>(<js>"/user/login"</js>)
+ <jk>public</jk> Ok login(
+ <ja>@FormData</ja>(<js>"username"</js>) String
<jv>username</jv>,
+ <ja>@FormData</ja>(<js>"password"</js>) String <jv>password</jv>
+ ) <jk>throws</jk> InvalidLogin
+ {
+ <jsm>checkCredentials</jsm>(<jv>username</jv>,
<jv>password</jv>);
+ <jk>return new</jk> Ok();
+ }
+</p>
+<p>
+ Custom exceptions can also extend from one of the predefined HTTP
exceptions such as the {@del oaj.http.exception.Unauthorized} exception:
+</p>
+<p class='bpcode w800'>
+ <jc>// Our annotated exception.</jc>
+ <ja>@Response</ja>(
+ description=<js>"Invalid username or password provided"</js>
<jc>// Overridden from parent class</jc>
+ )
+ <jk>public class</jk> InvalidLogin <jk>extends</jk> Unauthorized {
+ <jk>public</jk> InvalidLogin() {
+ <jk>super</jk>(<js>"Invalid username or
password."</js>);
+ }
+ }
+
+ <jc>// Parent predefined exception class.</jc>
+ <ja>@Response</ja>(
+ code=401,
+ description=<js>"Unauthorized"</js>
+ )
+ <jk>public class</jk> Unauthorized <jk>extends</jk> RestException {...}
+</p>
+
+<h5 class='topic'>@Resource on return type classes</h5>
+<p>
+ When applied type classes returned by a Java method, this annotation
defines schema and Swagger information on the body of responses.
+</p>
+<p>
+ In the example above, we're using the <c>Ok</c> class which is defined
like so:
+</p>
+<p class='bpcode w800'>
+ <ja>@Response</ja>(
+ code=200,
+ description=<js>"OK"</js>
+ )
+ <jk>public class</jk> Ok {
+
+ <ja>@ResponseBody</ja>
+ <jk>public</jk> String toString() {
+ <jk>return</jk> <js>"OK"</js>;
+ }
+ }
+</p>
+<p>
+ Another example showing how a redirect can be defined:
+</p>
+<p class='bpcode w800'>
+ <ja>@Response</ja>(
+ code=307,
+ description=<js>"Temporary Redirect"</js>
+ )
+ <jk>public class</jk> Redirect {
+ <jk>private final</jk> URI <jf>location</jf>;
+
+ <jk>public</jk> Redirect(URI <jv>location</jv>) {
+ <jk>this</jk>.<jf>location</jf> = <jv>location</jv>;
+ }
+
+ <ja>@ResponseHeader</ja>(
+ name=<js>"Location"</js>,
+ format=<js>"uri"</js>
+ )
+ <jk>public</jk> URI getLocation() {
+ <jk>return</jk> <jf>location</jf>;
+ }
+
+ <ja>@ResponseBody</ja>
+ <jk>public</jk> String toString() {
+ <jk>return</jk> <js>"Temporary Redirect"</js>;
+ }
+ }
+</p>
+<p class='bpcode w800'>
+ <jc>// Usage</jc>
+ <ja>@RestPost</ja>
+ <jk>public</jk> Redirect postPet(Pet pet) {
+ <jc>// Redirect to servlet root</jc>
+ <jk>return new</jk>
Redirect(URI.<jsm>create</jsm>(<js>"servlet:/"</js>));
+ }
+</p>
+
+<h5 class='topic'>@Resource on @RestOp-annotated methods</h5>
+<p>
+ The <ja>@Response</ja> annotation can also be applied to the Java
method itself which is effectively
+ the same as applying it to the return type (albeit for this method
only).
+</p>
+<p class='bpcode w800'>
+ <ja>@RestGet</ja>(<js>"/user/login"</js>)
+ <ja>@Response</ja>(code=200, description=<js>"OK"</js>)
+ <jk>public</jk> Ok login(
+ <ja>@FormData</ja>(<js>"username"</js>) String
<jv>username</jv>,
+ <ja>@FormData</ja>(<js>"password"</js>) String <jv>password</jv>
+ ) <jk>throws</jk> InvalidLogin
+ {
+ <jsm>checkCredentials</jsm>(<jv>username</jv>,
<jv>password</jv>);
+ <jk>return new</jk> Ok();
+ }
+</p>
+<p>
+ The <ja>@Response</ja> annotation can be simultaneously on both the
Java method and return type.
+ When used in both locations, the annotation values are combined, but
values defined on the
+ method return annotation take precedence over the values defined on the
type.
+</p>
+
+<h5 class='topic'>@Resource on @RestOp-annotated method parameters</h5>
+<p>
+ The <ja>@Response</ja> annotation can also be applied to the Java
method parameters when the parameter type
+ is {@link oaj.Value} (a placeholder for objects).
+</p>
+<p class='bpcode w800'>
+ <ja>@RestGet</ja>(<js>"/user/login"</js>)
+ <jk>public void</jk> login(
+ <ja>@FormData</ja>(<js>"username"</js>) String
<jv>username</jv>,
+ <ja>@FormData</ja>(<js>"password"</js>) String <jv>password,/,
+ <ja>@Response</ja>(code=200, description=<js>"Login
succeeded"</js>) Value<String> <jv>body</jv>
+ ) <jk>throws</jk> InvalidLogin
+ {
+ <jsm>checkCredentials</jsm>(<jv>username</jv>,
<jv>password</jv>);
+ <jv>body</jv>.set(<js>"OK"</js>);
+ }
+</p>
+<p>
+ <ja>@Response</ja>-annotated types can also be used as value parameters:
+</p>
+<p class='bpcode w800'>
+ <ja>@RestGet</ja>(...)
+ <jk>public void</jk> login(
+ ...
+ <ja>@Response</ja> Value<Ok> <jv>res</jv>
+ ) <jk>throws</jk> InvalidLogin
+ {
+ ...
+ <jv>res</jv>.set(<jk>new</jk> Ok());
+ }
+</p>
+<p>
+ In the above example, the <ja>@Response</ja> annotation is optional
since it is inferred from the class
+ that it's a <ja>@Response</ja> bean.
+</p>
+<p class='bpcode w800'>
+ <ja>@RestGet</ja>(<js>"/user/login"</js>)
+ <jk>public void</jk> login(
+ ...
+ Value<Ok> <jv>res</jv> <jc>// @Response annotation not
needed.</jc>
+ ) <jk>throws</jk> InvalidLogin
+ {
+ ...
+ <jv>res</jv>.set(<jk>new</jk> Ok());
+ }
+</p>
+
+<h5 class='topic'>@ResponseStatus on methods of @Response-annotated types</h5>
+<p>
+ The {@link oaj.http.annotation.ResponseStatus @ResponseStatus}
annotation can be used on
+ the method of a <ja>@Response</ja>-annotated class to identify HTTP
response
+ statuses other than <c>200</c> (the default).
+</p>
+
+<h5 class='figure'>Example:</h5>
+<p class='bpcode w800'>
+ <ja>@Response</ja>
+ <jk>public class</jk> AddPetSuccess {
+
+ <ja>@ResponseStatus</ja>
+ <jk>public int</jk> getStatus() {
+ <jk>return</jk> 201;
+ }
+
+ <ja>@Override</ja>
+ <jk>public</jk> String toString() {
+ <jk>return</jk> <js>"Pet was successfully added"</js>;
+ }
+ }
+</p>
+
+
+<h5 class='topic'>@ResponseHeader on methods of @Response-annotated types</h5>
+<p>
+ The {@link oaj.http.annotation.ResponseHeader @ResponseHeader}
annotation can be used on
+ the method of a <ja>@Response</ja>-annotated class to identify a header
+ to add to the response.
+</p>
+
+<h5 class='figure'>Example:</h5>
+<p class='bpcode w800'>
+ <ja>@Response</ja>
+ <jk>public class</jk> AddPetSuccess {
+
+ <ja>@ResponseHeader</ja>(
+ name=<js>"X-PetId"</js>,
+ type=<js>"integer"</js>,
+ format=<js>"int32"</js>,
+ description=<js>"ID of added pet."</js>,
+ example=<js>"123"</js>
+ )
+ <jk>public int</jk> getPetId() {...}
+ }
+</p>
+
+<h5 class='topic'>@ResponseBody on methods of @Response-annotated types</h5>
+<p>
+ The {@link oaj.http.annotation.ResponseBody @ResponseBody} annotation
can be used on
+ the method of a <ja>@Response</ja>-annotated class to identify a POJO
+ as the body of the HTTP response.
+</p>
+
+<h5 class='figure'>Example:</h5>
+<p class='bpcode w800'>
+ <ja>@Response</ja>
+ <jk>public class</jk> AddPetSuccess {
+
+ <ja>@ResponseBody</ja>
+ <jk>public</jk> Pet getPet() {...}
+ }
+</p>
+
+<p>
+ If a <ja>@Response</ja> class does not have a
<ja>@ResponseBody</ja>-annotated method, then the response
+ object itself is serialized in the response (typically using
<c>toString()</c>).
+</p>
+
+<h5 class='topic'>Notes about OpenAPI part serialization</h5>
+<p>
+ By default, POJOs representing the body of the request are serialized
using the Juneau serializer
+ matching the requesting <c>Accept</c> header.
+ The {@link oaj.oapi.OpenApiSerializer} class can be used to serialize
response bodies using OpenAPI rules.
+</p>
+<p>
+ The following examples show part-schema-based serialization of response
bodies:
+</p>
+<p class='bpcode w800'>
+ <ja>@Rest</ja>
+ <jk>public class</jk> ExampleResource {
+
+ <jc>// Example 1 - String[] should be serialized using part
serializer.</jc>
+ <ja>@Response</ja>(
+ serializers=OpenApiSerializer.<jk>class</jk>,
+ defaultAccept=<js>"text/openapi"</js>
+ )
+ <ja>@RestGet</ja>
+ <jk>public</jk> String[] example1() {
+ <jk>return new</jk>
String[]{<js>"foo"</js>,<js>"bar"</js>};
+ }
+
+ <jc>// Example 2 - Same as above. Annotation on parameter.</jc>
+ <ja>@RestGet</ja>
+ <jk>public void</jk> example2(
+ <ja>@Response</ja>(
+ serializers=OpenApiSerializer.<jk>class</jk>,
+ defaultAccept=<js>"text/openapi"</js>
+ )
+ Value<String[]> <jv>body</jv>
+ )
+ {
+ <jv>body</jv>.set(<jk>new</jk>
String[]{<js>"foo"</js>,<js>"bar"</js>});
+ }
+ }
+</p>
+<p>
+ The <c><ja>@Response</ja>(schema)</c> annotation can be used to define
the format of the output using OpenAPI-based rules.
+</p>
+<p class='bpcode w800'>
+ <ja>@Rest</ja>
+ <jk>public class</jk> ExampleResource {
+
+ <ja>@Response</ja>(
+ serializers=OpenApiSerializer.<jk>class</jk>,
+ defaultAccept=<js>"text/openapi"</js>,
+
schema=<ja>@Schema</ja>(collectionFormat=<js>"pipes"</js>)
+ )
+ <ja>@RestGet</ja>
+ <jk>public</jk> String[] example1() {
+ <jk>return new</jk>
String[]{<js>"foo"</js>,<js>"bar"</js>};
+ }
+ }
+</p>
+
+<h5 class='topic'>Swagger documentation</h5>
+<p>
+ The attributes on this annotation are also used to populate the
generated Swagger for the method.
+ For example, in the case of the <c>InvalidLogin</c> example above, the
following Swagger is generated:
+</p>
+<p class='bpcode w800'>
+ <jok>'/user/login'</jok>: {
+ <jok>get</jok>: {
+ <jok>responses</jok>: {
+ <jok>401</jok>: {
+ <jok>description</jok>: <jov>'Invalid
username or password provided'</jov>
+ }
+ }
+ }
+ }
+</p>
+
+<h5 class='topic'>Automatic HTTP status</h5>
+<p>
+ When the {@link oaj.http.annotation.Response#code() @Response(code)}
value is specified,
+ the HTTP status is automatically set to that value on the response
regardless of how it's used.
+</p>
+<p>
+ The following two examples are equivalent:
+</p>
+<p class='bpcode w800'>
+ <ja>@RestGet</ja>(<js>"/ok"</js>)
+ <jk>public void</jk> sendContinue(
+ <ja>@Response</ja>(code=100) Value<String> <jv>body</jv>
+ )
+ {
+ <jv>body</jv>.set(<js>"OK"</js>);
+ }
+</p>
+<p class='bpcode w800'>
+ <ja>@RestGet</ja>(<js>"/ok"</js>)
+ <jk>public void</jk> sendContinue(RestResponse <jv>res</jv>) {
+ <jv>res</jv>.setStatus(100);
+ <jv>res</jv>.setOutput(<js>"OK"</js>);
+ }
+</p>
+
+<ul class='seealso'>
+ <li class='link'>{@doc RestOpenApiSchemaPartSerializing}
+</ul>
+
+<p>
+ The {@link oaj.http.annotation.ResponseHeader @ResponseHeader}
annotation can be applied to <ja>@RestOp</ja>-annotated parameters to denote
them as an HTTP response headers.
+</p>
+<ul class='javatree'>
+ <li class='ja'>{@link oaj.http.annotation.ResponseHeader}
+ <ul>
+ <li class='jf'>{@link
oaj.http.annotation.ResponseHeader#_default() _default} - Default value if not
present.
+ <li class='jf'>{@link
oaj.http.annotation.ResponseHeader#_enum() _enum} - Output validation. Must
match one of the values.
+ <li class='jf'>{@link oaj.http.annotation.ResponseHeader#$ref()
$ref} - Schema reference.
+ <li class='jf'>{@link oaj.http.annotation.ResponseHeader#api()
api} - Free-form Swagger JSON.
+ <li class='jf'>{@link oaj.http.annotation.ResponseHeader#code()
code} - HTTP status codes that this header applies to.
+ <li class='jf'>{@link
oaj.http.annotation.ResponseHeader#collectionFormat() collectionFormat} - How
collections of items are formatted.
+ <li class='jf'>{@link
oaj.http.annotation.ResponseHeader#description() description} - Description.
+ <li class='jf'>{@link
oaj.http.annotation.ResponseHeader#example() example} - Serialized example.
+ <li class='jf'>{@link
oaj.http.annotation.ResponseHeader#exclusiveMaximum() exclusiveMaximum} -
Output validation. Whether maximum is exclusive.
+ <li class='jf'>{@link
oaj.http.annotation.ResponseHeader#exclusiveMinimum() exclusiveMinimum} -
Output validation. Whether minimum is exclusive.
+ <li class='jf'>{@link
oaj.http.annotation.ResponseHeader#format() format} - The schema type format.
+ <li class='jf'>{@link
oaj.http.annotation.ResponseHeader#items() items} - The schema of items in a
collection.
+ <li class='jf'>{@link
oaj.http.annotation.ResponseHeader#maximum() maximum} - Output validation.
Maximum numeric value.
+ <li class='jf'>{@link
oaj.http.annotation.ResponseHeader#maxItems() maxItems} - Output validation.
Maximum number of items in a collection.
+ <li class='jf'>{@link
oaj.http.annotation.ResponseHeader#maxLength() maxLength} - Output validation.
Maximum length of a string.
+ <li class='jf'>{@link
oaj.http.annotation.ResponseHeader#minimum() minimum} - Output validation.
Minimum numeric value.
+ <li class='jf'>{@link
oaj.http.annotation.ResponseHeader#minItems() minItems} - Output validation.
Minimum number of items in a collection.
+ <li class='jf'>{@link
oaj.http.annotation.ResponseHeader#minLength() minLength} - Output validation.
Minimum length of a string.
+ <li class='jf'>{@link
oaj.http.annotation.ResponseHeader#multipleOf() multipleOf} - Output
validation. Number must be a multiple of.
+ <li class='jf'>{@link oaj.http.annotation.ResponseHeader#name()
name} - Header name.
+ <li class='jf'>{@link
oaj.http.annotation.ResponseHeader#pattern() pattern} - Output validation.
Must match regular expression.
+ <li class='jf'>{@link
oaj.http.annotation.ResponseHeader#serializer() serializer} - Override the part
serializer.
+ <li class='jf'>{@link oaj.http.annotation.ResponseHeader#type()
type} - The schema type.
+ <li class='jf'>{@link
oaj.http.annotation.ResponseHeader#uniqueItems() uniqueItems} - Output
validation. Collections must contain unique items only.
+ <li class='jf'>{@link
oaj.http.annotation.ResponseHeader#value() value} - Free-form Swagger JSON.
+ </ul>
+</ul>
+<p>
+ This annotation can only be applied to parameters of type {@link
oaj.Value}.
+</p>
+<p>
+ The following examples show 3 different ways of accomplishing the same
task of setting an HTTP header
+ on a response:
+</p>
+<p class='bpcode w800'>
+ <jc>// Example #1 - Setting header directly on RestResponse object.</jc>
+ <ja>@RestGet</ja>(...)
+ <jk>public void</jk> login(RestResponse res) {
+ res.setHeader(<js>"X-Rate-Limit"</js>, 1000);
+ ...
+ }
+
+ <jc>// Example #2 - Use on parameter.</jc>
+ <ja>@RestGet</ja>(...)
+ <jk>public void</jk> login(
+ <ja>@ResponseHeader</ja>(
+ name=<js>"X-Rate-Limit"</js>,
+ type=<js>"integer"</js>,
+ format=<js>"int32"</js>,
+ description=<js>"Calls per hour allowed by the
user."</js>,
+ example=<js>"123"</js>
+ )
+ Value<Integer> <jv>rateLimit</jv>
+ )
+ {
+ <jv>rateLimit</jv>.set(1000);
+ ...
+ }
+
+ <jc>// Example #3 - Use on type.</jc>
+ <ja>@RestGet</ja>(...)
+ <jk>public void</jk> login(Value<RateLimit> <jv>rateLimit</jv>) {
+ <jv>rateLimit</jv>.set(<jk>new</jk> RateLimit());
+ ...
+ }
+
+ <ja>@ResponseHeader</ja>(
+ name=<js>"X-Rate-Limit"</js>,
+ type=<js>"integer"</js>,
+ format=<js>"int32"</js>,
+ description=<js>"Calls per hour allowed by the user."</js>,
+ example=<js>"123"</js>
+ )
+ <jk>public class</jk> RateLimit {
+ <jc>// OpenApiSerializer knows to look for this method based on
format/type.</jc>
+ <jk>public</jk> Integer toInteger() {
+ <jk>return</jk> 1000;
+ }
+ }
+</p>
+
+<p>
+ The {@link oaj.http.annotation.ResponseStatus @ResponseStatus}
annotation annotation can be applied to <ja>@RestOp</ja>-annotated parameters
to denote them as an HTTP response status codes.
+</p>
+<ul class='javatree'>
+ <li class='ja'>{@link oaj.http.annotation.ResponseStatus}
+</ul>
+<p>
+ This can only be applied to parameters of the {@link oaj.Value} class
with an {@link java.lang.Integer} type.
+</p>
+
+<h5 class='figure'>Examples:</h5>
+<p class='bpcode w800'>
+ <jc>// Defined on parameter.</jc>
+ <ja>@RestGet</ja>(<js>"/user/login"</js>)
+ <jk>public void</jk> login(
+ <ja>@FormData</ja>(<js>"username"</js>) String
<jv>username</jv>,
+ <ja>@FormData</ja>(<js>"password"</js>) String
<jv>password</jv>,
+ <ja>@ResponseStatus</ja> Value<Integer> <jv>status</jv>
+ )
+ {
+ <jk>if</jk> (! <jsm>isValid</jsm>(<jv>username</jv>,
<jv>password</jv>))
+ <jv>status</jv>.set(401);
+ }
+</p>
+
diff --git
a/juneau-doc/docs/Topics/06.juneau-rest-server/04.HttpParts/07.RequestHeader_RequestQueryParams_RequestFormParams_RequestPathParams.html
b/juneau-doc/docs/Topics/06.juneau-rest-server/04.HttpParts/07.RequestHeader_RequestQueryParams_RequestFormParams_RequestPathParams.html
new file mode 100644
index 0000000..75a7f96
--- /dev/null
+++
b/juneau-doc/docs/Topics/06.juneau-rest-server/04.HttpParts/07.RequestHeader_RequestQueryParams_RequestFormParams_RequestPathParams.html
@@ -0,0 +1,20 @@
+<!--
+/***************************************************************************************************************************
+ * 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.
+
***************************************************************************************************************************/
+ -->
+
+{title:'RequestHeaders / RequestQueryParams / RequestFormParams /
RequestPathParams', created:'9.0.0'}
+
+<p>
+ TODO
+</p>
\ No newline at end of file
diff --git
a/juneau-microservice/juneau-microservice-ftest/src/test/java/org/apache/juneau/rest/test/client/ThirdPartyProxyResource.java
b/juneau-microservice/juneau-microservice-ftest/src/test/java/org/apache/juneau/rest/test/client/ThirdPartyProxyResource.java
index bc9045b..d9142a4 100644
---
a/juneau-microservice/juneau-microservice-ftest/src/test/java/org/apache/juneau/rest/test/client/ThirdPartyProxyResource.java
+++
b/juneau-microservice/juneau-microservice-ftest/src/test/java/org/apache/juneau/rest/test/client/ThirdPartyProxyResource.java
@@ -188,15 +188,15 @@ public class ThirdPartyProxyResource extends
BasicRestServletJena {
@RestGet(path="/typedBeanHeaders")
public String typedBeanHeaders(
- @Header(n="a") @Schema(cf="uon") TypedBean a,
- @Header(n="an") @Schema(cf="uon") TypedBean an,
- @Header(n="b") @Schema(cf="uon") TypedBean[][][] b,
- @Header(n="c") @Schema(cf="uon") List<TypedBean> c,
- @Header(n="d") @Schema(cf="uon") List<TypedBean[][][]>
d,
- @Header(n="e") @Schema(cf="uon") Map<String,TypedBean>
e,
- @Header(n="f") @Schema(cf="uon")
Map<String,List<TypedBean>> f,
- @Header(n="g") @Schema(cf="uon")
Map<String,List<TypedBean[][][]>> g,
- @Header(n="h") @Schema(cf="uon")
Map<Integer,List<TypedBean>> h
+ @Header("a") @Schema(cf="uon") TypedBean a,
+ @Header("an") @Schema(cf="uon") TypedBean an,
+ @Header("b") @Schema(cf="uon") TypedBean[][][] b,
+ @Header("c") @Schema(cf="uon") List<TypedBean> c,
+ @Header("d") @Schema(cf="uon") List<TypedBean[][][]> d,
+ @Header("e") @Schema(cf="uon") Map<String,TypedBean> e,
+ @Header("f") @Schema(cf="uon")
Map<String,List<TypedBean>> f,
+ @Header("g") @Schema(cf="uon")
Map<String,List<TypedBean[][][]>> g,
+ @Header("h") @Schema(cf="uon")
Map<Integer,List<TypedBean>> h
) throws Exception {
assertObject(a).asJson().is("{a:1,b:'foo'}");
@@ -224,10 +224,10 @@ public class ThirdPartyProxyResource extends
BasicRestServletJena {
@RestGet(path="/swappedObjectHeaders")
public String swappedObjectHeaders(
- @Header(n="a") @Schema(cf="uon") SwappedObject a,
- @Header(n="b") @Schema(cf="uon") SwappedObject[][][] b,
- @Header(n="c") @Schema(cf="uon")
Map<SwappedObject,SwappedObject> c,
- @Header(n="d") @Schema(cf="uon")
Map<SwappedObject,SwappedObject[][][]> d
+ @Header("a") @Schema(cf="uon") SwappedObject a,
+ @Header("b") @Schema(cf="uon") SwappedObject[][][] b,
+ @Header("c") @Schema(cf="uon")
Map<SwappedObject,SwappedObject> c,
+ @Header("d") @Schema(cf="uon")
Map<SwappedObject,SwappedObject[][][]> d
) throws Exception {
assertObject(a).asJson().is("'swap-~!@#$%^&*()_+`-={}[]|:;\"<,>.?/'");
@@ -247,10 +247,10 @@ public class ThirdPartyProxyResource extends
BasicRestServletJena {
@RestGet(path="/implicitSwappedObjectHeaders")
public String implicitSwappedObjectHeaders(
- @Header(n="a") @Schema(cf="uon") ImplicitSwappedObject
a,
- @Header(n="b") @Schema(cf="uon")
ImplicitSwappedObject[][][] b,
- @Header(n="c") @Schema(cf="uon")
Map<ImplicitSwappedObject,ImplicitSwappedObject> c,
- @Header(n="d") @Schema(cf="uon")
Map<ImplicitSwappedObject,ImplicitSwappedObject[][][]> d
+ @Header("a") @Schema(cf="uon") ImplicitSwappedObject a,
+ @Header("b") @Schema(cf="uon")
ImplicitSwappedObject[][][] b,
+ @Header("c") @Schema(cf="uon")
Map<ImplicitSwappedObject,ImplicitSwappedObject> c,
+ @Header("d") @Schema(cf="uon")
Map<ImplicitSwappedObject,ImplicitSwappedObject[][][]> d
) throws Exception {
assertObject(a).asJson().is("'swap-~!@#$%^&*()_+`-={}[]|:;\"<,>.?/'");
@@ -270,15 +270,15 @@ public class ThirdPartyProxyResource extends
BasicRestServletJena {
@RestGet(path="/enumHeaders")
public String enumHeaders(
- @Header(n="a") @Schema(cf="uon") TestEnum a,
- @Header(n="an") @Schema(cf="uon") TestEnum an,
- @Header(n="b") @Schema(cf="uon") TestEnum[][][] b,
- @Header(n="c") @Schema(cf="uon") List<TestEnum> c,
- @Header(n="d") @Schema(cf="uon")
List<List<List<TestEnum>>> d,
- @Header(n="e") @Schema(cf="uon") List<TestEnum[][][]> e,
- @Header(n="f") @Schema(cf="uon") Map<TestEnum,TestEnum>
f,
- @Header(n="g") @Schema(cf="uon")
Map<TestEnum,TestEnum[][][]> g,
- @Header(n="h") @Schema(cf="uon")
Map<TestEnum,List<TestEnum[][][]>> h
+ @Header("a") @Schema(cf="uon") TestEnum a,
+ @Header("an") @Schema(cf="uon") TestEnum an,
+ @Header("b") @Schema(cf="uon") TestEnum[][][] b,
+ @Header("c") @Schema(cf="uon") List<TestEnum> c,
+ @Header("d") @Schema(cf="uon")
List<List<List<TestEnum>>> d,
+ @Header("e") @Schema(cf="uon") List<TestEnum[][][]> e,
+ @Header("f") @Schema(cf="uon") Map<TestEnum,TestEnum> f,
+ @Header("g") @Schema(cf="uon")
Map<TestEnum,TestEnum[][][]> g,
+ @Header("h") @Schema(cf="uon")
Map<TestEnum,List<TestEnum[][][]>> h
) throws Exception {
assertEquals(TestEnum.TWO, a);
@@ -467,15 +467,15 @@ public class ThirdPartyProxyResource extends
BasicRestServletJena {
@RestGet(path="/beanQueries")
public String beanQueries(
- @Query(n="a") @Schema(cf="uon") ABean a,
- @Query(n="an") @Schema(cf="uon") ABean an,
- @Query(n="b") @Schema(cf="uon") ABean[][][] b,
- @Query(n="c") @Schema(cf="uon") List<ABean> c,
- @Query(n="d") @Schema(cf="uon") List<ABean[][][]> d,
- @Query(n="e") @Schema(cf="uon") Map<String,ABean> e,
- @Query(n="f") @Schema(cf="uon") Map<String,List<ABean>>
f,
- @Query(n="g") @Schema(cf="uon")
Map<String,List<ABean[][][]>> g,
- @Query(n="h") @Schema(cf="uon")
Map<Integer,List<ABean>> h
+ @Query("a") @Schema(cf="uon") ABean a,
+ @Query("an") @Schema(cf="uon") ABean an,
+ @Query("b") @Schema(cf="uon") ABean[][][] b,
+ @Query("c") @Schema(cf="uon") List<ABean> c,
+ @Query("d") @Schema(cf="uon") List<ABean[][][]> d,
+ @Query("e") @Schema(cf="uon") Map<String,ABean> e,
+ @Query("f") @Schema(cf="uon") Map<String,List<ABean>> f,
+ @Query("g") @Schema(cf="uon")
Map<String,List<ABean[][][]>> g,
+ @Query("h") @Schema(cf="uon") Map<Integer,List<ABean>> h
) throws Exception {
assertObject(a).asJson().is("{a:1,b:'foo'}");
@@ -500,15 +500,15 @@ public class ThirdPartyProxyResource extends
BasicRestServletJena {
@RestGet(path="/typedBeanQueries")
public String typedBeanQueries(
- @Query(n="a") @Schema(cf="uon") TypedBean a,
- @Query(n="an") @Schema(cf="uon") TypedBean an,
- @Query(n="b") @Schema(cf="uon") TypedBean[][][] b,
- @Query(n="c") @Schema(cf="uon") List<TypedBean> c,
- @Query(n="d") @Schema(cf="uon") List<TypedBean[][][]> d,
- @Query(n="e") @Schema(cf="uon") Map<String,TypedBean> e,
- @Query(n="f") @Schema(cf="uon")
Map<String,List<TypedBean>> f,
- @Query(n="g") @Schema(cf="uon")
Map<String,List<TypedBean[][][]>> g,
- @Query(n="h") @Schema(cf="uon")
Map<Integer,List<TypedBean>> h
+ @Query("a") @Schema(cf="uon") TypedBean a,
+ @Query("an") @Schema(cf="uon") TypedBean an,
+ @Query("b") @Schema(cf="uon") TypedBean[][][] b,
+ @Query("c") @Schema(cf="uon") List<TypedBean> c,
+ @Query("d") @Schema(cf="uon") List<TypedBean[][][]> d,
+ @Query("e") @Schema(cf="uon") Map<String,TypedBean> e,
+ @Query("f") @Schema(cf="uon")
Map<String,List<TypedBean>> f,
+ @Query("g") @Schema(cf="uon")
Map<String,List<TypedBean[][][]>> g,
+ @Query("h") @Schema(cf="uon")
Map<Integer,List<TypedBean>> h
) throws Exception {
assertObject(a).asJson().is("{a:1,b:'foo'}");
@@ -536,10 +536,10 @@ public class ThirdPartyProxyResource extends
BasicRestServletJena {
@RestGet(path="/swappedObjectQueries")
public String swappedObjectQueries(
- @Query(n="a") @Schema(cf="uon") SwappedObject a,
- @Query(n="b") @Schema(cf="uon") SwappedObject[][][] b,
- @Query(n="c") @Schema(cf="uon")
Map<SwappedObject,SwappedObject> c,
- @Query(n="d") @Schema(cf="uon")
Map<SwappedObject,SwappedObject[][][]> d
+ @Query("a") @Schema(cf="uon") SwappedObject a,
+ @Query("b") @Schema(cf="uon") SwappedObject[][][] b,
+ @Query("c") @Schema(cf="uon")
Map<SwappedObject,SwappedObject> c,
+ @Query("d") @Schema(cf="uon")
Map<SwappedObject,SwappedObject[][][]> d
) throws Exception {
assertObject(a).asJson().is("'swap-~!@#$%^&*()_+`-={}[]|:;\"<,>.?/'");
@@ -559,10 +559,10 @@ public class ThirdPartyProxyResource extends
BasicRestServletJena {
@RestGet(path="/implicitSwappedObjectQueries")
public String implicitSwappedObjectQueries(
- @Query(n="a") @Schema(cf="uon") ImplicitSwappedObject a,
- @Query(n="b") @Schema(cf="uon")
ImplicitSwappedObject[][][] b,
- @Query(n="c") @Schema(cf="uon")
Map<ImplicitSwappedObject,ImplicitSwappedObject> c,
- @Query(n="d") @Schema(cf="uon")
Map<ImplicitSwappedObject,ImplicitSwappedObject[][][]> d
+ @Query("a") @Schema(cf="uon") ImplicitSwappedObject a,
+ @Query("b") @Schema(cf="uon")
ImplicitSwappedObject[][][] b,
+ @Query("c") @Schema(cf="uon")
Map<ImplicitSwappedObject,ImplicitSwappedObject> c,
+ @Query("d") @Schema(cf="uon")
Map<ImplicitSwappedObject,ImplicitSwappedObject[][][]> d
) throws Exception {
assertObject(a).asJson().is("'swap-~!@#$%^&*()_+`-={}[]|:;\"<,>.?/'");
@@ -582,15 +582,15 @@ public class ThirdPartyProxyResource extends
BasicRestServletJena {
@RestGet(path="/enumQueries")
public String enumQueries(
- @Query(n="a") @Schema(cf="uon") TestEnum a,
- @Query(n="an") @Schema(cf="uon") TestEnum an,
- @Query(n="b") @Schema(cf="uon") TestEnum[][][] b,
- @Query(n="c") @Schema(cf="uon") List<TestEnum> c,
- @Query(n="d") @Schema(cf="uon")
List<List<List<TestEnum>>> d,
- @Query(n="e") @Schema(cf="uon") List<TestEnum[][][]> e,
- @Query(n="f") @Schema(cf="uon") Map<TestEnum,TestEnum>
f,
- @Query(n="g") @Schema(cf="uon")
Map<TestEnum,TestEnum[][][]> g,
- @Query(n="h") @Schema(cf="uon")
Map<TestEnum,List<TestEnum[][][]>> h
+ @Query("a") @Schema(cf="uon") TestEnum a,
+ @Query("an") @Schema(cf="uon") TestEnum an,
+ @Query("b") @Schema(cf="uon") TestEnum[][][] b,
+ @Query("c") @Schema(cf="uon") List<TestEnum> c,
+ @Query("d") @Schema(cf="uon")
List<List<List<TestEnum>>> d,
+ @Query("e") @Schema(cf="uon") List<TestEnum[][][]> e,
+ @Query("f") @Schema(cf="uon") Map<TestEnum,TestEnum> f,
+ @Query("g") @Schema(cf="uon")
Map<TestEnum,TestEnum[][][]> g,
+ @Query("h") @Schema(cf="uon")
Map<TestEnum,List<TestEnum[][][]>> h
) throws Exception {
assertEquals(TestEnum.TWO, a);
@@ -655,7 +655,7 @@ public class ThirdPartyProxyResource extends
BasicRestServletJena {
@RestGet(path="/beanQuery")
public String beanQuery(
@Query("a") String a,
- @Query(n="b") @Schema(allowEmptyValue=true) String b,
+ @Query("b") @Schema(allowEmptyValue=true) String b,
@Query("c") String c
) throws Exception {
@@ -669,7 +669,7 @@ public class ThirdPartyProxyResource extends
BasicRestServletJena {
@RestGet(path="/partListQuery")
public String partListQuery(
@Query("a") String a,
- @Query(n="b") @Schema(allowEmptyValue=true) String b,
+ @Query("b") @Schema(allowEmptyValue=true) String b,
@Query("c") String c
) throws Exception {
@@ -801,15 +801,15 @@ public class ThirdPartyProxyResource extends
BasicRestServletJena {
@RestPost(path="/beanFormData")
public String beanFormData(
- @FormData(n="a") @Schema(cf="uon") ABean a,
- @FormData(n="an") @Schema(cf="uon") ABean an,
- @FormData(n="b") @Schema(cf="uon") ABean[][][] b,
- @FormData(n="c") @Schema(cf="uon") List<ABean> c,
- @FormData(n="d") @Schema(cf="uon") List<ABean[][][]> d,
- @FormData(n="e") @Schema(cf="uon") Map<String,ABean> e,
- @FormData(n="f") @Schema(cf="uon")
Map<String,List<ABean>> f,
- @FormData(n="g") @Schema(cf="uon")
Map<String,List<ABean[][][]>> g,
- @FormData(n="h") @Schema(cf="uon")
Map<Integer,List<ABean>> h
+ @FormData("a") @Schema(cf="uon") ABean a,
+ @FormData("an") @Schema(cf="uon") ABean an,
+ @FormData("b") @Schema(cf="uon") ABean[][][] b,
+ @FormData("c") @Schema(cf="uon") List<ABean> c,
+ @FormData("d") @Schema(cf="uon") List<ABean[][][]> d,
+ @FormData("e") @Schema(cf="uon") Map<String,ABean> e,
+ @FormData("f") @Schema(cf="uon")
Map<String,List<ABean>> f,
+ @FormData("g") @Schema(cf="uon")
Map<String,List<ABean[][][]>> g,
+ @FormData("h") @Schema(cf="uon")
Map<Integer,List<ABean>> h
) throws Exception {
assertObject(a).asJson().is("{a:1,b:'foo'}");
@@ -834,15 +834,15 @@ public class ThirdPartyProxyResource extends
BasicRestServletJena {
@RestPost(path="/typedBeanFormData")
public String typedBeanFormData(
- @FormData(n="a") @Schema(cf="uon") TypedBean a,
- @FormData(n="an") @Schema(cf="uon") TypedBean an,
- @FormData(n="b") @Schema(cf="uon") TypedBean[][][] b,
- @FormData(n="c") @Schema(cf="uon") List<TypedBean> c,
- @FormData(n="d") @Schema(cf="uon")
List<TypedBean[][][]> d,
- @FormData(n="e") @Schema(cf="uon")
Map<String,TypedBean> e,
- @FormData(n="f") @Schema(cf="uon")
Map<String,List<TypedBean>> f,
- @FormData(n="g") @Schema(cf="uon")
Map<String,List<TypedBean[][][]>> g,
- @FormData(n="h") @Schema(cf="uon")
Map<Integer,List<TypedBean>> h
+ @FormData("a") @Schema(cf="uon") TypedBean a,
+ @FormData("an") @Schema(cf="uon") TypedBean an,
+ @FormData("b") @Schema(cf="uon") TypedBean[][][] b,
+ @FormData("c") @Schema(cf="uon") List<TypedBean> c,
+ @FormData("d") @Schema(cf="uon") List<TypedBean[][][]>
d,
+ @FormData("e") @Schema(cf="uon") Map<String,TypedBean>
e,
+ @FormData("f") @Schema(cf="uon")
Map<String,List<TypedBean>> f,
+ @FormData("g") @Schema(cf="uon")
Map<String,List<TypedBean[][][]>> g,
+ @FormData("h") @Schema(cf="uon")
Map<Integer,List<TypedBean>> h
) throws Exception {
assertObject(a).asJson().is("{a:1,b:'foo'}");
@@ -870,10 +870,10 @@ public class ThirdPartyProxyResource extends
BasicRestServletJena {
@RestPost(path="/swappedObjectFormData")
public String swappedObjectFormData(
- @FormData(n="a") @Schema(cf="uon") SwappedObject a,
- @FormData(n="b") @Schema(cf="uon") SwappedObject[][][]
b,
- @FormData(n="c") @Schema(cf="uon")
Map<SwappedObject,SwappedObject> c,
- @FormData(n="d") @Schema(cf="uon")
Map<SwappedObject,SwappedObject[][][]> d
+ @FormData("a") @Schema(cf="uon") SwappedObject a,
+ @FormData("b") @Schema(cf="uon") SwappedObject[][][] b,
+ @FormData("c") @Schema(cf="uon")
Map<SwappedObject,SwappedObject> c,
+ @FormData("d") @Schema(cf="uon")
Map<SwappedObject,SwappedObject[][][]> d
) throws Exception {
assertObject(a).asJson().is("'swap-~!@#$%^&*()_+`-={}[]|:;\"<,>.?/'");
@@ -893,10 +893,10 @@ public class ThirdPartyProxyResource extends
BasicRestServletJena {
@RestPost(path="/implicitSwappedObjectFormData")
public String implicitSwappedObjectFormData(
- @FormData(n="a") @Schema(cf="uon")
ImplicitSwappedObject a,
- @FormData(n="b") @Schema(cf="uon")
ImplicitSwappedObject[][][] b,
- @FormData(n="c") @Schema(cf="uon")
Map<ImplicitSwappedObject,ImplicitSwappedObject> c,
- @FormData(n="d") @Schema(cf="uon")
Map<ImplicitSwappedObject,ImplicitSwappedObject[][][]> d
+ @FormData("a") @Schema(cf="uon") ImplicitSwappedObject
a,
+ @FormData("b") @Schema(cf="uon")
ImplicitSwappedObject[][][] b,
+ @FormData("c") @Schema(cf="uon")
Map<ImplicitSwappedObject,ImplicitSwappedObject> c,
+ @FormData("d") @Schema(cf="uon")
Map<ImplicitSwappedObject,ImplicitSwappedObject[][][]> d
) throws Exception {
assertObject(a).asJson().is("'swap-~!@#$%^&*()_+`-={}[]|:;\"<,>.?/'");
@@ -916,15 +916,15 @@ public class ThirdPartyProxyResource extends
BasicRestServletJena {
@RestPost(path="/enumFormData")
public String enumFormData(
- @FormData(n="a") @Schema(cf="uon") TestEnum a,
- @FormData(n="an") @Schema(cf="uon") TestEnum an,
- @FormData(n="b") @Schema(cf="uon") TestEnum[][][] b,
- @FormData(n="c") @Schema(cf="uon") List<TestEnum> c,
- @FormData(n="d") @Schema(cf="uon")
List<List<List<TestEnum>>> d,
- @FormData(n="e") @Schema(cf="uon") List<TestEnum[][][]>
e,
- @FormData(n="f") @Schema(cf="uon")
Map<TestEnum,TestEnum> f,
- @FormData(n="g") @Schema(cf="uon")
Map<TestEnum,TestEnum[][][]> g,
- @FormData(n="h") @Schema(cf="uon")
Map<TestEnum,List<TestEnum[][][]>> h
+ @FormData("a") @Schema(cf="uon") TestEnum a,
+ @FormData("an") @Schema(cf="uon") TestEnum an,
+ @FormData("b") @Schema(cf="uon") TestEnum[][][] b,
+ @FormData("c") @Schema(cf="uon") List<TestEnum> c,
+ @FormData("d") @Schema(cf="uon")
List<List<List<TestEnum>>> d,
+ @FormData("e") @Schema(cf="uon") List<TestEnum[][][]> e,
+ @FormData("f") @Schema(cf="uon") Map<TestEnum,TestEnum>
f,
+ @FormData("g") @Schema(cf="uon")
Map<TestEnum,TestEnum[][][]> g,
+ @FormData("h") @Schema(cf="uon")
Map<TestEnum,List<TestEnum[][][]>> h
) throws Exception {
assertEquals(TestEnum.TWO, a);
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/BasicSwaggerProviderSession.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/BasicSwaggerProviderSession.java
index ba79417..4598a2d 100644
---
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/BasicSwaggerProviderSession.java
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/BasicSwaggerProviderSession.java
@@ -321,12 +321,7 @@ public class BasicSwaggerProviderSession {
addBodyExamples(sm, param, false, type,
locale);
} else if (mpi.hasAnnotation(Query.class) ||
pt.hasAnnotation(Query.class)) {
- String name = null;
- for (Query a :
mpi.getAnnotations(Query.class))
- name = firstNonEmpty(a.name(),
a.n(), a.value(), name);
- for (Query a :
pt.getAnnotations(Query.class))
- name = firstNonEmpty(a.name(),
a.n(), a.value(), name);
-
+ String name =
QueryAnnotation.findName(mpi.getAnnotations(Query.class),
pt.getAnnotations(Query.class)).orElse(null);
OMap param = paramMap.getMap(QUERY +
"." + name, true).a("name", name).a("in", QUERY);
pt.getAnnotations(Schema.class).forEach(x -> merge(param, x));
pt.getAnnotations(Query.class).forEach(x -> merge(param, x.schema()));
@@ -336,12 +331,7 @@ public class BasicSwaggerProviderSession {
addParamExample(sm, param, QUERY, type);
} else if (mpi.hasAnnotation(FormData.class) ||
pt.hasAnnotation(FormData.class)) {
- String name = null;
- for (FormData a :
mpi.getAnnotations(FormData.class))
- name = firstNonEmpty(a.name(),
a.n(), a.value(), name);
- for (FormData a :
pt.getAnnotations(FormData.class))
- name = firstNonEmpty(a.name(),
a.n(), a.value(), name);
-
+ String name =
FormDataAnnotation.findName(mpi.getAnnotations(FormData.class),
pt.getAnnotations(FormData.class)).orElse(null);
OMap param = paramMap.getMap(FORM_DATA
+ "." + name, true).a("name", name).a("in", FORM_DATA);
pt.getAnnotations(Schema.class).forEach(x -> merge(param, x));
pt.getAnnotations(FormData.class).forEach(x -> merge(param, x.schema()));
@@ -351,12 +341,7 @@ public class BasicSwaggerProviderSession {
addParamExample(sm, param, FORM_DATA,
type);
} else if (mpi.hasAnnotation(Header.class) ||
pt.hasAnnotation(Header.class)) {
- String name = null;
- for (Header a :
mpi.getAnnotations(Header.class))
- name = firstNonEmpty(a.name(),
a.n(), a.value(), name);
- for (Header a :
pt.getAnnotations(Header.class))
- name = firstNonEmpty(a.name(),
a.n(), a.value(), name);
-
+ String name =
HeaderAnnotation.findName(mpi.getAnnotations(Header.class),
pt.getAnnotations(Header.class)).orElse(null);
OMap param = paramMap.getMap(HEADER +
"." + name, true).a("name", name).a("in", HEADER);
pt.getAnnotations(Schema.class).forEach(x -> merge(param, x));
pt.getAnnotations(Header.class).forEach(x -> merge(param, x.schema()));
@@ -366,12 +351,7 @@ public class BasicSwaggerProviderSession {
addParamExample(sm, param, HEADER,
type);
} else if (mpi.hasAnnotation(Path.class) ||
pt.hasAnnotation(Path.class)) {
- String name = null;
- for (Path a :
mpi.getAnnotations(Path.class))
- name = firstNonEmpty(a.name(),
a.n(), a.value(), name);
- for (Path a :
pt.getAnnotations(Path.class))
- name = firstNonEmpty(a.name(),
a.n(), a.value(), name);
-
+ String name =
PathAnnotation.findName(mpi.getAnnotations(Path.class),
pt.getAnnotations(Path.class)).orElse(null);
OMap param = paramMap.getMap(PATH + "."
+ name, true).a("name", name).a("in", PATH);
pt.getAnnotations(Schema.class).forEach(x -> merge(param, x));
pt.getAnnotations(Path.class).forEach(x
-> merge(param, x.schema()));
@@ -468,9 +448,7 @@ public class BasicSwaggerProviderSession {
if (mpi.hasAnnotation(ResponseHeader.class) ||
pt.hasAnnotation(ResponseHeader.class)) {
List<ResponseHeader> la =
AList.of(mpi.getAnnotations(ResponseHeader.class)).a(pt.getAnnotations(ResponseHeader.class));
Set<Integer> codes = getCodes2(la, 200);
- String name = null;
- for (ResponseHeader a : la)
- name = firstNonEmpty(a.name(),
a.n(), a.value(), name);
+ String name =
ResponseHeaderAnnotation.findName(la).orElse(null);
Type type =
Value.unwrap(mpi.getParameterType().innerType());
for (ResponseHeader a : la) {
if (! isMulti(a)) {
@@ -1025,8 +1003,8 @@ public class BasicSwaggerProviderSession {
if (! SchemaAnnotation.empty(a.schema()))
merge(om, a.schema());
return om
- .appendSkipEmpty("example", resolve(a.example(),
a.ex()))
- .appendSkipEmpty("examples", parseMap(a.examples()),
parseMap(a.exs()))
+ .appendSkipEmpty("example", resolve(a.example()))
+ .appendSkipEmpty("examples", parseMap(a.examples()))
.appendSkipEmpty("headers", merge(om.getMap("headers"),
a.headers()))
.appendSkipEmpty("schema", merge(om.getMap("schema"),
a.schema()))
;
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestOpContext.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestOpContext.java
index 59bde37..a38c953 100644
---
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestOpContext.java
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestOpContext.java
@@ -1645,7 +1645,7 @@ public class RestOpContext extends Context implements
Comparable<RestOpContext>
Header h = (Header)a;
if (def != null) {
try {
-
defaultRequestHeaders().set(basicHeader(firstNonEmpty(h.name(), h.n(),
h.value()), parseAnything(def)));
+
defaultRequestHeaders().set(basicHeader(firstNonEmpty(h.name(), h.value()),
parseAnything(def)));
} catch (ParseException
e) {
throw new
ConfigException(e, "Malformed @Header annotation");
}
@@ -1655,7 +1655,7 @@ public class RestOpContext extends Context implements
Comparable<RestOpContext>
Query h = (Query)a;
if (def != null) {
try {
-
defaultRequestQueryData().setDefault(basicPart(firstNonEmpty(h.name(), h.n(),
h.value()), parseAnything(def)));
+
defaultRequestQueryData().setDefault(basicPart(firstNonEmpty(h.name(),
h.value()), parseAnything(def)));
} catch (ParseException
e) {
throw new
ConfigException(e, "Malformed @Query annotation");
}
@@ -1665,7 +1665,7 @@ public class RestOpContext extends Context implements
Comparable<RestOpContext>
FormData h = (FormData)a;
if (def != null) {
try {
-
defaultRequestFormData().setDefault(basicPart(firstNonEmpty(h.name(), h.n(),
h.value()), parseAnything(def)));
+
defaultRequestFormData().setDefault(basicPart(firstNonEmpty(h.name(),
h.value()), parseAnything(def)));
} catch (ParseException
e) {
throw new
ConfigException(e, "Malformed @FormData annotation");
}
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/args/FormDataArg.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/args/FormDataArg.java
index 332768d..f01b173 100644
---
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/args/FormDataArg.java
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/args/FormDataArg.java
@@ -14,6 +14,7 @@ package org.apache.juneau.rest.args;
import static java.util.Optional.*;
import static org.apache.juneau.internal.StringUtils.*;
+import static org.apache.juneau.http.annotation.FormDataAnnotation.*;
import java.util.*;
@@ -65,29 +66,20 @@ public class FormDataArg implements RestOpArg {
/**
* Constructor.
*
- * @param paramInfo The Java method parameter being resolved.
+ * @param pi The Java method parameter being resolved.
* @param annotations The annotations to apply to any new part parsers.
*/
- protected FormDataArg(ParamInfo paramInfo, AnnotationWorkList
annotations) {
- this.name = getName(paramInfo);
- this.type = paramInfo.getParameterType();
- this.schema = HttpPartSchema.create(FormData.class, paramInfo);
+ protected FormDataArg(ParamInfo pi, AnnotationWorkList annotations) {
+ ClassInfo pt = pi.getParameterType();
+
+ this.name = findName(pi.getAnnotations(FormData.class),
pt.getAnnotations(FormData.class)).orElseThrow(()->new ArgException(pi,
"@FormData used without name or value"));
+ this.type = pi.getParameterType();
+ this.schema = HttpPartSchema.create(FormData.class, pi);
this.partParser = ofNullable(schema.getParser()).map(x ->
HttpPartParser.creator().type(x).apply(annotations).create()).orElse(null);
- this.multi = getMulti(paramInfo) ||
schema.getCollectionFormat() == HttpPartCollectionFormat.MULTI;
+ this.multi = getMulti(pi) || schema.getCollectionFormat() ==
HttpPartCollectionFormat.MULTI;
if (multi && ! type.isCollectionOrArray())
- throw new ArgException(paramInfo, "Use of multipart
flag on @FormData parameter that is not an array or Collection");
- }
-
- private String getName(ParamInfo paramInfo) {
- String n = null;
- for (FormData h : paramInfo.getAnnotations(FormData.class))
- n = firstNonEmpty(h.name(), h.n(), h.value(), n);
- for (FormData h :
paramInfo.getParameterType().getAnnotations(FormData.class))
- n = firstNonEmpty(h.name(), h.n(), h.value(), n);
- if (n == null)
- throw new ArgException(paramInfo, "@FormData used
without name or value");
- return n;
+ throw new ArgException(pi, "Use of multipart flag on
@FormData parameter that is not an array or Collection");
}
private boolean getMulti(ParamInfo paramInfo) {
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/args/HasFormDataArg.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/args/HasFormDataArg.java
index c4c6a0f..a8c5a5a 100644
---
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/args/HasFormDataArg.java
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/args/HasFormDataArg.java
@@ -12,7 +12,7 @@
//
***************************************************************************************************************************
package org.apache.juneau.rest.args;
-import static org.apache.juneau.internal.StringUtils.*;
+import static org.apache.juneau.http.annotation.HasFormDataAnnotation.*;
import java.lang.reflect.*;
@@ -57,20 +57,11 @@ public class HasFormDataArg implements RestOpArg {
/**
* Constructor.
*
- * @param paramInfo The Java method parameter being resolved.
+ * @param pi The Java method parameter being resolved.
*/
- protected HasFormDataArg(ParamInfo paramInfo) {
- this.name = getName(paramInfo);
- this.type = paramInfo.getParameterType().innerType();
- }
-
- private String getName(ParamInfo paramInfo) {
- String n = null;
- for (HasFormData h :
paramInfo.getAnnotations(HasFormData.class))
- n = firstNonEmpty(h.name(), h.n(), h.value(), n);
- if (n == null)
- throw new ArgException(paramInfo, "@HasFormData used
without name or value");
- return n;
+ protected HasFormDataArg(ParamInfo pi) {
+ this.name =
findName(pi.getAnnotations(HasFormData.class)).orElseThrow(() -> new
ArgException(pi, "@HasFormData used without name or value"));
+ this.type = pi.getParameterType().innerType();
}
@Override /* RestOpArg */
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/args/HasQueryArg.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/args/HasQueryArg.java
index 74e8957..66b7392 100644
---
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/args/HasQueryArg.java
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/args/HasQueryArg.java
@@ -12,7 +12,7 @@
//
***************************************************************************************************************************
package org.apache.juneau.rest.args;
-import static org.apache.juneau.internal.StringUtils.*;
+import static org.apache.juneau.http.annotation.HasQueryAnnotation.*;
import java.lang.reflect.*;
@@ -57,20 +57,11 @@ public class HasQueryArg implements RestOpArg {
/**
* Constructor.
*
- * @param paramInfo The Java method parameter being resolved.
+ * @param pi The Java method parameter being resolved.
*/
- protected HasQueryArg(ParamInfo paramInfo) {
- this.name = getName(paramInfo);
- this.type = paramInfo.getParameterType().innerType();
- }
-
- private String getName(ParamInfo paramInfo) {
- String n = null;
- for (HasQuery h : paramInfo.getAnnotations(HasQuery.class))
- n = firstNonEmpty(h.name(), h.n(), h.value(), n);
- if (n == null)
- throw new ArgException(paramInfo, "@HasQuery used
without name or value");
- return n;
+ protected HasQueryArg(ParamInfo pi) {
+ this.name =
findName(pi.getAnnotations(HasQuery.class)).orElseThrow(() -> new
ArgException(pi, "@HasQuery used without name or value"));
+ this.type = pi.getParameterType().innerType();
}
@Override /* RestOpArg */
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/args/HeaderArg.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/args/HeaderArg.java
index 3a8dc3a..8b2c875 100644
---
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/args/HeaderArg.java
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/args/HeaderArg.java
@@ -14,6 +14,7 @@ package org.apache.juneau.rest.args;
import static org.apache.juneau.internal.StringUtils.*;
import static java.util.Optional.*;
+import static org.apache.juneau.http.annotation.HeaderAnnotation.*;
import java.util.*;
@@ -109,29 +110,20 @@ public class HeaderArg implements RestOpArg {
/**
* Constructor.
*
- * @param paramInfo The Java method parameter being resolved.
+ * @param pi The Java method parameter being resolved.
* @param annotations The annotations to apply to any new part parsers.
*/
- protected HeaderArg(ParamInfo paramInfo, AnnotationWorkList
annotations) {
- this.name = getName(paramInfo);
- this.type = paramInfo.getParameterType();
- this.schema = HttpPartSchema.create(Header.class, paramInfo);
+ protected HeaderArg(ParamInfo pi, AnnotationWorkList annotations) {
+ ClassInfo pt = pi.getParameterType();
+
+ this.name = findName(pi.getAnnotations(Header.class),
pt.getAnnotations(Header.class)).orElseThrow(() -> new ArgException(pi,
"@Header used without name or value"));
+ this.type = pi.getParameterType();
+ this.schema = HttpPartSchema.create(Header.class, pi);
this.partParser = ofNullable(schema.getParser()).map(x ->
HttpPartParser.creator().type(x).apply(annotations).create()).orElse(null);
- this.multi = getMulti(paramInfo);
+ this.multi = getMulti(pi);
if (multi && ! type.isCollectionOrArray())
- throw new ArgException(paramInfo, "Use of multipart
flag on @Header parameter that is not an array or Collection");
- }
-
- private String getName(ParamInfo paramInfo) {
- String n = null;
- for (Header h : paramInfo.getAnnotations(Header.class))
- n = firstNonEmpty(h.name(), h.n(), h.value(), n);
- for (Header h :
paramInfo.getParameterType().getAnnotations(Header.class))
- n = firstNonEmpty(h.name(), h.n(), h.value(), n);
- if (n == null)
- throw new ArgException(paramInfo, "@Header used without
name or value");
- return n;
+ throw new ArgException(pi, "Use of multipart flag on
@Header parameter that is not an array or Collection");
}
private boolean getMulti(ParamInfo paramInfo) {
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/args/PathArg.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/args/PathArg.java
index 946c520..2319014 100644
---
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/args/PathArg.java
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/args/PathArg.java
@@ -13,7 +13,7 @@
package org.apache.juneau.rest.args;
import static java.util.Optional.*;
-import static org.apache.juneau.internal.StringUtils.*;
+import static org.apache.juneau.http.annotation.PathAnnotation.*;
import java.lang.reflect.*;
@@ -77,18 +77,15 @@ public class PathArg implements RestOpArg {
this.partParser = ofNullable(schema.getParser()).map(x ->
HttpPartParser.creator().type(x).apply(annotations).create()).orElse(null);
}
- private String getName(ParamInfo paramInfo, UrlPathMatcher pathMatcher)
{
- String p = null;
- for (Path h : paramInfo.getAnnotations(Path.class))
- p = firstNonEmpty(h.name(), h.n(), h.value(), p);
- for (Path h :
paramInfo.getParameterType().getAnnotations(Path.class))
- p = firstNonEmpty(h.name(), h.n(), h.value(), p);
+ private String getName(ParamInfo pi, UrlPathMatcher pathMatcher) {
+ ClassInfo pt = pi.getParameterType();
+ String p = findName(pi.getAnnotations(Path.class),
pt.getAnnotations(Path.class)).orElse(null);
if (p != null)
return p;
if (pathMatcher != null) {
int idx = 0;
- int i = paramInfo.getIndex();
- MethodInfo mi = paramInfo.getMethod();
+ int i = pi.getIndex();
+ MethodInfo mi = pi.getMethod();
for (int j = 0; j < i; j++)
if
(mi.getParam(i).getLastAnnotation(Path.class) != null)
@@ -96,7 +93,7 @@ public class PathArg implements RestOpArg {
String[] vars = pathMatcher.getVars();
if (vars.length <= idx)
- throw new ArgException(paramInfo, "Number of
attribute parameters exceeds the number of URL pattern variables");
+ throw new ArgException(pi, "Number of attribute
parameters exceeds the number of URL pattern variables");
// Check for {#} variables.
String idxs = String.valueOf(idx);
@@ -106,7 +103,7 @@ public class PathArg implements RestOpArg {
return pathMatcher.getVars()[idx];
}
- throw new ArgException(paramInfo, "@Path used without name or
value");
+ throw new ArgException(pi, "@Path used without name or value");
}
@Override /* RestOpArg */
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/args/QueryArg.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/args/QueryArg.java
index 0fe8fba..f35f3a3 100644
---
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/args/QueryArg.java
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/args/QueryArg.java
@@ -65,29 +65,20 @@ public class QueryArg implements RestOpArg {
/**
* Constructor.
*
- * @param paramInfo The Java method parameter being resolved.
+ * @param pi The Java method parameter being resolved.
* @param annotations The annotations to apply to any new part parsers.
*/
- protected QueryArg(ParamInfo paramInfo, AnnotationWorkList annotations)
{
- this.name = getName(paramInfo);
- this.type = paramInfo.getParameterType();
- this.schema = HttpPartSchema.create(Query.class, paramInfo);
+ protected QueryArg(ParamInfo pi, AnnotationWorkList annotations) {
+ ClassInfo pt = pi.getParameterType();
+
+ this.name =
QueryAnnotation.findName(pi.getAnnotations(Query.class),
pt.getAnnotations(Query.class)).orElseThrow(() -> new ArgException(pi, "@Query
used without name or value"));
+ this.type = pi.getParameterType();
+ this.schema = HttpPartSchema.create(Query.class, pi);
this.partParser = ofNullable(schema.getParser()).map(x ->
HttpPartParser.creator().type(x).apply(annotations).create()).orElse(null);
- this.multi = getMulti(paramInfo) ||
schema.getCollectionFormat() == HttpPartCollectionFormat.MULTI;
+ this.multi = getMulti(pi) || schema.getCollectionFormat() ==
HttpPartCollectionFormat.MULTI;
if (multi && ! type.isCollectionOrArray())
- throw new ArgException(paramInfo, "Use of multipart
flag on @Query parameter that is not an array or Collection");
- }
-
- private String getName(ParamInfo paramInfo) {
- String n = null;
- for (Query h : paramInfo.getAnnotations(Query.class))
- n = firstNonEmpty(h.name(), h.n(), h.value(), n);
- for (Query h :
paramInfo.getParameterType().getAnnotations(Query.class))
- n = firstNonEmpty(h.name(), h.n(), h.value(), n);
- if (n == null)
- throw new ArgException(paramInfo, "@Query used without
name or value");
- return n;
+ throw new ArgException(pi, "Use of multipart flag on
@Query parameter that is not an array or Collection");
}
private boolean getMulti(ParamInfo paramInfo) {
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/args/ResponseHeaderArg.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/args/ResponseHeaderArg.java
index bdde9be..81c8edb 100644
---
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/args/ResponseHeaderArg.java
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/args/ResponseHeaderArg.java
@@ -13,7 +13,7 @@
package org.apache.juneau.rest.args;
import static java.util.Optional.*;
-import static org.apache.juneau.internal.StringUtils.*;
+import static org.apache.juneau.http.annotation.ResponseHeaderAnnotation.*;
import java.lang.reflect.*;
@@ -57,29 +57,20 @@ public class ResponseHeaderArg implements RestOpArg {
/**
* Constructor.
*
- * @param paramInfo The Java method parameter being resolved.
+ * @param pi The Java method parameter being resolved.
* @param annotations The annotations to apply to any new part parsers.
*/
- protected ResponseHeaderArg(ParamInfo paramInfo, AnnotationWorkList
annotations) {
- this.name = getName(paramInfo);
- this.type = paramInfo.getParameterType().innerType();
- HttpPartSchema schema =
HttpPartSchema.create(ResponseHeader.class, paramInfo);
+ protected ResponseHeaderArg(ParamInfo pi, AnnotationWorkList
annotations) {
+ ClassInfo pt = pi.getParameterType();
+
+ this.name = findName(pi.getAnnotations(ResponseHeader.class),
pt.getAnnotations(ResponseHeader.class)).orElseThrow(() -> new ArgException(pi,
"@ResponseHeader used without name or value"));
+ this.type = pi.getParameterType().innerType();
+ HttpPartSchema schema =
HttpPartSchema.create(ResponseHeader.class, pi);
this.meta = new ResponsePartMeta(HttpPartType.HEADER, schema,
ofNullable(schema.getSerializer()).map(x ->
HttpPartSerializer.creator().type(x).apply(annotations).create()).orElse(null));
Class<?> c = type instanceof Class ? (Class<?>)type : type
instanceof ParameterizedType ? (Class<?>)((ParameterizedType)type).getRawType()
: null;
if (c != Value.class)
- throw new ArgException(paramInfo, "Type must be
Value<?> on parameter annotated with @ResponseHeader annotation");
- }
-
- private static String getName(ParamInfo paramInfo) {
- String n = null;
- for (ResponseHeader h :
paramInfo.getAnnotations(ResponseHeader.class))
- n = firstNonEmpty(h.name(), h.n(), h.value(), n);
- for (ResponseHeader h :
paramInfo.getParameterType().getAnnotations(ResponseHeader.class))
- n = firstNonEmpty(h.name(), h.n(), h.value(), n);
- if (n == null)
- throw new ArgException(paramInfo, "@ResponseHeader used
without name or value");
- return n;
+ throw new ArgException(pi, "Type must be Value<?> on
parameter annotated with @ResponseHeader annotation");
}
@SuppressWarnings({ "unchecked", "rawtypes" })
diff --git
a/juneau-utest/src/test/java/org/apache/juneau/http/annotation/AnnotationUtils_Test.java
b/juneau-utest/src/test/java/org/apache/juneau/http/annotation/AnnotationUtils_Test.java
index 194bf01..1cff11f 100644
---
a/juneau-utest/src/test/java/org/apache/juneau/http/annotation/AnnotationUtils_Test.java
+++
b/juneau-utest/src/test/java/org/apache/juneau/http/annotation/AnnotationUtils_Test.java
@@ -93,7 +93,6 @@ public class AnnotationUtils_Test {
assertTrue(FormDataAnnotation.empty(formData().build()));
assertFalse(FormDataAnnotation.empty(formData().multi(true).build()));
-
assertFalse(FormDataAnnotation.empty(formData().n("foo").build()));
assertFalse(FormDataAnnotation.empty(formData().name("foo").build()));
assertFalse(FormDataAnnotation.empty(formData().parser(OpenApiParser.class).build()));
assertFalse(FormDataAnnotation.empty(formData().serializer(OpenApiSerializer.class).build()));
@@ -104,7 +103,6 @@ public class AnnotationUtils_Test {
public void a04_HasFormData() throws Exception {
assertObject(hasFormData().build().annotationType()).asJson().contains("HasFormData");
-
assertObject(hasFormData().n("foo").build().n()).asJson().is("'foo'");
assertObject(hasFormData().name("foo").build().name()).asJson().is("'foo'");
assertObject(hasFormData().value("foo").build().value()).asJson().is("'foo'");
}
@@ -122,7 +120,6 @@ public class AnnotationUtils_Test {
assertTrue(QueryAnnotation.empty(query().build()));
assertFalse(QueryAnnotation.empty(query().multi(true).build()));
- assertFalse(QueryAnnotation.empty(query().n("foo").build()));
assertFalse(QueryAnnotation.empty(query().name("foo").build()));
assertFalse(QueryAnnotation.empty(query().parser(OpenApiParser.class).build()));
assertFalse(QueryAnnotation.empty(query().serializer(OpenApiSerializer.class).build()));
@@ -133,7 +130,6 @@ public class AnnotationUtils_Test {
public void a06_HasQuery() throws Exception {
assertObject(hasQuery().build().annotationType()).asJson().contains("HasQuery");
-
assertObject(hasQuery().n("foo").build().n()).asJson().is("'foo'");
assertObject(hasQuery().name("foo").build().name()).asJson().is("'foo'");
assertObject(hasQuery().value("foo").build().value()).asJson().is("'foo'");
}
@@ -151,7 +147,6 @@ public class AnnotationUtils_Test {
assertTrue(HeaderAnnotation.empty(header().build()));
assertFalse(HeaderAnnotation.empty(header().multi(true).build()));
- assertFalse(HeaderAnnotation.empty(header().n("foo").build()));
assertFalse(HeaderAnnotation.empty(header().name("foo").build()));
assertFalse(HeaderAnnotation.empty(header().parser(OpenApiParser.class).build()));
assertFalse(HeaderAnnotation.empty(header().serializer(OpenApiSerializer.class).build()));
@@ -184,7 +179,6 @@ public class AnnotationUtils_Test {
assertTrue(PathAnnotation.empty((Path)null));
assertTrue(PathAnnotation.empty(path().build()));
- assertFalse(PathAnnotation.empty(path().n("foo").build()));
assertFalse(PathAnnotation.empty(path().name("foo").build()));
assertFalse(PathAnnotation.empty(path().parser(OpenApiParser.class).build()));
assertFalse(PathAnnotation.empty(path().serializer(OpenApiSerializer.class).build()));
@@ -209,10 +203,8 @@ public class AnnotationUtils_Test {
assertTrue(ResponseAnnotation.empty((Response)null));
assertFalse(ResponseAnnotation.empty(response().code(a(0)).build()));
-
assertFalse(ResponseAnnotation.empty(response().ex(a("foo")).build()));
assertFalse(ResponseAnnotation.empty(response().example(a("foo")).build()));
assertFalse(ResponseAnnotation.empty(response().examples(a("foo")).build()));
-
assertFalse(ResponseAnnotation.empty(response().exs(a("foo")).build()));
assertFalse(ResponseAnnotation.empty(response().headers(new
ResponseHeader[]{responseHeader().name("foo").build()}).build()));
assertFalse(ResponseAnnotation.empty(response().parser(OpenApiParser.class).build()));
assertFalse(ResponseAnnotation.empty(response().schema(schema().$ref("foo").build()).build()));
@@ -233,7 +225,6 @@ public class AnnotationUtils_Test {
assertTrue(ResponseHeaderAnnotation.empty(A2.class.getAnnotation(ResponseHeader.class)));
assertFalse(ResponseHeaderAnnotation.empty(responseHeader().code(a(0)).build()));
-
assertFalse(ResponseHeaderAnnotation.empty(responseHeader().n("foo").build()));
assertFalse(ResponseHeaderAnnotation.empty(responseHeader().name("foo").build()));
assertFalse(ResponseHeaderAnnotation.empty(responseHeader().serializer(OpenApiSerializer.class).build()));
assertFalse(ResponseHeaderAnnotation.empty(responseHeader().value("foo").build()));
diff --git
a/juneau-utest/src/test/java/org/apache/juneau/http/annotation/FormDataAnnotation_Test.java
b/juneau-utest/src/test/java/org/apache/juneau/http/annotation/FormDataAnnotation_Test.java
index 149e353..58b3b34 100644
---
a/juneau-utest/src/test/java/org/apache/juneau/http/annotation/FormDataAnnotation_Test.java
+++
b/juneau-utest/src/test/java/org/apache/juneau/http/annotation/FormDataAnnotation_Test.java
@@ -33,7 +33,6 @@ public class FormDataAnnotation_Test {
FormData a1 = FormDataAnnotation.create()
.multi(true)
- .n("n")
.name("name")
.on("on")
.onClass(X1.class)
@@ -44,7 +43,6 @@ public class FormDataAnnotation_Test {
FormData a2 = FormDataAnnotation.create()
.multi(true)
- .n("n")
.name("name")
.on("on")
.onClass(X1.class)
@@ -58,7 +56,6 @@ public class FormDataAnnotation_Test {
assertObject(a1).asJson().matches(""
+ "{"
+ "multi:true,"
- + "n:'n',"
+ "name:'name',"
+ "on:['on'],"
+
"onClass:['org.apache.juneau.http.annotation.FormDataAnnotation_Test$X1'],"
@@ -119,7 +116,6 @@ public class FormDataAnnotation_Test {
@FormData(
multi=true,
- n="n",
name="name",
on="on",
onClass=X1.class,
@@ -132,7 +128,6 @@ public class FormDataAnnotation_Test {
@FormData(
multi=true,
- n="n",
name="name",
on="on",
onClass=X1.class,
diff --git
a/juneau-utest/src/test/java/org/apache/juneau/http/annotation/HasFormDataAnnotation_Test.java
b/juneau-utest/src/test/java/org/apache/juneau/http/annotation/HasFormDataAnnotation_Test.java
index dceadc0..dddfe03 100644
---
a/juneau-utest/src/test/java/org/apache/juneau/http/annotation/HasFormDataAnnotation_Test.java
+++
b/juneau-utest/src/test/java/org/apache/juneau/http/annotation/HasFormDataAnnotation_Test.java
@@ -27,13 +27,11 @@ public class HasFormDataAnnotation_Test {
//------------------------------------------------------------------------------------------------------------------
HasFormData a1 = HasFormDataAnnotation.create()
- .n("n")
.name("name")
.value("value")
.build();
HasFormData a2 = HasFormDataAnnotation.create()
- .n("n")
.name("name")
.value("value")
.build();
@@ -42,7 +40,6 @@ public class HasFormDataAnnotation_Test {
public void a01_basic() {
assertObject(a1).asJson().is(""
+ "{"
- + "n:'n',"
+ "name:'name',"
+ "value:'value'"
+ "}"
@@ -65,5 +62,4 @@ public class HasFormDataAnnotation_Test {
BeanContext bc2 = BeanContext.create().annotations(a2).build();
assertTrue(bc1 == bc2);
}
-
}
diff --git
a/juneau-utest/src/test/java/org/apache/juneau/http/annotation/HasQueryAnnotation_Test.java
b/juneau-utest/src/test/java/org/apache/juneau/http/annotation/HasQueryAnnotation_Test.java
index e16f97b..c3ec11c 100644
---
a/juneau-utest/src/test/java/org/apache/juneau/http/annotation/HasQueryAnnotation_Test.java
+++
b/juneau-utest/src/test/java/org/apache/juneau/http/annotation/HasQueryAnnotation_Test.java
@@ -29,13 +29,11 @@ public class HasQueryAnnotation_Test {
//------------------------------------------------------------------------------------------------------------------
HasQuery a1 = HasQueryAnnotation.create()
- .n("n")
.name("name")
.value("value")
.build();
HasQuery a2 = HasQueryAnnotation.create()
- .n("n")
.name("name")
.value("value")
.build();
@@ -44,7 +42,6 @@ public class HasQueryAnnotation_Test {
public void a01_basic() {
assertObject(a1).asJson().is(""
+ "{"
- + "n:'n',"
+ "name:'name',"
+ "value:'value'"
+ "}"
diff --git
a/juneau-utest/src/test/java/org/apache/juneau/http/annotation/HeaderAnnotation_Test.java
b/juneau-utest/src/test/java/org/apache/juneau/http/annotation/HeaderAnnotation_Test.java
index f3a0dd2..4ec5b15 100644
---
a/juneau-utest/src/test/java/org/apache/juneau/http/annotation/HeaderAnnotation_Test.java
+++
b/juneau-utest/src/test/java/org/apache/juneau/http/annotation/HeaderAnnotation_Test.java
@@ -33,7 +33,6 @@ public class HeaderAnnotation_Test {
Header a1 = HeaderAnnotation.create()
.multi(true)
- .n("n")
.name("name")
.on("on")
.onClass(X1.class)
@@ -44,7 +43,6 @@ public class HeaderAnnotation_Test {
Header a2 = HeaderAnnotation.create()
.multi(true)
- .n("n")
.name("name")
.on("on")
.onClass(X1.class)
@@ -58,7 +56,6 @@ public class HeaderAnnotation_Test {
assertObject(a1).asJson().matches(""
+ "{"
+ "multi:true,"
- + "n:'n',"
+ "name:'name',"
+ "on:['on'],"
+ "onClass:['"+CNAME+"$X1'],"
@@ -119,7 +116,6 @@ public class HeaderAnnotation_Test {
@Header(
multi=true,
- n="n",
name="name",
on="on",
onClass=X1.class,
@@ -132,7 +128,6 @@ public class HeaderAnnotation_Test {
@Header(
multi=true,
- n="n",
name="name",
on="on",
onClass=X1.class,
diff --git
a/juneau-utest/src/test/java/org/apache/juneau/http/annotation/PathAnnotation_Test.java
b/juneau-utest/src/test/java/org/apache/juneau/http/annotation/PathAnnotation_Test.java
index ff43b45..c10f03d 100644
---
a/juneau-utest/src/test/java/org/apache/juneau/http/annotation/PathAnnotation_Test.java
+++
b/juneau-utest/src/test/java/org/apache/juneau/http/annotation/PathAnnotation_Test.java
@@ -32,7 +32,6 @@ public class PathAnnotation_Test {
//------------------------------------------------------------------------------------------------------------------
Path a1 = PathAnnotation.create()
- .n("n")
.name("name")
.on("on")
.onClass(X1.class)
@@ -42,7 +41,6 @@ public class PathAnnotation_Test {
.build();
Path a2 = PathAnnotation.create()
- .n("n")
.name("name")
.on("on")
.onClass(X1.class)
@@ -55,7 +53,6 @@ public class PathAnnotation_Test {
public void a01_basic() {
assertObject(a1).asJson().matches(""
+ "{"
- + "n:'n',"
+ "name:'name',"
+ "on:['on'],"
+ "onClass:['"+CNAME+"$X1'],"
@@ -115,7 +112,6 @@ public class PathAnnotation_Test {
//------------------------------------------------------------------------------------------------------------------
@Path(
- n="n",
name="name",
on="on",
onClass=X1.class,
@@ -127,7 +123,6 @@ public class PathAnnotation_Test {
Path d1 = D1.class.getAnnotationsByType(Path.class)[0];
@Path(
- n="n",
name="name",
on="on",
onClass=X1.class,
diff --git
a/juneau-utest/src/test/java/org/apache/juneau/http/annotation/QueryAnnotation_Test.java
b/juneau-utest/src/test/java/org/apache/juneau/http/annotation/QueryAnnotation_Test.java
index 1430072..c2fc24d 100644
---
a/juneau-utest/src/test/java/org/apache/juneau/http/annotation/QueryAnnotation_Test.java
+++
b/juneau-utest/src/test/java/org/apache/juneau/http/annotation/QueryAnnotation_Test.java
@@ -33,7 +33,6 @@ public class QueryAnnotation_Test {
Query a1 = QueryAnnotation.create()
.multi(true)
- .n("n")
.name("name")
.on("on")
.onClass(X1.class)
@@ -44,7 +43,6 @@ public class QueryAnnotation_Test {
Query a2 = QueryAnnotation.create()
.multi(true)
- .n("n")
.name("name")
.on("on")
.onClass(X1.class)
@@ -58,7 +56,6 @@ public class QueryAnnotation_Test {
assertObject(a1).asJson().matches(""
+ "{"
+ "multi:true,"
- + "n:'n',"
+ "name:'name',"
+ "on:['on'],"
+ "onClass:['"+CNAME+"$X1'],"
@@ -119,7 +116,6 @@ public class QueryAnnotation_Test {
@Query(
multi=true,
- n="n",
name="name",
on="on",
onClass=X1.class,
@@ -132,7 +128,6 @@ public class QueryAnnotation_Test {
@Query(
multi=true,
- n="n",
name="name",
on="on",
onClass=X1.class,
diff --git
a/juneau-utest/src/test/java/org/apache/juneau/http/annotation/ResponseAnnotation_Test.java
b/juneau-utest/src/test/java/org/apache/juneau/http/annotation/ResponseAnnotation_Test.java
index 6f91d0c..4cb9d0a 100644
---
a/juneau-utest/src/test/java/org/apache/juneau/http/annotation/ResponseAnnotation_Test.java
+++
b/juneau-utest/src/test/java/org/apache/juneau/http/annotation/ResponseAnnotation_Test.java
@@ -33,10 +33,8 @@ public class ResponseAnnotation_Test {
Response a1 = ResponseAnnotation.create()
.code(1)
- .ex("ex")
.example("example")
.examples("examples")
- .exs("exs")
.headers(ResponseHeaderAnnotation.DEFAULT)
.on("on")
.onClass(X1.class)
@@ -48,10 +46,8 @@ public class ResponseAnnotation_Test {
Response a2 = ResponseAnnotation.create()
.code(1)
- .ex("ex")
.example("example")
.examples("examples")
- .exs("exs")
.headers(ResponseHeaderAnnotation.DEFAULT)
.on("on")
.onClass(X1.class)
@@ -66,10 +62,8 @@ public class ResponseAnnotation_Test {
assertObject(a1).asJson().matches(""
+ "{"
+ "code:[1],"
- + "ex:['ex'],"
+ "example:['example'],"
+ "examples:['examples'],"
- + "exs:['exs'],"
+ "headers:[*],"
+ "on:['on'],"
+ "onClass:['"+CNAME+"$X1'],"
@@ -128,10 +122,8 @@ public class ResponseAnnotation_Test {
@Response(
code=1,
- ex="ex",
example="example",
examples="examples",
- exs="exs",
headers=@ResponseHeader,
on="on",
onClass=X1.class,
@@ -145,10 +137,8 @@ public class ResponseAnnotation_Test {
@Response(
code=1,
- ex="ex",
example="example",
examples="examples",
- exs="exs",
headers=@ResponseHeader,
on="on",
onClass=X1.class,
diff --git
a/juneau-utest/src/test/java/org/apache/juneau/http/annotation/ResponseHeaderAnnotation_Test.java
b/juneau-utest/src/test/java/org/apache/juneau/http/annotation/ResponseHeaderAnnotation_Test.java
index c02dd01..f12a185 100644
---
a/juneau-utest/src/test/java/org/apache/juneau/http/annotation/ResponseHeaderAnnotation_Test.java
+++
b/juneau-utest/src/test/java/org/apache/juneau/http/annotation/ResponseHeaderAnnotation_Test.java
@@ -33,7 +33,6 @@ public class ResponseHeaderAnnotation_Test {
ResponseHeader a1 = ResponseHeaderAnnotation.create()
.code(1)
- .n("n")
.name("name")
.on("on")
.onClass(X1.class)
@@ -43,7 +42,6 @@ public class ResponseHeaderAnnotation_Test {
ResponseHeader a2 = ResponseHeaderAnnotation.create()
.code(1)
- .n("n")
.name("name")
.on("on")
.onClass(X1.class)
@@ -56,7 +54,6 @@ public class ResponseHeaderAnnotation_Test {
assertObject(a1).asJson().matches(""
+ "{"
+ "code:[1],"
- + "n:'n',"
+ "name:'name',"
+ "on:['on'],"
+ "onClass:['"+CNAME+"$X1'],"
@@ -114,7 +111,6 @@ public class ResponseHeaderAnnotation_Test {
@ResponseHeader(
code=1,
- n="n",
name="name",
on="on",
onClass=X1.class,
@@ -126,7 +122,6 @@ public class ResponseHeaderAnnotation_Test {
@ResponseHeader(
code=1,
- n="n",
name="name",
on="on",
onClass=X1.class,
diff --git
a/juneau-utest/src/test/java/org/apache/juneau/http/remote/Remote_FormDataAnnotation_Test.java
b/juneau-utest/src/test/java/org/apache/juneau/http/remote/Remote_FormDataAnnotation_Test.java
index 7e7fd6b..7b3d731 100644
---
a/juneau-utest/src/test/java/org/apache/juneau/http/remote/Remote_FormDataAnnotation_Test.java
+++
b/juneau-utest/src/test/java/org/apache/juneau/http/remote/Remote_FormDataAnnotation_Test.java
@@ -697,7 +697,7 @@ public class Remote_FormDataAnnotation_Test {
@Remote
public static interface J1 {
- @RemoteOp(path="/") String
postX1(@FormData(n="x",serializer=MockWriterSerializer.X.class) String b);
+ @RemoteOp(path="/") String
postX1(@FormData(name="x",serializer=MockWriterSerializer.X.class) String b);
}
@Test
@@ -923,7 +923,7 @@ public class Remote_FormDataAnnotation_Test {
public List<Object> getX1() {
return
AList.of("foo","","true","123","null",true,123,null);
}
- @FormData(n="c",serializer=MockWriterSerializer.X.class)
+ @FormData(name="c",serializer=MockWriterSerializer.X.class)
public List<Object> getX2() {
return
AList.of("foo","","true","123","null",true,123,null);
}
@@ -939,7 +939,7 @@ public class Remote_FormDataAnnotation_Test {
public Object[] getX5() {
return new
Object[]{"foo","","true","123","null",true,123,null};
}
- @FormData(n="g",serializer=MockWriterSerializer.X.class)
+ @FormData(name="g",serializer=MockWriterSerializer.X.class)
public Object[] getX6() {
return new
Object[]{"foo","","true","123","null",true,123,null};
}
diff --git
a/juneau-utest/src/test/java/org/apache/juneau/http/remote/Remote_HeaderAnnotation_Test.java
b/juneau-utest/src/test/java/org/apache/juneau/http/remote/Remote_HeaderAnnotation_Test.java
index 59029e8..ad3591a 100644
---
a/juneau-utest/src/test/java/org/apache/juneau/http/remote/Remote_HeaderAnnotation_Test.java
+++
b/juneau-utest/src/test/java/org/apache/juneau/http/remote/Remote_HeaderAnnotation_Test.java
@@ -660,7 +660,7 @@ public class Remote_HeaderAnnotation_Test {
@Remote
public static interface J1 {
- @RemoteOp(path="/") String
getX1(@Header(n="x",serializer=MockWriterSerializer.X.class) String b);
+ @RemoteOp(path="/") String
getX1(@Header(name="x",serializer=MockWriterSerializer.X.class) String b);
}
@Test
diff --git
a/juneau-utest/src/test/java/org/apache/juneau/http/remote/Remote_PathAnnotation_Test.java
b/juneau-utest/src/test/java/org/apache/juneau/http/remote/Remote_PathAnnotation_Test.java
index 2ff7c2f..593eff8 100644
---
a/juneau-utest/src/test/java/org/apache/juneau/http/remote/Remote_PathAnnotation_Test.java
+++
b/juneau-utest/src/test/java/org/apache/juneau/http/remote/Remote_PathAnnotation_Test.java
@@ -77,7 +77,7 @@ public class Remote_PathAnnotation_Test {
@RemoteOp(path="a/{x}") String getX14(@Path @Schema(f="uon")
Map<String,Bean> b);
@RemoteOp(path="a/{x}") String getX15(@Path("*") PartList b);
@RemoteOp(path="a/{x}") String getX16(@Path PartList b);
- @RemoteOp(path="a/{x}") String
getX17(@Path(n="x",serializer=UonSerializer.class) Map<String,Bean> b);
+ @RemoteOp(path="a/{x}") String
getX17(@Path(name="x",serializer=UonSerializer.class) Map<String,Bean> b);
@RemoteOp(path="a/{x}") String getX18(@Path("*") NameValuePair
b);
@RemoteOp(path="a/{x}") String getX19(@Path NameValuePair b);
@RemoteOp(path="a/{x}") String getX20(@Path NameValuePair[] b);
@@ -569,7 +569,7 @@ public class Remote_PathAnnotation_Test {
@Remote
public static interface H1 {
- @RemoteOp(path="/{x}") String
getX1(@Path(n="x",serializer=MockWriterSerializer.X.class) String b);
+ @RemoteOp(path="/{x}") String
getX1(@Path(name="x",serializer=MockWriterSerializer.X.class) String b);
}
@Test
@@ -735,7 +735,7 @@ public class Remote_PathAnnotation_Test {
public List<Object> getX1() {
return
AList.of("foo","","true","123","null",true,123,null);
}
- @Path(n="c",serializer=MockWriterSerializer.X.class)
+ @Path(name="c",serializer=MockWriterSerializer.X.class)
public List<Object> getX2() {
return
AList.of("foo","","true","123","null",true,123,null);
}
@@ -747,7 +747,7 @@ public class Remote_PathAnnotation_Test {
public Object[] getX5() {
return new
Object[]{"foo","","true","123","null",true,123,null};
}
- @Path(n="g",serializer=MockWriterSerializer.X.class)
+ @Path(name="g",serializer=MockWriterSerializer.X.class)
public Object[] getX6() {
return new
Object[]{"foo","","true","123","null",true,123,null};
}
diff --git
a/juneau-utest/src/test/java/org/apache/juneau/http/remote/Remote_QueryAnnotation_Test.java
b/juneau-utest/src/test/java/org/apache/juneau/http/remote/Remote_QueryAnnotation_Test.java
index ef87538..b416cc8 100644
---
a/juneau-utest/src/test/java/org/apache/juneau/http/remote/Remote_QueryAnnotation_Test.java
+++
b/juneau-utest/src/test/java/org/apache/juneau/http/remote/Remote_QueryAnnotation_Test.java
@@ -679,7 +679,7 @@ public class Remote_QueryAnnotation_Test {
@Remote
public static interface J1 {
- @RemoteOp(path="/") String
getX1(@Query(n="x",serializer=MockWriterSerializer.X.class) String b);
+ @RemoteOp(path="/") String
getX1(@Query(name="x",serializer=MockWriterSerializer.X.class) String b);
}
@Test
@@ -887,7 +887,7 @@ public class Remote_QueryAnnotation_Test {
public List<Object> getX1() {
return
AList.of("foo","","true","123","null",true,123,null);
}
- @Query(n="c",serializer=MockWriterSerializer.X.class)
+ @Query(name="c",serializer=MockWriterSerializer.X.class)
public List<Object> getX2() {
return
AList.of("foo","","true","123","null",true,123,null);
}
@@ -903,7 +903,7 @@ public class Remote_QueryAnnotation_Test {
public Object[] getX5() {
return new
Object[]{"foo","","true","123","null",true,123,null};
}
- @Query(n="g",serializer=MockWriterSerializer.X.class)
+ @Query(name="g",serializer=MockWriterSerializer.X.class)
public Object[] getX6() {
return new
Object[]{"foo","","true","123","null",true,123,null};
}
diff --git
a/juneau-utest/src/test/java/org/apache/juneau/httppart/HttpPartSchema_FormData_Test.java
b/juneau-utest/src/test/java/org/apache/juneau/httppart/HttpPartSchema_FormData_Test.java
index 7d93ae5..0039a0e 100644
---
a/juneau-utest/src/test/java/org/apache/juneau/httppart/HttpPartSchema_FormData_Test.java
+++
b/juneau-utest/src/test/java/org/apache/juneau/httppart/HttpPartSchema_FormData_Test.java
@@ -46,9 +46,7 @@ public class HttpPartSchema_FormData_Test {
assertEquals("x", s.getName());
}
- @FormData(
- n="x"
- )
+ @FormData("x")
@Schema(
t="number",
f="int32",
@@ -99,9 +97,7 @@ public class HttpPartSchema_FormData_Test {
public static class A03 {
public void a(
- @FormData(
- n="x"
- )
+ @FormData("x")
@Schema(
t="number",
f="int32",
@@ -157,9 +153,7 @@ public class HttpPartSchema_FormData_Test {
public static class A04 {
public void a(
- @FormData(
- n="y"
- )
+ @FormData("y")
@Schema(
t="integer",
f="int64",
diff --git
a/juneau-utest/src/test/java/org/apache/juneau/httppart/HttpPartSchema_Header_Test.java
b/juneau-utest/src/test/java/org/apache/juneau/httppart/HttpPartSchema_Header_Test.java
index e8fec46..a739175 100644
---
a/juneau-utest/src/test/java/org/apache/juneau/httppart/HttpPartSchema_Header_Test.java
+++
b/juneau-utest/src/test/java/org/apache/juneau/httppart/HttpPartSchema_Header_Test.java
@@ -48,9 +48,7 @@ public class HttpPartSchema_Header_Test {
assertEquals("x", s.getName());
}
- @Header(
- n="x"
- )
+ @Header("x")
@Schema(
t="number",
f="int32",
@@ -101,9 +99,7 @@ public class HttpPartSchema_Header_Test {
public static class A03 {
public void a(
- @Header(
- n="x"
- )
+ @Header("x")
@Schema(
t="number",
f="int32",
@@ -159,9 +155,7 @@ public class HttpPartSchema_Header_Test {
public static class A04 {
public void a(
- @Header(
- n="y"
- )
+ @Header("y")
@Schema(
t="integer",
f="int64",
diff --git
a/juneau-utest/src/test/java/org/apache/juneau/httppart/HttpPartSchema_Path_Test.java
b/juneau-utest/src/test/java/org/apache/juneau/httppart/HttpPartSchema_Path_Test.java
index 1650836..40d4d04 100644
---
a/juneau-utest/src/test/java/org/apache/juneau/httppart/HttpPartSchema_Path_Test.java
+++
b/juneau-utest/src/test/java/org/apache/juneau/httppart/HttpPartSchema_Path_Test.java
@@ -48,9 +48,7 @@ public class HttpPartSchema_Path_Test {
assertEquals("x", s.getName());
}
- @Path(
- n="x"
- )
+ @Path("x")
@Schema(
t="number",
f="int32",
@@ -89,9 +87,7 @@ public class HttpPartSchema_Path_Test {
public static class A03 {
public void a(
- @Path(
- n="x"
- )
+ @Path("x")
@Schema(
t="number",
f="int32",
@@ -135,9 +131,7 @@ public class HttpPartSchema_Path_Test {
public static class A04 {
public void a(
- @Path(
- n="y"
- )
+ @Path("y")
@Schema(
t="integer",
f="int64",
diff --git
a/juneau-utest/src/test/java/org/apache/juneau/httppart/HttpPartSchema_Query_Test.java
b/juneau-utest/src/test/java/org/apache/juneau/httppart/HttpPartSchema_Query_Test.java
index 5a6a255..0d1426a 100644
---
a/juneau-utest/src/test/java/org/apache/juneau/httppart/HttpPartSchema_Query_Test.java
+++
b/juneau-utest/src/test/java/org/apache/juneau/httppart/HttpPartSchema_Query_Test.java
@@ -48,9 +48,7 @@ public class HttpPartSchema_Query_Test {
assertEquals("x", s.getName());
}
- @Query(
- n="x"
- )
+ @Query("x")
@Schema(
t="number",
f="int32",
@@ -101,9 +99,7 @@ public class HttpPartSchema_Query_Test {
public static class A03 {
public void a(
- @Query(
- n="x"
- )
+ @Query("x")
@Schema(
t="number",
f="int32",
@@ -159,9 +155,7 @@ public class HttpPartSchema_Query_Test {
public static class A04 {
public void a(
- @Query(
- n="y"
- )
+ @Query("y")
@Schema(
t="integer",
f="int64",
@@ -215,9 +209,7 @@ public class HttpPartSchema_Query_Test {
assertEquals("c3\nc4", s.getDefault());
}
- @Query(
- n="x"
- )
+ @Query("x")
@Schema(
items=@Items(
t="number",
diff --git
a/juneau-utest/src/test/java/org/apache/juneau/httppart/HttpPartSchema_ResponseHeader_Test.java
b/juneau-utest/src/test/java/org/apache/juneau/httppart/HttpPartSchema_ResponseHeader_Test.java
index 6efd366..d5248e5 100644
---
a/juneau-utest/src/test/java/org/apache/juneau/httppart/HttpPartSchema_ResponseHeader_Test.java
+++
b/juneau-utest/src/test/java/org/apache/juneau/httppart/HttpPartSchema_ResponseHeader_Test.java
@@ -48,9 +48,7 @@ public class HttpPartSchema_ResponseHeader_Test {
assertEquals("x", s.getName());
}
- @ResponseHeader(
- n="x"
- )
+ @ResponseHeader("x")
@Schema(
t="number",
f="int32",
@@ -97,9 +95,7 @@ public class HttpPartSchema_ResponseHeader_Test {
public static class A03 {
public void a(
- @ResponseHeader(
- n="x"
- )
+ @ResponseHeader("x")
@Schema(
t="number",
f="int32",
@@ -151,9 +147,7 @@ public class HttpPartSchema_ResponseHeader_Test {
public static class A04 {
public void a(
- @ResponseHeader(
- n="y"
- )
+ @ResponseHeader("y")
@Schema(
t="integer",
f="int64",
diff --git
a/juneau-utest/src/test/java/org/apache/juneau/rest/annotation/Query_Test.java
b/juneau-utest/src/test/java/org/apache/juneau/rest/annotation/Query_Test.java
index a0555ef..8336ec4 100644
---
a/juneau-utest/src/test/java/org/apache/juneau/rest/annotation/Query_Test.java
+++
b/juneau-utest/src/test/java/org/apache/juneau/rest/annotation/Query_Test.java
@@ -133,27 +133,27 @@ public class Query_Test {
}
@RestGet
- public Object a(@Query(n="x") @Schema(cf="multi") String[] x) {
+ public Object a(@Query("x") @Schema(cf="multi") String[] x) {
return x;
}
@RestGet
- public Object b(@Query(n="x") @Schema(cf="multi") int[] x) {
+ public Object b(@Query("x") @Schema(cf="multi") int[] x) {
return x;
}
@RestGet
- public Object c(@Query(n="x") @Schema(cf="multi") List<String>
x) {
+ public Object c(@Query("x") @Schema(cf="multi") List<String> x)
{
return x;
}
@RestGet
- public Object d(@Query(n="x") @Schema(cf="multi") List<Integer>
x) {
+ public Object d(@Query("x") @Schema(cf="multi") List<Integer>
x) {
return x;
}
@RestGet
- public Object e(@Query(n="x")
@Schema(cf="multi",items=@Items(f="uon")) C1[] x) {
+ public Object e(@Query("x")
@Schema(cf="multi",items=@Items(f="uon")) C1[] x) {
return x;
}
@RestGet
- public Object f(@Query(n="x")
@Schema(cf="multi",items=@Items(f="uon")) List<C1> x) {
+ public Object f(@Query("x")
@Schema(cf="multi",items=@Items(f="uon")) List<C1> x) {
return x;
}
}
diff --git
a/juneau-utest/src/test/java/org/apache/juneau/rest/annotation/Swagger_Path_Test.java
b/juneau-utest/src/test/java/org/apache/juneau/rest/annotation/Swagger_Path_Test.java
index e033a93..633c3de 100644
---
a/juneau-utest/src/test/java/org/apache/juneau/rest/annotation/Swagger_Path_Test.java
+++
b/juneau-utest/src/test/java/org/apache/juneau/rest/annotation/Swagger_Path_Test.java
@@ -33,9 +33,7 @@ public class Swagger_Path_Test {
@Rest
public static class A {
- @Path(
- n="P"
- )
+ @Path("P")
@Schema(
d={"a","b"},
e="a,b",
@@ -52,7 +50,7 @@ public class Swagger_Path_Test {
public void a(A1 f) {}
@Path(
- n="P",
+ name="P",
schema=@Schema(description="a\nb",type="string",_enum={"a","b"})
)
public static class A2 {
@@ -66,7 +64,7 @@ public class Swagger_Path_Test {
public void b(A2 f) {}
@Path(
- n="P",
+ name="P",
schema=@Schema(description="b\nc",type="string",_enum={"b","c"})
)
@Schema(
@@ -95,7 +93,7 @@ public class Swagger_Path_Test {
@RestDelete(path="/d/{P}")
public void d(A4 f) {}
- @Path(n="P")
+ @Path("P")
@Schema(e="a,b")
public static class A5 {
@Override
@@ -145,7 +143,7 @@ public class Swagger_Path_Test {
@Rest
public static class B {
- @Path(n="P")
+ @Path(name="P")
public static class B1 {}
@RestGet(path="/a/{P}")
public void a(B1 f) {}
@@ -192,25 +190,30 @@ public class Swagger_Path_Test {
public static class D {
@RestGet(path="/a/{P}")
- public void a(@Path(
- n="P"
- )
- @Schema(d="a", t="string")
- String h) {}
+ public void a(
+ @Path("P")
+ @Schema(d="a", t="string")
+ String h
+ ) {}
@RestPut(path="/b/{P}")
- public void b(@Path(
- n="P",
- schema=@Schema(description="a",type="string")
- ) String h) {}
+ public void b(
+ @Path(
+ name="P",
+ schema=@Schema(description="a",type="string")
+ )
+ String h
+ ) {}
@RestPost(path="/c/{P}")
- public void c(@Path(
- n="P",
- schema=@Schema(description="b",type="string")
- )
- @Schema(d="a", t="string")
- String h) {}
+ public void c(
+ @Path(
+ name="P",
+ schema=@Schema(description="b",type="string")
+ )
+ @Schema(d="a", t="string")
+ String h
+ ) {}
@RestDelete(path="/d/{P}")
public void d(@Path("P") String h) {}
diff --git
a/juneau-utest/src/test/java/org/apache/juneau/rest/annotation/Swagger_Query_Test.java
b/juneau-utest/src/test/java/org/apache/juneau/rest/annotation/Swagger_Query_Test.java
index 426b81f..bb9e958 100644
---
a/juneau-utest/src/test/java/org/apache/juneau/rest/annotation/Swagger_Query_Test.java
+++
b/juneau-utest/src/test/java/org/apache/juneau/rest/annotation/Swagger_Query_Test.java
@@ -33,9 +33,7 @@ public class Swagger_Query_Test {
@Rest
public static class A {
- @Query(
- n="Q"
- )
+ @Query("Q")
@Schema(d= {"a","b"}, t="string")
public static class A1 {
public A1(String x) {}
@@ -44,7 +42,7 @@ public class Swagger_Query_Test {
public void a(A1 q) {}
@Query(
- n="Q",
+ name="Q",
schema=@Schema(description="a\nb",type="string")
)
public static class A2 {
@@ -54,7 +52,7 @@ public class Swagger_Query_Test {
public void b(A2 q) {}
@Query(
- n="Q",
+ name="Q",
schema=@Schema(description="b\nc",type="string")
)
@Schema(d={"a","b"}, t="string")
@@ -97,7 +95,7 @@ public class Swagger_Query_Test {
@Rest
public static class B {
- @Query(n="Q")
+ @Query(name="Q")
public static class B1 {}
@RestGet
public void a(B1 q) {}
@@ -145,28 +143,29 @@ public class Swagger_Query_Test {
@RestGet
public void a(
- @Query(
- n="Q"
- )
+ @Query("Q")
@Schema(d= {"a","b"}, t="string")
- String q) {}
+ String q
+ ) {}
@RestPut
public void b(
@Query(
- n="Q",
+ name="Q",
schema=@Schema(description="a\nb",type="string")
)
- String q) {}
+ String q
+ ) {}
@RestPost
public void c(
@Query(
- n="Q",
+ name="Q",
schema=@Schema(description="b\nc",type="string")
)
@Schema(d= {"a","b"}, t="string")
- String q) {}
+ String q
+ ) {}
@RestDelete
public void d(@Query("Q") String q) {}