You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@juneau.apache.org by ja...@apache.org on 2018/08/18 19:27:03 UTC
[juneau] branch master updated: Javadocs and minor fixes.
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 f51128c Javadocs and minor fixes.
f51128c is described below
commit f51128c87f33e598155dec0a1fd6b3af43b23199
Author: JamesBognar <ja...@apache.org>
AuthorDate: Sat Aug 18 15:26:48 2018 -0400
Javadocs and minor fixes.
---
.../juneau/http/annotation/AnnotationUtils.java | 13 +
.../apache/juneau/http/annotation/FormData.java | 1 +
.../org/apache/juneau/http/annotation/Header.java | 90 -------
.../org/apache/juneau/http/annotation/Path.java | 89 -------
.../juneau/httppart/HttpPartSchemaBuilder.java | 2 +
.../apache/juneau/doc/internal/DocGenerator.java | 6 +-
juneau-doc/src/main/javadoc/overview.html | 273 ++++++++++++++++++---
.../01.RestProxies/02.RemoteMethod.html | 28 ++-
.../01.RestProxies/03.Body.html | 18 +-
.../01.RestProxies/04.FormData.html | 9 +-
.../01.RestProxies/05.Query.html | 8 +-
.../01.RestProxies/06.Header.html | 61 ++++-
.../01.RestProxies/07.Path.html | 54 +++-
.../01.RestProxies/08.Request.html | 91 +++++++
.../org/apache/juneau/rest/client/RestCall.java | 10 +-
.../client/remote/RemoteMethodAnnotationTest.java | 86 ++++++-
.../rest/annotation/ResponseAnnotationTest.java | 22 ++
17 files changed, 605 insertions(+), 256 deletions(-)
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/AnnotationUtils.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/AnnotationUtils.java
index 8fdfcfc..5cc648e 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/AnnotationUtils.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/AnnotationUtils.java
@@ -300,6 +300,19 @@ public class AnnotationUtils {
}
/**
+ * Returns <jk>true</jk> if the part parser should be used on the specified part.
+ *
+ * @param a The annotation to check.
+ * @return <jk>true</jk> if the part parser should be used on the specified part.
+ */
+ public static boolean usePartParser(Response a) {
+ return
+ a.usePartParser()
+ || a.partParser() != HttpPartParser.Null.class
+ || ! empty(a.schema());
+ }
+
+ /**
* Returns <jk>true</jk> if the part serializer should be used on the specified part.
*
* @param a The annotation to check.
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 c9ee6a1..2fca9c0 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
@@ -82,6 +82,7 @@ import org.apache.juneau.jsonschema.*;
* servlet to drain the body content.
*
* <h5 class='topic'>Arguments and argument-types of client-side @RemoteResource-annotated interfaces</h5>
+ *
* Annotation applied to Java method arguments of interface proxies to denote that they are FORM post parameters on the
* request.
*
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 04ee0d1..c79ec2a 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
@@ -71,96 +71,6 @@ import org.apache.juneau.jsonschema.*;
* Annotation applied to Java method arguments of interface proxies to denote that they are serialized as an HTTP
* header value.
*
- * <h5 class='section'>Example:</h5>
- * <p class='bcode w800'>
- * <ja>@RemoteResource</ja>(path=<js>"/myproxy"</js>)
- * <jk>public interface</jk> MyProxy {
- *
- * <jc>// Explicit names specified for HTTP headers.</jc>
- * <jc>// pojo will be converted to UON notation (unless plain-text parts enabled).</jc>
- * <ja>@RemoteMethod</ja>(path=<js>"/mymethod1"</js>)
- * String myProxyMethod1(<ja>@Header</ja>(<js>"Foo"</js>)</ja> String foo,
- * <ja>@Header</ja>(<js>"Bar"</js>)</ja> MyPojo pojo);
- *
- * <jc>// Multiple values pulled from a NameValuePairs object.</jc>
- * <jc>// Same as @Header("*").</jc>
- * <ja>@RemoteMethod</ja>(path=<js>"/mymethod2"</js>)
- * String myProxyMethod2(<ja>@Header</ja> NameValuePairs nameValuePairs);
- *
- * <jc>// Multiple values pulled from a Map.</jc>
- * <jc>// Same as @Header("*").</jc>
- * <ja>@RemoteMethod</ja>(path=<js>"/mymethod3"</js>)
- * String myProxyMethod3(<ja>@Header</ja> Map<String,Object> map);
- *
- * <jc>// Multiple values pulled from a bean.</jc>
- * <jc>// Same as @Header("*").</jc>
- * <ja>@RemoteMethod</ja>(path=<js>"/mymethod4"</js>)
- * String myProxyMethod4(<ja>@Header</ja> MyBean myBean);
- * }
- * </p>
- *
- * <p>
- * Single-part arguments (i.e. those with name != <js>"*"</js>) can be any of the following types:
- * <ul class='spaced-list'>
- * <li>
- * Any serializable POJO - Converted to a string using the {@link HttpPartSerializer} registered with the
- * <code>RestClient</code> or associated via the {@link #serializer()} annotation.
- * </ul>
- *
- * <p>
- * Multi-part arguments (i.e. those with name == <js>"*"</js> or empty) can be any of the following types:
- * <ul class='spaced-list'>
- * <li>
- * <code>NameValuePairs</code> - Serialized as individual headers.
- * <li>
- * <code>Map</code> - Converted to key-value pairs.
- * <br>Values serialized using the registered {@link HttpPartSerializer}.
- * <li>
- * Bean - Converted to key-value pairs.
- * <br>Values serialized using the registered {@link HttpPartSerializer}.
- * </ul>
- *
- * <p>
- * The annotation can also be applied to a bean property field or getter when the argument or argument class is annotated with
- * {@link Request @Request}:
- *
- * <h5 class='section'>Example:</h5>
- * <p class='bcode w800'>
- * <ja>@RemoteResource</ja>(path=<js>"/myproxy"</js>)
- * <jk>public interface</jk> MyProxy {
- *
- * <ja>@RemoteMethod</ja>(path=<js>"/mymethod"</js>)
- * String myProxyMethod(<ja>@Request</ja> MyRequest bean);
- * }
- *
- * <jk>public interface</jk> MyRequest {
- *
- * <jc>// Name explicitly specified.</jc>
- * <ja>@Header</ja>(<js>"Foo"</js>)
- * String getX();
- *
- * <jc>// Name inherited from bean property.</jc>
- * <jc>// Same as @Header("bar")</jc>
- * <ja>@Header</ja>
- * String getBar();
- *
- * <jc>// Multiple values pulled from NameValuePairs object.</jc>
- * <jc>// Same as @Header("*")</jc>
- * <ja>@Header</ja>
- * NameValuePairs getNameValuePairs();
- *
- * <jc>// Multiple values pulled from Map.</jc>
- * <jc>// Same as @Header("*")</jc>
- * <ja>@Header</ja>
- * Map<String,Object> getMap();
- *
- * <jc>// Multiple values pulled from bean.</jc>
- * <jc>// Same as @Header("*")</jc>
- * <ja>@Header</ja>
- * MyBean getBean();
- * }
- * </p>
- *
* <h5 class='section'>See Also:</h5>
* <ul class='doctree'>
* <li class='link'>{@doc juneau-rest-client.RestProxies.Header}
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 be750a9..d9c2c78 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
@@ -67,95 +67,6 @@ import org.apache.juneau.jsonschema.*;
*
* Annotation applied to Java method arguments of interface proxies to denote that they are path variables on the request.
*
- * <h5 class='section'>Example:</h5>
- * <p class='bcode w800'>
- * <ja>@RemoteResource</ja>(path=<js>"/myproxy"</js>)
- * <jk>public interface</jk> MyProxy {
- *
- * <jc>// Explicit names specified for path parameters.</jc>
- * <jc>// pojo will be converted to UON notation (unless plain-text parts enabled).</jc>
- * <ja>@RemoteMethod</ja>(path=<js>"/mymethod1/{foo}/{bar}"</js>)
- * String myProxyMethod1(<ja>@Path</ja>(<js>"foo"</js>)</ja> String foo, <ja>@Path</ja>(<js>"bar"</js>)</ja> MyPojo pojo);
- *
- * <jc>// Multiple values pulled from a NameValuePairs object.</jc>
- * <jc>// Same as @Path("*").</jc>
- * <ja>@RemoteMethod</ja>(path=<js>"/mymethod2/{foo}/{bar}/{baz}"</js>)
- * String myProxyMethod2(<ja>@Path</ja> NameValuePairs nameValuePairs);
- *
- * <jc>// Multiple values pulled from a Map.</jc>
- * <jc>// Same as @Path("*").</jc>
- * <ja>@RemoteMethod</ja>(path=<js>"/mymethod3/{foo}/{bar}/{baz}"</js>)
- * String myProxyMethod3(<ja>@Path</ja> Map<String,Object> map);
- *
- * <jc>// Multiple values pulled from a bean.</jc>
- * <jc>// Same as @Path("*").</jc>
- * <ja>@RemoteMethod</ja>(path=<js>"/mymethod4/{foo}/{bar}/{baz}"</js>)
- * String myProxyMethod4(<ja>@Path</ja> MyBean myBean);
- * }
- * </p>
- *
- * <p>
- * Single-part arguments (i.e. those with name != <js>"*"</js>) can be any of the following types:
- * <ul class='spaced-list'>
- * <li>
- * Any serializable POJO - Converted to a string using the {@link HttpPartSerializer} registered with the
- * <code>RestClient</code> or associated via the {@link #serializer()} annotation.
- * </ul>
- *
- * <p>
- * Multi-part arguments (i.e. those with name == <js>"*"</js> or empty) can be any of the following types:
- * <ul class='spaced-list'>
- * <li>
- * <code>NameValuePairs</code> - Serialized as individual query parameters.
- * <li>
- * <code>Map</code> - Converted to key-value pairs.
- * <br>Values serialized using the registered {@link HttpPartSerializer}.
- * <li>
- * Bean - Converted to key-value pairs.
- * <br>Values serialized using the registered {@link HttpPartSerializer}.
- * </ul>
- *
- * <p>
- * The annotation can also be applied to a bean property field or getter when the argument or argument class is annotated with
- * {@link Request @Request}:
- *
- * <h5 class='section'>Example:</h5>
- * <p class='bcode w800'>
- * <ja>@RemoteResource</ja>(path=<js>"/myproxy"</js>)
- * <jk>public interface</jk> MyProxy {
- *
- * <ja>@RemoteMethod</ja>(path=<js>"/mymethod/{foo}/{bar}/{baz}"</js>)
- * String myProxyMethod(<ja>@Request</ja> MyRequest bean);
- * }
- *
- * <jk>public interface</jk> MyRequest {
- *
- * <jc>// Name explicitly specified.</jc>
- * <ja>@Path</ja>(<js>"foo"</js>)
- * String getX();
- *
- * <jc>// Name inherited from bean property.</jc>
- * <jc>// Same as @Path("bar")</jc>
- * <ja>@Path</ja>
- * String getBar();
- *
- * <jc>// Multiple values pulled from NameValuePairs object.</jc>
- * <jc>// Same as @Path("*")</jc>
- * <ja>@Path</ja>
- * NameValuePairs getNameValuePairs();
- *
- * <jc>// Multiple values pulled from Map.</jc>
- * <jc>// Same as @Path("*")</jc>
- * <ja>@Path</ja>
- * Map<String,Object> getMap();
- *
- * <jc>// Multiple values pulled from bean.</jc>
- * <jc>// Same as @Path("*")</jc>
- * <ja>@Path</ja>
- * MyBean getMyBean();
- * }
- * </p>
- *
* <h5 class='section'>See Also:</h5>
* <ul class='doctree'>
* <li class='link'>{@doc juneau-rest-client.RestProxies.Path}
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/HttpPartSchemaBuilder.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/HttpPartSchemaBuilder.java
index 6e34fb6..3e24cf5 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/HttpPartSchemaBuilder.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/HttpPartSchemaBuilder.java
@@ -275,7 +275,9 @@ public class HttpPartSchemaBuilder {
required(false);
allowEmptyValue(true);
serializer(a.partSerializer());
+ parser(a.partParser());
usePartSerializer(AnnotationUtils.usePartSerializer(a));
+ usePartParser(AnnotationUtils.usePartParser(a));
apply(a.schema());
return this;
}
diff --git a/juneau-doc/src/main/java/org/apache/juneau/doc/internal/DocGenerator.java b/juneau-doc/src/main/java/org/apache/juneau/doc/internal/DocGenerator.java
index f035904..d9cbb09 100644
--- a/juneau-doc/src/main/java/org/apache/juneau/doc/internal/DocGenerator.java
+++ b/juneau-doc/src/main/java/org/apache/juneau/doc/internal/DocGenerator.java
@@ -216,7 +216,11 @@ public class DocGenerator {
tags = title.substring(1, title.indexOf('}'));
title = title.substring(tags.length()+2).trim();
}
- contents = s.substring(i).trim();
+ contents = s.substring(i).trim()
+ .replaceAll("oaj\\.", "org.apache.juneau.")
+ .replaceAll("oajr\\.", "org.apache.juneau.rest.")
+ .replaceAll("oajrc\\.", "org.apache.juneau.rest.client.")
+ ;
} catch (Exception e) {
throw new RuntimeException("Problem with file " + f.getAbsolutePath());
}
diff --git a/juneau-doc/src/main/javadoc/overview.html b/juneau-doc/src/main/javadoc/overview.html
index 3f94217..1394a9c 100644
--- a/juneau-doc/src/main/javadoc/overview.html
+++ b/juneau-doc/src/main/javadoc/overview.html
@@ -372,8 +372,8 @@
<li><p class='new'><a class='doclink' href='#juneau-rest-client.RestProxies.Body'>@Body</a></p>
<li><p class='new'><a class='doclink' href='#juneau-rest-client.RestProxies.FormData'>@FormData</a></p>
<li><p class='new'><a class='doclink' href='#juneau-rest-client.RestProxies.Query'>@Query</a></p>
- <li><p class='todo'><a class='doclink' href='#juneau-rest-client.RestProxies.Header'>@Header</a></p>
- <li><p class='todo'><a class='doclink' href='#juneau-rest-client.RestProxies.Path'>@Path</a></p>
+ <li><p class='new'><a class='doclink' href='#juneau-rest-client.RestProxies.Header'>@Header</a></p>
+ <li><p class='new'><a class='doclink' href='#juneau-rest-client.RestProxies.Path'>@Path</a></p>
<li><p class='todo'><a class='doclink' href='#juneau-rest-client.RestProxies.Request'>@Request</a></p>
<li><p class='todo'><a class='doclink' href='#juneau-rest-client.RestProxies.Response'>@Request</a></p>
</ol>
@@ -19977,7 +19977,7 @@ TODO(7.2.0)
</p>
<p class='bpcode w800'>
<jc>// Create a reusable JSON client.</jc>
- <jk>try</jk> (RestClient client = RestClient.<jsm>create</jsm>().build()) {
+ <jk>try</jk> (RestClient client = RestClient.<jsm>create</jsm>().json().build()) {
<jc>// The address of the root resource.</jc>
String url = <js>"http://localhost:10000/addressBook"</js>;
@@ -20037,7 +20037,7 @@ TODO(7.2.0)
<jc>// Examples below use the Juneau Address Book resource example</jc>
<jc>// Create a reusable client with JSON support</jc>
- <jk>try</jk> (RestClient client = RestClient.<jsm>create</jsm>().build()) {
+ <jk>try</jk> (RestClient client = RestClient.<jsm>create</jsm>().json().build()) {
<jc>// GET request, ignoring output</jc>
<jk>try</jk> {
@@ -20279,7 +20279,7 @@ TODO(7.2.0)
<div class='topic'><!-- START: 9.1.2 - juneau-rest-client.RestProxies.RemoteMethod -->
<p>
The {@link org.apache.juneau.rest.client.remote.RemoteMethod @RemoteMethod} annotation is applied to methods
- of {@link org.apache.juneau.rest.client.remote.RemoteResource @RemoteResource}-annotated interfaces to identify REST endpoints.
+ of <ja>@RemoteResource</ja>-annotated interfaces to identify REST endpoints.
</p>
<ul class='doctree'>
<li class='ja'>{@link org.apache.juneau.rest.client.remote.RemoteMethod}
@@ -20304,12 +20304,12 @@ TODO(7.2.0)
}
</p>
<p>
- The method names can be anything.
+ The Java method name can be anything.
</p>
<h5 class='topic w800'>Inferred method/path</h5>
<p>
- The <code>method</code> and <code>path</code> annotations are optional if you follow certain naming
+ In such cases, <code>method</code> and <code>path</code> annotations are optional if you follow certain naming
conventions on your method that identify the method and path.
</p>
<p>
@@ -20325,6 +20325,9 @@ TODO(7.2.0)
}
</p>
<p>
+ In such cases, the <ja>@RemoteMethod</ja> annotation is optional.
+</p>
+<p>
Method names matching the following pattern are assumed to be implying the HTTP method name:
</p>
<p class='bpcode w800'>
@@ -20380,7 +20383,7 @@ TODO(7.2.0)
<h5 class='topic w800'>@RemoteMethod(returns)</h5>
<p>
- By default, the return type of the Java methods of can be any of the following:
+ The return type of the Java methods of can be any of the following:
</p>
<ul class='spaced-list'>
<li>
@@ -20399,8 +20402,6 @@ TODO(7.2.0)
<li>
{@link java.io.Reader}
- Returns access to the raw reader of the response.
- <br>Note that if you don't want your response parsed as a POJO, you'll want to get the response reader
- directly.
<li>
{@link java.io.InputStream}
- Returns access to the raw input stream of the response.
@@ -20416,11 +20417,31 @@ TODO(7.2.0)
<jk>public interface</jk> PetStore {
<jc>// POST /pets</jc>
- <jc>// Returns HTTP status code.
+ <jc>// Returns HTTP status code.</jc>
<ja>@RemoteMethod</ja>(returns=<jsf>STATUS</jsf>)
<jk>int</jk> postPets(...);
}
</p>
+
+<p>
+ If your <code>RestClient</code> does not have a parser associated with it, then the {@link org.apache.juneau.httppart.OpenApiPartParser OpenAPI part parser}
+ is used to parse the response.
+ <br>If your <code>RestClient</code> does have a parser associated with it, then you can force it to use the part parser using the {@link org.apache.juneau.http.annotation.Response#usePartParser() @Response(usePartParser)}
+ annotation on your method like so:
+</p>
+<p class='bpcode w800'>
+ <ja>@RemoteResource</ja>
+ <jk>public interface</jk> PetStore {
+
+ <jc>// Force the part parser to be used for the response body.</jc>
+ <ja>@RemoteMethod</ja>
+ <ja>@Response</ja>(usePartParser=<jk>true</jk>)
+ String postPets(...);
+ }
+</p>
+<p>
+ The usage of <ja>@Response</ja> is described in detail below.
+</p>
</div><!-- END: 9.1.2 - juneau-rest-client.RestProxies.RemoteMethod -->
<!-- ==================================================================================================== -->
@@ -20469,8 +20490,8 @@ TODO(7.2.0)
</p>
<ul class='spaced-list'>
<li>
- Any serializable POJO - Converted to text using the {@link org.apache.juneau.serializer.Serializer} or {@link org.apache.juneau.httppart.HttpPartSerializer} registered with the
- <code>RestClient</code> or specified on annotation.
+ Any serializable POJO - Converted to output using the {@link org.apache.juneau.serializer.Serializer} or {@link org.apache.juneau.httppart.HttpPartSerializer} registered with the
+ <code>RestClient</code> ({@link org.apache.juneau.httppart.OpenApiPartSerializer} by default) or associated via the {@link org.apache.juneau.http.annotation.Body#partSerializer() @Body(partSerializer)} annotation.
<li>
{@link java.io.Reader} - Raw contents of {@code Reader} will be serialized to remote resource.
<li>
@@ -20482,14 +20503,15 @@ TODO(7.2.0)
</ul>
<p>
- OpenAPI schema based serialization can be used by specifying a value for the {@link org.apache.juneau.http.annotation.Body#partSerializer() @Body(partSerializer)} annotation.
+ OpenAPI schema based serialization can be used by specifying a value for the {@link org.apache.juneau.http.annotation.Body#partSerializer() @Body(partSerializer)} annotation
+ or setting {@link org.apache.juneau.http.annotation.Body#usePartSerializer() @Body(usePartSerializer)} to <jk>true</jk>.
</p>
<p class='bpcode w800'>
<ja>@RemoteMethod</ja>(path=<js>"/comma-delimited-pipe-delimited-ints"</js>)
String addCommaDelimitedPipeDelimitedInts(
<ja>@Body</ja>(
- serializer=OpenApiPartSerializer.<jk>class</jk>,
+ usePartSerializer=<jk>true</jk>,
schema=<ja>@Schema</ja>(
type=<js>"array"</js>,
collectionFormat=<js>"pipes"</js>,
@@ -20507,9 +20529,12 @@ TODO(7.2.0)
<jk>int</jk>[][] input
);
</p>
-
<p>
- When using OpenAPI serialization, the argument can be any data type specified in {@link org.apache.juneau.httppart.OpenApiPartSerializer}.
+ If your <code>RestClient</code> class does not have a serializer associated with it, the body will automatically be serialized using the registered
+ OpenAPI part serializer.
+</p>
+<p>
+ See the link below for information about supported data types in OpenAPI serialization.
</p>
<h5 class='section'>See Also:</h5>
@@ -20595,7 +20620,7 @@ TODO(7.2.0)
<ul class='spaced-list'>
<li>
Any serializable POJO - Converted to a string using the {@link org.apache.juneau.httppart.HttpPartSerializer} registered with the
- <code>RestClient</code> or associated via the {@link org.apache.juneau.http.annotation.FormData#serializer() @FormData(serializer)} annotation.
+ <code>RestClient</code> ({@link org.apache.juneau.httppart.OpenApiPartSerializer} by default) or associated via the {@link org.apache.juneau.http.annotation.FormData#serializer() @FormData(serializer)} annotation.
</ul>
<p>
Multi-part arguments (i.e. those with name == <js>"*"</js> or empty) can be any of the following types:
@@ -20609,16 +20634,15 @@ TODO(7.2.0)
<code>NameValuePairs</code> - Converted to a URL-encoded FORM post.
<li>
<code>Map</code> - Converted to key-value pairs.
- <br>Values serialized using the registered {@link org.apache.juneau.httppart.HttpPartSerializer}.
+ <br>Values serialized using the registered {@link org.apache.juneau.httppart.HttpPartSerializer} ({@link org.apache.juneau.httppart.OpenApiPartSerializer} by default).
<li>
Bean - Converted to key-value pairs.
- <br>Values serialized using the registered {@link org.apache.juneau.httppart.HttpPartSerializer}.
+ <br>Values serialized using the registered {@link org.apache.juneau.httppart.HttpPartSerializer} ({@link org.apache.juneau.httppart.OpenApiPartSerializer} by default).
<li>
<code>CharSequence</code> - Used directly as am <js>"application/x-www-form-urlencoded"</js> entity.
</ul>
-
<p>
- When using OpenAPI serialization, the argument can be any data type specified in {@link org.apache.juneau.httppart.OpenApiPartSerializer}.
+ See the link below for information about supported data types in OpenAPI serialization.
</p>
<h5 class='section'>See Also:</h5>
@@ -20707,7 +20731,7 @@ TODO(7.2.0)
<ul class='spaced-list'>
<li>
Any serializable POJO - Converted to a string using the {@link org.apache.juneau.httppart.HttpPartSerializer} registered with the
- <code>RestClient</code> or associated via the {@link org.apache.juneau.http.annotation.Query#serializer() @Query(serializer)} annotation.
+ <code>RestClient</code> ({@link org.apache.juneau.httppart.OpenApiPartSerializer} by default) or associated via the {@link org.apache.juneau.http.annotation.Query#serializer() @Query(serializer)} annotation.
</ul>
<p>
@@ -20720,16 +20744,16 @@ TODO(7.2.0)
<code>NameValuePairs</code> - Serialized as individual query parameters.
<li>
<code>Map</code> - Converted to key-value pairs.
- <br>Values serialized using the registered {@link org.apache.juneau.httppart.HttpPartSerializer}.
+ <br>Values serialized using the registered {@link org.apache.juneau.httppart.HttpPartSerializer} ({@link org.apache.juneau.httppart.OpenApiPartSerializer} by default).
<li>
Bean - Converted to key-value pairs.
- <br>Values serialized using the registered {@link org.apache.juneau.httppart.HttpPartSerializer}.
+ <br>Values serialized using the registered {@link org.apache.juneau.httppart.HttpPartSerializer} ({@link org.apache.juneau.httppart.OpenApiPartSerializer} by default).
<li>
<code>CharSequence</code> - Serialized directly a query string.
</ul>
<p>
- When using OpenAPI serialization, the argument can be any data type specified in {@link org.apache.juneau.httppart.OpenApiPartSerializer}.
+ See the link below for information about supported data types in OpenAPI serialization.
</p>
<h5 class='section'>See Also:</h5>
@@ -20740,7 +20764,7 @@ TODO(7.2.0)
<!-- ==================================================================================================== -->
-<h4 class='topic todo' onclick='toggle(this)'><a href='#juneau-rest-client.RestProxies.Header' id='juneau-rest-client.RestProxies.Header'>9.1.6 - @Header</a></h4>
+<h4 class='topic new' onclick='toggle(this)'><a href='#juneau-rest-client.RestProxies.Header' id='juneau-rest-client.RestProxies.Header'>9.1.6 - @Header</a></h4>
<div class='topic'><!-- START: 9.1.6 - juneau-rest-client.RestProxies.Header -->
<p>
The {@link org.apache.juneau.http.annotation.Header @Header} annotation can be applied to arguments of <ja>@RemoteMethod</ja>-annotated methods
@@ -20774,22 +20798,59 @@ TODO(7.2.0)
</ul>
</ul>
-{@link org.apache.juneau.http.annotation.Header}
-- A request header.
-<br>The argument can be any of the following types:
-<ul>
- <li class='normal'>Any serializable POJO
- - Converted to text using {@link org.apache.juneau.httppart.SimpleUonPartSerializerSession#serialize(HttpPartType,HttpPartSchema,Object)}.
- <li class='normal'><code>Map<String,Object></code>
- - Individual name-value pairs.
- <br>Values are converted to text using {@link org.apache.juneau.httppart.SimpleUonPartSerializerSession#serialize(HttpPartType,HttpPartSchema,Object)}.
-</ul>
+<h5 class='figure'>Example:</h5>
+<p class='bpcode w800'>
+ <ja>@RemoteResource</ja>(path=<js>"/myproxy"</js>)
+ <jk>public interface</jk> MyProxy {
+
+ <jc>// Explicit names specified for HTTP headers.</jc>
+ <jc>// pojo will be converted to UON notation (unless plain-text parts enabled).</jc>
+ <ja>@RemoteMethod</ja>(path=<js>"/mymethod1"</js>)
+ String myProxyMethod1(<ja>@Header</ja>(<js>"Foo"</js>)</ja> String foo,
+ <ja>@Header</ja>(<js>"Bar"</js>)</ja> MyPojo pojo);
+ <jc>// Multiple values pulled from a NameValuePairs object.</jc>
+ <jc>// Same as @Header("*").</jc>
+ <ja>@RemoteMethod</ja>(path=<js>"/mymethod2"</js>)
+ String myProxyMethod2(<ja>@Header</ja> NameValuePairs nameValuePairs);
+ <jc>// Multiple values pulled from a Map.</jc>
+ <jc>// Same as @Header("*").</jc>
+ <ja>@RemoteMethod</ja>(path=<js>"/mymethod3"</js>)
+ String myProxyMethod3(<ja>@Header</ja> Map<String,Object> map);
+ <jc>// Multiple values pulled from a bean.</jc>
+ <jc>// Same as @Header("*").</jc>
+ <ja>@RemoteMethod</ja>(path=<js>"/mymethod4"</js>)
+ String myProxyMethod4(<ja>@Header</ja> MyBean myBean);
+ }
+</p>
<p>
- When using OpenAPI serialization, the argument can be any data type specified in {@link org.apache.juneau.httppart.OpenApiPartSerializer}.
+ Single-part arguments (i.e. those with name != <js>"*"</js>) can be any of the following types:
+</p>
+<ul class='spaced-list'>
+ <li>
+ Any serializable POJO - Converted to a string using the {@link org.apache.juneau.httppart.HttpPartSerializer} registered with the
+ <code>RestClient</code> ({@link org.apache.juneau.httppart.OpenApiPartSerializer} by default) or associated via the {@link org.apache.juneau.http.annotation.Header#serializer() @Header(serializer)} annotation.
+</ul>
+
+<p>
+ Multi-part arguments (i.e. those with name == <js>"*"</js> or empty) can be any of the following types:
+</p>
+<ul class='spaced-list'>
+ <li>
+ <code>NameValuePairs</code> - Serialized as individual headers.
+ <li>
+ <code>Map</code> - Converted to key-value pairs.
+ <br>Values serialized using the registered {@link org.apache.juneau.httppart.HttpPartSerializer} ({@link org.apache.juneau.httppart.OpenApiPartSerializer} by default).
+ <li>
+ Bean - Converted to key-value pairs.
+ <br>Values serialized using the registered {@link org.apache.juneau.httppart.HttpPartSerializer} ({@link org.apache.juneau.httppart.OpenApiPartSerializer} by default).
+</ul>
+
+<p>
+ See the link below for information about supported data types in OpenAPI serialization.
</p>
<h5 class='section'>See Also:</h5>
@@ -20800,7 +20861,7 @@ TODO(7.2.0)
<!-- ==================================================================================================== -->
-<h4 class='topic todo' onclick='toggle(this)'><a href='#juneau-rest-client.RestProxies.Path' id='juneau-rest-client.RestProxies.Path'>9.1.7 - @Path</a></h4>
+<h4 class='topic new' onclick='toggle(this)'><a href='#juneau-rest-client.RestProxies.Path' id='juneau-rest-client.RestProxies.Path'>9.1.7 - @Path</a></h4>
<div class='topic'><!-- START: 9.1.7 - juneau-rest-client.RestProxies.Path -->
<p>
The {@link org.apache.juneau.http.annotation.Path @Path} annotation can be applied to arguments of <ja>@RemoteMethod</ja>-annotated methods
@@ -20828,8 +20889,58 @@ TODO(7.2.0)
</ul>
</ul>
+<h5 class='figure'>Example:</h5>
+<p class='bpcode w800'>
+ <ja>@RemoteResource</ja>(path=<js>"/myproxy"</js>)
+ <jk>public interface</jk> MyProxy {
+
+ <jc>// Explicit names specified for path parameters.</jc>
+ <jc>// pojo will be converted to UON notation (unless plain-text parts enabled).</jc>
+ <ja>@RemoteMethod</ja>(path=<js>"/mymethod1/{foo}/{bar}"</js>)
+ String myProxyMethod1(<ja>@Path</ja>(<js>"foo"</js>)</ja> String foo, <ja>@Path</ja>(<js>"bar"</js>)</ja> MyPojo pojo);
+
+ <jc>// Multiple values pulled from a NameValuePairs object.</jc>
+ <jc>// Same as @Path("*").</jc>
+ <ja>@RemoteMethod</ja>(path=<js>"/mymethod2/{foo}/{bar}/{baz}"</js>)
+ String myProxyMethod2(<ja>@Path</ja> NameValuePairs nameValuePairs);
+
+ <jc>// Multiple values pulled from a Map.</jc>
+ <jc>// Same as @Path("*").</jc>
+ <ja>@RemoteMethod</ja>(path=<js>"/mymethod3/{foo}/{bar}/{baz}"</js>)
+ String myProxyMethod3(<ja>@Path</ja> Map<String,Object> map);
+
+ <jc>// Multiple values pulled from a bean.</jc>
+ <jc>// Same as @Path("*").</jc>
+ <ja>@RemoteMethod</ja>(path=<js>"/mymethod4/{foo}/{bar}/{baz}"</js>)
+ String myProxyMethod4(<ja>@Path</ja> MyBean myBean);
+ }
+</p>
+
<p>
- When using OpenAPI serialization, the argument can be any data type specified in {@link org.apache.juneau.httppart.OpenApiPartSerializer}.
+ Single-part arguments (i.e. those with name != <js>"*"</js>) can be any of the following types:
+</p>
+<ul class='spaced-list'>
+ <li>
+ Any serializable POJO - Converted to a string using the {@link org.apache.juneau.httppart.HttpPartSerializer} registered with the
+ <code>RestClient</code> ({@link org.apache.juneau.httppart.OpenApiPartSerializer} by default) or associated via the {@link org.apache.juneau.http.annotation.Path#serializer() @Path(serializer)} annotation.
+</ul>
+
+<p>
+ Multi-part arguments (i.e. those with name == <js>"*"</js> or empty) can be any of the following types:
+</p>
+<ul class='spaced-list'>
+ <li>
+ <code>NameValuePairs</code> - Serialized as individual query parameters.
+ <li>
+ <code>Map</code> - Converted to key-value pairs.
+ <br>Values serialized using the registered {@link org.apache.juneau.httppart.HttpPartSerializer} ({@link org.apache.juneau.httppart.OpenApiPartSerializer} by default).
+ <li>
+ Bean - Converted to key-value pairs.
+ <br>Values serialized using the registered {@link org.apache.juneau.httppart.HttpPartSerializer} ({@link org.apache.juneau.httppart.OpenApiPartSerializer} by default).
+</ul>
+
+<p>
+ See the link below for information about supported data types in OpenAPI serialization.
</p>
<h5 class='section'>See Also:</h5>
@@ -20959,6 +21070,88 @@ TODO(7.2.0)
Reader getReader();
}
</p>
+
+<p>
+ The annotation can also be applied to a bean property field or getter when the argument or argument class is annotated with {@link org.apache.juneau.http.annotation.Request @Request}:
+</p>
+
+<h5 class='section'>Example:</h5>
+<p class='bcode w800'>
+ <ja>@RemoteResource</ja>(path=<js>"/myproxy"</js>)
+ <jk>public interface</jk> MyProxy {
+
+ <ja>@RemoteMethod</ja>(path=<js>"/mymethod"</js>)
+ String myProxyMethod(<ja>@Request</ja> MyRequest bean);
+ }
+
+ <jk>public interface</jk> MyRequest {
+
+ <jc>// Name explicitly specified.</jc>
+ <ja>@Header</ja>(<js>"Foo"</js>)
+ String getX();
+
+ <jc>// Name inherited from bean property.</jc>
+ <jc>// Same as @Header("bar")</jc>
+ <ja>@Header</ja>
+ String getBar();
+
+ <jc>// Multiple values pulled from NameValuePairs object.</jc>
+ <jc>// Same as @Header("*")</jc>
+ <ja>@Header</ja>
+ NameValuePairs getNameValuePairs();
+
+ <jc>// Multiple values pulled from Map.</jc>
+ <jc>// Same as @Header("*")</jc>
+ <ja>@Header</ja>
+ Map<String,Object> getMap();
+
+ <jc>// Multiple values pulled from bean.</jc>
+ <jc>// Same as @Header("*")</jc>
+ <ja>@Header</ja>
+ MyBean getBean();
+ }
+</p>
+
+<p>
+ The annotation can also be applied to a bean property field or getter when the argument or argument class is annotated with
+ {@link org.apache.juneau.http.annotation.Request @Request}:
+</p>
+<h5 class='section'>Example:</h5>
+<p class='bcode w800'>
+ <ja>@RemoteResource</ja>(path=<js>"/myproxy"</js>)
+ <jk>public interface</jk> MyProxy {
+
+ <ja>@RemoteMethod</ja>(path=<js>"/mymethod/{foo}/{bar}/{baz}"</js>)
+ String myProxyMethod(<ja>@Request</ja> MyRequest bean);
+ }
+
+ <jk>public interface</jk> MyRequest {
+
+ <jc>// Name explicitly specified.</jc>
+ <ja>@Path</ja>(<js>"foo"</js>)
+ String getX();
+
+ <jc>// Name inherited from bean property.</jc>
+ <jc>// Same as @Path("bar")</jc>
+ <ja>@Path</ja>
+ String getBar();
+
+ <jc>// Multiple values pulled from NameValuePairs object.</jc>
+ <jc>// Same as @Path("*")</jc>
+ <ja>@Path</ja>
+ NameValuePairs getNameValuePairs();
+
+ <jc>// Multiple values pulled from Map.</jc>
+ <jc>// Same as @Path("*")</jc>
+ <ja>@Path</ja>
+ Map<String,Object> getMap();
+
+ <jc>// Multiple values pulled from bean.</jc>
+ <jc>// Same as @Path("*")</jc>
+ <ja>@Path</ja>
+ MyBean getMyBean();
+ }
+</p>
</div><!-- END: 9.1.8 - juneau-rest-client.RestProxies.Request -->
<!-- ==================================================================================================== -->
diff --git a/juneau-doc/src/main/resources/Topics/09.juneau-rest-client/01.RestProxies/02.RemoteMethod.html b/juneau-doc/src/main/resources/Topics/09.juneau-rest-client/01.RestProxies/02.RemoteMethod.html
index ae5ca80..5ad20d8 100644
--- a/juneau-doc/src/main/resources/Topics/09.juneau-rest-client/01.RestProxies/02.RemoteMethod.html
+++ b/juneau-doc/src/main/resources/Topics/09.juneau-rest-client/01.RestProxies/02.RemoteMethod.html
@@ -17,7 +17,7 @@
<p>
The {@link org.apache.juneau.rest.client.remote.RemoteMethod @RemoteMethod} annotation is applied to methods
- of {@link org.apache.juneau.rest.client.remote.RemoteResource @RemoteResource}-annotated interfaces to identify REST endpoints.
+ of <ja>@RemoteResource</ja>-annotated interfaces to identify REST endpoints.
</p>
<ul class='doctree'>
<li class='ja'>{@link org.apache.juneau.rest.client.remote.RemoteMethod}
@@ -42,12 +42,12 @@
}
</p>
<p>
- The method names can be anything.
+ The Java method name can be anything.
</p>
<h5 class='topic w800'>Inferred method/path</h5>
<p>
- The <code>method</code> and <code>path</code> annotations are optional if you follow certain naming
+ In such cases, <code>method</code> and <code>path</code> annotations are optional if you follow certain naming
conventions on your method that identify the method and path.
</p>
<p>
@@ -140,8 +140,6 @@
<li>
{@link java.io.Reader}
- Returns access to the raw reader of the response.
- <br>Note that if you don't want your response parsed as a POJO, you'll want to get the response reader
- directly.
<li>
{@link java.io.InputStream}
- Returns access to the raw input stream of the response.
@@ -162,3 +160,23 @@
<jk>int</jk> postPets(...);
}
</p>
+
+<p>
+ If your <code>RestClient</code> does not have a parser associated with it, then the {@link org.apache.juneau.httppart.OpenApiPartParser OpenAPI part parser}
+ is used to parse the response.
+ <br>If your <code>RestClient</code> does have a parser associated with it, then you can force it to use the part parser using the {@link org.apache.juneau.http.annotation.Response#usePartParser() @Response(usePartParser)}
+ annotation on your method like so:
+</p>
+<p class='bpcode w800'>
+ <ja>@RemoteResource</ja>
+ <jk>public interface</jk> PetStore {
+
+ <jc>// Force the part parser to be used for the response body.</jc>
+ <ja>@RemoteMethod</ja>
+ <ja>@Response</ja>(usePartParser=<jk>true</jk>)
+ String postPets(...);
+ }
+</p>
+<p>
+ The usage of <ja>@Response</ja> is described in detail below.
+</p>
diff --git a/juneau-doc/src/main/resources/Topics/09.juneau-rest-client/01.RestProxies/03.Body.html b/juneau-doc/src/main/resources/Topics/09.juneau-rest-client/01.RestProxies/03.Body.html
index 1bd4714..3f97775 100644
--- a/juneau-doc/src/main/resources/Topics/09.juneau-rest-client/01.RestProxies/03.Body.html
+++ b/juneau-doc/src/main/resources/Topics/09.juneau-rest-client/01.RestProxies/03.Body.html
@@ -57,8 +57,8 @@
</p>
<ul class='spaced-list'>
<li>
- Any serializable POJO - Converted to text using the {@link org.apache.juneau.serializer.Serializer} or {@link org.apache.juneau.httppart.HttpPartSerializer} registered with the
- <code>RestClient</code> or specified on annotation.
+ Any serializable POJO - Converted to output using the {@link org.apache.juneau.serializer.Serializer} or {@link org.apache.juneau.httppart.HttpPartSerializer} registered with the
+ <code>RestClient</code> ({@link org.apache.juneau.httppart.OpenApiPartSerializer} by default) or associated via the {@link org.apache.juneau.http.annotation.Body#partSerializer() @Body(partSerializer)} annotation.
<li>
{@link java.io.Reader} - Raw contents of {@code Reader} will be serialized to remote resource.
<li>
@@ -70,14 +70,15 @@
</ul>
<p>
- OpenAPI schema based serialization can be used by specifying a value for the {@link org.apache.juneau.http.annotation.Body#partSerializer() @Body(partSerializer)} annotation.
+ OpenAPI schema based serialization can be used by specifying a value for the {@link org.apache.juneau.http.annotation.Body#partSerializer() @Body(partSerializer)} annotation
+ or setting {@link org.apache.juneau.http.annotation.Body#usePartSerializer() @Body(usePartSerializer)} to <jk>true</jk>.
</p>
<p class='bpcode w800'>
<ja>@RemoteMethod</ja>(path=<js>"/comma-delimited-pipe-delimited-ints"</js>)
String addCommaDelimitedPipeDelimitedInts(
<ja>@Body</ja>(
- serializer=OpenApiPartSerializer.<jk>class</jk>,
+ usePartSerializer=<jk>true</jk>,
schema=<ja>@Schema</ja>(
type=<js>"array"</js>,
collectionFormat=<js>"pipes"</js>,
@@ -95,9 +96,12 @@
<jk>int</jk>[][] input
);
</p>
-
<p>
- When using OpenAPI serialization, the argument can be any data type specified in {@link org.apache.juneau.httppart.OpenApiPartSerializer}.
+ If your <code>RestClient</code> class does not have a serializer associated with it, the body will automatically be serialized using the registered
+ OpenAPI part serializer.
+</p>
+<p>
+ See the link below for information about supported data types in OpenAPI serialization.
</p>
<h5 class='section'>See Also:</h5>
@@ -105,3 +109,5 @@
<li class='link'>{@doc juneau-marshall.OpenApiDetails.Serializers}
</ul>
+
+
diff --git a/juneau-doc/src/main/resources/Topics/09.juneau-rest-client/01.RestProxies/04.FormData.html b/juneau-doc/src/main/resources/Topics/09.juneau-rest-client/01.RestProxies/04.FormData.html
index 09a5c2f..d1d9453 100644
--- a/juneau-doc/src/main/resources/Topics/09.juneau-rest-client/01.RestProxies/04.FormData.html
+++ b/juneau-doc/src/main/resources/Topics/09.juneau-rest-client/01.RestProxies/04.FormData.html
@@ -88,7 +88,7 @@
<ul class='spaced-list'>
<li>
Any serializable POJO - Converted to a string using the {@link org.apache.juneau.httppart.HttpPartSerializer} registered with the
- <code>RestClient</code> or associated via the {@link org.apache.juneau.http.annotation.FormData#serializer() @FormData(serializer)} annotation.
+ <code>RestClient</code> ({@link org.apache.juneau.httppart.OpenApiPartSerializer} by default) or associated via the {@link org.apache.juneau.http.annotation.FormData#serializer() @FormData(serializer)} annotation.
</ul>
<p>
Multi-part arguments (i.e. those with name == <js>"*"</js> or empty) can be any of the following types:
@@ -102,16 +102,15 @@
<code>NameValuePairs</code> - Converted to a URL-encoded FORM post.
<li>
<code>Map</code> - Converted to key-value pairs.
- <br>Values serialized using the registered {@link org.apache.juneau.httppart.HttpPartSerializer}.
+ <br>Values serialized using the registered {@link org.apache.juneau.httppart.HttpPartSerializer} ({@link org.apache.juneau.httppart.OpenApiPartSerializer} by default).
<li>
Bean - Converted to key-value pairs.
- <br>Values serialized using the registered {@link org.apache.juneau.httppart.HttpPartSerializer}.
+ <br>Values serialized using the registered {@link org.apache.juneau.httppart.HttpPartSerializer} ({@link org.apache.juneau.httppart.OpenApiPartSerializer} by default).
<li>
<code>CharSequence</code> - Used directly as am <js>"application/x-www-form-urlencoded"</js> entity.
</ul>
-
<p>
- When using OpenAPI serialization, the argument can be any data type specified in {@link org.apache.juneau.httppart.OpenApiPartSerializer}.
+ See the link below for information about supported data types in OpenAPI serialization.
</p>
<h5 class='section'>See Also:</h5>
diff --git a/juneau-doc/src/main/resources/Topics/09.juneau-rest-client/01.RestProxies/05.Query.html b/juneau-doc/src/main/resources/Topics/09.juneau-rest-client/01.RestProxies/05.Query.html
index ac61b8d..1ecfb9d 100644
--- a/juneau-doc/src/main/resources/Topics/09.juneau-rest-client/01.RestProxies/05.Query.html
+++ b/juneau-doc/src/main/resources/Topics/09.juneau-rest-client/01.RestProxies/05.Query.html
@@ -91,7 +91,7 @@
<ul class='spaced-list'>
<li>
Any serializable POJO - Converted to a string using the {@link org.apache.juneau.httppart.HttpPartSerializer} registered with the
- <code>RestClient</code> or associated via the {@link org.apache.juneau.http.annotation.Query#serializer() @Query(serializer)} annotation.
+ <code>RestClient</code> ({@link org.apache.juneau.httppart.OpenApiPartSerializer} by default) or associated via the {@link org.apache.juneau.http.annotation.Query#serializer() @Query(serializer)} annotation.
</ul>
<p>
@@ -104,16 +104,16 @@
<code>NameValuePairs</code> - Serialized as individual query parameters.
<li>
<code>Map</code> - Converted to key-value pairs.
- <br>Values serialized using the registered {@link org.apache.juneau.httppart.HttpPartSerializer}.
+ <br>Values serialized using the registered {@link org.apache.juneau.httppart.HttpPartSerializer} ({@link org.apache.juneau.httppart.OpenApiPartSerializer} by default).
<li>
Bean - Converted to key-value pairs.
- <br>Values serialized using the registered {@link org.apache.juneau.httppart.HttpPartSerializer}.
+ <br>Values serialized using the registered {@link org.apache.juneau.httppart.HttpPartSerializer} ({@link org.apache.juneau.httppart.OpenApiPartSerializer} by default).
<li>
<code>CharSequence</code> - Serialized directly a query string.
</ul>
<p>
- When using OpenAPI serialization, the argument can be any data type specified in {@link org.apache.juneau.httppart.OpenApiPartSerializer}.
+ See the link below for information about supported data types in OpenAPI serialization.
</p>
<h5 class='section'>See Also:</h5>
diff --git a/juneau-doc/src/main/resources/Topics/09.juneau-rest-client/01.RestProxies/06.Header.html b/juneau-doc/src/main/resources/Topics/09.juneau-rest-client/01.RestProxies/06.Header.html
index 71c8d22..2a4b0f2 100644
--- a/juneau-doc/src/main/resources/Topics/09.juneau-rest-client/01.RestProxies/06.Header.html
+++ b/juneau-doc/src/main/resources/Topics/09.juneau-rest-client/01.RestProxies/06.Header.html
@@ -13,7 +13,7 @@
***************************************************************************************************************************/
-->
-{todo} @Header
+{new} @Header
<p>
The {@link org.apache.juneau.http.annotation.Header @Header} annotation can be applied to arguments of <ja>@RemoteMethod</ja>-annotated methods
@@ -47,22 +47,59 @@
</ul>
</ul>
-{@link org.apache.juneau.http.annotation.Header}
-- A request header.
-<br>The argument can be any of the following types:
-<ul>
- <li class='normal'>Any serializable POJO
- - Converted to text using {@link org.apache.juneau.httppart.SimpleUonPartSerializerSession#serialize(HttpPartType,HttpPartSchema,Object)}.
- <li class='normal'><code>Map<String,Object></code>
- - Individual name-value pairs.
- <br>Values are converted to text using {@link org.apache.juneau.httppart.SimpleUonPartSerializerSession#serialize(HttpPartType,HttpPartSchema,Object)}.
-</ul>
+<h5 class='figure'>Example:</h5>
+<p class='bpcode w800'>
+ <ja>@RemoteResource</ja>(path=<js>"/myproxy"</js>)
+ <jk>public interface</jk> MyProxy {
+
+ <jc>// Explicit names specified for HTTP headers.</jc>
+ <jc>// pojo will be converted to UON notation (unless plain-text parts enabled).</jc>
+ <ja>@RemoteMethod</ja>(path=<js>"/mymethod1"</js>)
+ String myProxyMethod1(<ja>@Header</ja>(<js>"Foo"</js>)</ja> String foo,
+ <ja>@Header</ja>(<js>"Bar"</js>)</ja> MyPojo pojo);
+ <jc>// Multiple values pulled from a NameValuePairs object.</jc>
+ <jc>// Same as @Header("*").</jc>
+ <ja>@RemoteMethod</ja>(path=<js>"/mymethod2"</js>)
+ String myProxyMethod2(<ja>@Header</ja> NameValuePairs nameValuePairs);
+
+ <jc>// Multiple values pulled from a Map.</jc>
+ <jc>// Same as @Header("*").</jc>
+ <ja>@RemoteMethod</ja>(path=<js>"/mymethod3"</js>)
+ String myProxyMethod3(<ja>@Header</ja> Map<String,Object> map);
+
+ <jc>// Multiple values pulled from a bean.</jc>
+ <jc>// Same as @Header("*").</jc>
+ <ja>@RemoteMethod</ja>(path=<js>"/mymethod4"</js>)
+ String myProxyMethod4(<ja>@Header</ja> MyBean myBean);
+ }
+</p>
+<p>
+ Single-part arguments (i.e. those with name != <js>"*"</js>) can be any of the following types:
+</p>
+<ul class='spaced-list'>
+ <li>
+ Any serializable POJO - Converted to a string using the {@link org.apache.juneau.httppart.HttpPartSerializer} registered with the
+ <code>RestClient</code> ({@link org.apache.juneau.httppart.OpenApiPartSerializer} by default) or associated via the {@link org.apache.juneau.http.annotation.Header#serializer() @Header(serializer)} annotation.
+</ul>
+<p>
+ Multi-part arguments (i.e. those with name == <js>"*"</js> or empty) can be any of the following types:
+</p>
+<ul class='spaced-list'>
+ <li>
+ <code>NameValuePairs</code> - Serialized as individual headers.
+ <li>
+ <code>Map</code> - Converted to key-value pairs.
+ <br>Values serialized using the registered {@link org.apache.juneau.httppart.HttpPartSerializer} ({@link org.apache.juneau.httppart.OpenApiPartSerializer} by default).
+ <li>
+ Bean - Converted to key-value pairs.
+ <br>Values serialized using the registered {@link org.apache.juneau.httppart.HttpPartSerializer} ({@link org.apache.juneau.httppart.OpenApiPartSerializer} by default).
+</ul>
<p>
- When using OpenAPI serialization, the argument can be any data type specified in {@link org.apache.juneau.httppart.OpenApiPartSerializer}.
+ See the link below for information about supported data types in OpenAPI serialization.
</p>
<h5 class='section'>See Also:</h5>
diff --git a/juneau-doc/src/main/resources/Topics/09.juneau-rest-client/01.RestProxies/07.Path.html b/juneau-doc/src/main/resources/Topics/09.juneau-rest-client/01.RestProxies/07.Path.html
index d852ac5..f19fe49 100644
--- a/juneau-doc/src/main/resources/Topics/09.juneau-rest-client/01.RestProxies/07.Path.html
+++ b/juneau-doc/src/main/resources/Topics/09.juneau-rest-client/01.RestProxies/07.Path.html
@@ -13,7 +13,7 @@
***************************************************************************************************************************/
-->
-{todo} @Path
+{new} @Path
<p>
The {@link org.apache.juneau.http.annotation.Path @Path} annotation can be applied to arguments of <ja>@RemoteMethod</ja>-annotated methods
@@ -41,8 +41,58 @@
</ul>
</ul>
+<h5 class='figure'>Example:</h5>
+<p class='bpcode w800'>
+ <ja>@RemoteResource</ja>(path=<js>"/myproxy"</js>)
+ <jk>public interface</jk> MyProxy {
+
+ <jc>// Explicit names specified for path parameters.</jc>
+ <jc>// pojo will be converted to UON notation (unless plain-text parts enabled).</jc>
+ <ja>@RemoteMethod</ja>(path=<js>"/mymethod1/{foo}/{bar}"</js>)
+ String myProxyMethod1(<ja>@Path</ja>(<js>"foo"</js>)</ja> String foo, <ja>@Path</ja>(<js>"bar"</js>)</ja> MyPojo pojo);
+
+ <jc>// Multiple values pulled from a NameValuePairs object.</jc>
+ <jc>// Same as @Path("*").</jc>
+ <ja>@RemoteMethod</ja>(path=<js>"/mymethod2/{foo}/{bar}/{baz}"</js>)
+ String myProxyMethod2(<ja>@Path</ja> NameValuePairs nameValuePairs);
+
+ <jc>// Multiple values pulled from a Map.</jc>
+ <jc>// Same as @Path("*").</jc>
+ <ja>@RemoteMethod</ja>(path=<js>"/mymethod3/{foo}/{bar}/{baz}"</js>)
+ String myProxyMethod3(<ja>@Path</ja> Map<String,Object> map);
+
+ <jc>// Multiple values pulled from a bean.</jc>
+ <jc>// Same as @Path("*").</jc>
+ <ja>@RemoteMethod</ja>(path=<js>"/mymethod4/{foo}/{bar}/{baz}"</js>)
+ String myProxyMethod4(<ja>@Path</ja> MyBean myBean);
+ }
+</p>
+
+<p>
+ Single-part arguments (i.e. those with name != <js>"*"</js>) can be any of the following types:
+</p>
+<ul class='spaced-list'>
+ <li>
+ Any serializable POJO - Converted to a string using the {@link org.apache.juneau.httppart.HttpPartSerializer} registered with the
+ <code>RestClient</code> ({@link org.apache.juneau.httppart.OpenApiPartSerializer} by default) or associated via the {@link org.apache.juneau.http.annotation.Path#serializer() @Path(serializer)} annotation.
+</ul>
+
+<p>
+ Multi-part arguments (i.e. those with name == <js>"*"</js> or empty) can be any of the following types:
+</p>
+<ul class='spaced-list'>
+ <li>
+ <code>NameValuePairs</code> - Serialized as individual query parameters.
+ <li>
+ <code>Map</code> - Converted to key-value pairs.
+ <br>Values serialized using the registered {@link org.apache.juneau.httppart.HttpPartSerializer} ({@link org.apache.juneau.httppart.OpenApiPartSerializer} by default).
+ <li>
+ Bean - Converted to key-value pairs.
+ <br>Values serialized using the registered {@link org.apache.juneau.httppart.HttpPartSerializer} ({@link org.apache.juneau.httppart.OpenApiPartSerializer} by default).
+</ul>
+
<p>
- When using OpenAPI serialization, the argument can be any data type specified in {@link org.apache.juneau.httppart.OpenApiPartSerializer}.
+ See the link below for information about supported data types in OpenAPI serialization.
</p>
<h5 class='section'>See Also:</h5>
diff --git a/juneau-doc/src/main/resources/Topics/09.juneau-rest-client/01.RestProxies/08.Request.html b/juneau-doc/src/main/resources/Topics/09.juneau-rest-client/01.RestProxies/08.Request.html
index 994801a..57a1515 100644
--- a/juneau-doc/src/main/resources/Topics/09.juneau-rest-client/01.RestProxies/08.Request.html
+++ b/juneau-doc/src/main/resources/Topics/09.juneau-rest-client/01.RestProxies/08.Request.html
@@ -133,3 +133,94 @@ TODO(7.2.0)
}
</p>
+<p>
+ The annotation can also be applied to a bean property field or getter when the argument or argument class is annotated with {@link org.apache.juneau.http.annotation.Request @Request}:
+</p>
+
+<h5 class='section'>Example:</h5>
+<p class='bcode w800'>
+ <ja>@RemoteResource</ja>(path=<js>"/myproxy"</js>)
+ <jk>public interface</jk> MyProxy {
+
+ <ja>@RemoteMethod</ja>(path=<js>"/mymethod"</js>)
+ String myProxyMethod(<ja>@Request</ja> MyRequest bean);
+ }
+
+ <jk>public interface</jk> MyRequest {
+
+ <jc>// Name explicitly specified.</jc>
+ <ja>@Header</ja>(<js>"Foo"</js>)
+ String getX();
+
+ <jc>// Name inherited from bean property.</jc>
+ <jc>// Same as @Header("bar")</jc>
+ <ja>@Header</ja>
+ String getBar();
+
+ <jc>// Multiple values pulled from NameValuePairs object.</jc>
+ <jc>// Same as @Header("*")</jc>
+ <ja>@Header</ja>
+ NameValuePairs getNameValuePairs();
+
+ <jc>// Multiple values pulled from Map.</jc>
+ <jc>// Same as @Header("*")</jc>
+ <ja>@Header</ja>
+ Map<String,Object> getMap();
+
+ <jc>// Multiple values pulled from bean.</jc>
+ <jc>// Same as @Header("*")</jc>
+ <ja>@Header</ja>
+ MyBean getBean();
+ }
+</p>
+
+<p>
+ The annotation can also be applied to a bean property field or getter when the argument or argument class is annotated with
+ {@link org.apache.juneau.http.annotation.Request @Request}:
+</p>
+<h5 class='section'>Example:</h5>
+<p class='bcode w800'>
+ <ja>@RemoteResource</ja>(path=<js>"/myproxy"</js>)
+ <jk>public interface</jk> MyProxy {
+
+ <ja>@RemoteMethod</ja>(path=<js>"/mymethod/{foo}/{bar}/{baz}"</js>)
+ String myProxyMethod(<ja>@Request</ja> MyRequest bean);
+ }
+
+ <jk>public interface</jk> MyRequest {
+
+ <jc>// Name explicitly specified.</jc>
+ <ja>@Path</ja>(<js>"foo"</js>)
+ String getX();
+
+ <jc>// Name inherited from bean property.</jc>
+ <jc>// Same as @Path("bar")</jc>
+ <ja>@Path</ja>
+ String getBar();
+
+ <jc>// Multiple values pulled from NameValuePairs object.</jc>
+ <jc>// Same as @Path("*")</jc>
+ <ja>@Path</ja>
+ NameValuePairs getNameValuePairs();
+
+ <jc>// Multiple values pulled from Map.</jc>
+ <jc>// Same as @Path("*")</jc>
+ <ja>@Path</ja>
+ Map<String,Object> getMap();
+
+ <jc>// Multiple values pulled from bean.</jc>
+ <jc>// Same as @Path("*")</jc>
+ <ja>@Path</ja>
+ MyBean getMyBean();
+ }
+</p>
+
+
+
+
+
+
+
+
+
+
diff --git a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestCall.java b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestCall.java
index 8d4a2f7..7ac9deb 100644
--- a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestCall.java
+++ b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestCall.java
@@ -96,6 +96,7 @@ public final class RestCall extends BeanSession implements Closeable {
private boolean hasInput; // input() was called, even if it's setting 'null'.
private Serializer serializer;
private Parser parser;
+ private HttpPartSerializer partSerializer;
private HttpPartParser partParser;
private URIBuilder uriBuilder;
private NameValuePairs formData;
@@ -119,6 +120,7 @@ public final class RestCall extends BeanSession implements Closeable {
this.retryInterval = client.retryInterval;
this.serializer = client.serializer;
this.parser = client.parser;
+ this.partSerializer = client.getPartSerializer();
this.partParser = client.getPartParser();
uriBuilder = new URIBuilder(uri);
}
@@ -559,6 +561,8 @@ public final class RestCall extends BeanSession implements Closeable {
*/
public RestCall body(Object input, HttpPartSerializer partSerializer, HttpPartSchema schema) throws RestCallException {
try {
+ if (schema != null && schema.isUsePartSerializer())
+ partSerializer = this.partSerializer;
if (partSerializer != null)
body(new StringEntity(partSerializer.serialize(BODY, schema, input)));
else
@@ -2167,7 +2171,11 @@ public final class RestCall extends BeanSession implements Closeable {
Header h = response.getFirstHeader("Content-Type");
MediaType mt = MediaType.forString(h == null ? null : h.getValue());
- if ((isEmpty(mt) || mt.toString().equals("text/plain"))) {
+ boolean usePartParser = isEmpty(mt)
+ || mt.toString().equals("text/plain")
+ || (schema != null && partParser != null && schema.isUsePartParser());
+
+ if (usePartParser) {
if (type.hasStringTransform())
return type.getStringTransform().transform(getResponseAsString());
if (partParser != null)
diff --git a/juneau-rest/juneau-rest-client/src/test/java/org/apache/juneau/rest/client/remote/RemoteMethodAnnotationTest.java b/juneau-rest/juneau-rest-client/src/test/java/org/apache/juneau/rest/client/remote/RemoteMethodAnnotationTest.java
index 53bcc4c..bbe45e9 100644
--- a/juneau-rest/juneau-rest-client/src/test/java/org/apache/juneau/rest/client/remote/RemoteMethodAnnotationTest.java
+++ b/juneau-rest/juneau-rest-client/src/test/java/org/apache/juneau/rest/client/remote/RemoteMethodAnnotationTest.java
@@ -17,7 +17,9 @@ import static org.junit.Assert.*;
import java.io.*;
import org.apache.http.*;
+import org.apache.juneau.http.annotation.*;
import org.apache.juneau.internal.*;
+import org.apache.juneau.json.*;
import org.apache.juneau.rest.annotation.*;
import org.apache.juneau.rest.client.*;
import org.apache.juneau.rest.mock.*;
@@ -124,9 +126,91 @@ public class RemoteMethodAnnotationTest {
public void b01_returnTypes() throws Exception {
B01 t = rb.getRemoteResource(B01.class);
t.b01();
-// assertEquals("foo", t.b02());
+ assertEquals("foo", t.b02());
assertEquals("bar", IOUtils.read(t.b02a().getEntity().getContent()));
assertEquals("baz", IOUtils.read(t.b02b()));
assertEquals("qux", IOUtils.read(t.b02c()));
}
+
+ //=================================================================================================================
+ // Return types, JSON
+ //=================================================================================================================
+
+ @RestResource(serializers=SimpleJsonSerializer.class, parsers=JsonParser.class)
+ public static class C {
+
+ @RestMethod(name="POST")
+ public String c01(@Body String body) {
+ return body;
+ }
+ }
+ private static MockRest c = MockRest.create(C.class);
+ private static RestClient rc = RestClient.create().mockHttpConnection(c).simpleJson().build();
+
+ @RemoteResource
+ public static interface C01 {
+
+ @RemoteMethod(method="POST",path="c01")
+ public String c01a(@Body String foo);
+
+ @RemoteMethod(method="POST",path="c01")
+ public HttpResponse c01b(@Body String foo);
+
+ @RemoteMethod(method="POST",path="c01")
+ public Reader c01c(@Body String foo);
+
+ @RemoteMethod(method="POST",path="c01")
+ public InputStream c01d(@Body String foo);
+ }
+
+ @Test
+ public void c01_returnTypes_json() throws Exception {
+ C01 t = rc.getRemoteResource(C01.class);
+ assertEquals("foo", t.c01a("foo"));
+ assertEquals("'foo'", IOUtils.read(t.c01b("foo").getEntity().getContent()));
+ assertEquals("'foo'", IOUtils.read(t.c01c("foo")));
+ assertEquals("'foo'", IOUtils.read(t.c01d("foo")));
+ }
+
+ //=================================================================================================================
+ // Return types, part serialization
+ //=================================================================================================================
+
+ @RestResource(serializers=SimpleJsonSerializer.class, parsers=JsonParser.class)
+ public static class D {
+
+ @RestMethod(name="POST")
+ @Response(usePartSerializer=true)
+ public String d01(@Body(usePartParser=true) String body) {
+ return body;
+ }
+ }
+ private static MockRest d = MockRest.create(D.class, true);
+ private static RestClient rd = RestClient.create().debug().mockHttpConnection(d).build();
+
+ @RemoteResource
+ public static interface D01 {
+
+ @RemoteMethod(method="POST",path="d01")
+ @Response(usePartParser=true)
+ public String d01a(@Body(usePartSerializer=true) String foo);
+
+ @RemoteMethod(method="POST",path="d01")
+ public HttpResponse d01b(@Body(usePartSerializer=true) String foo);
+
+ @RemoteMethod(method="POST",path="d01")
+ public Reader d01c(@Body(usePartSerializer=true) String foo);
+
+ @RemoteMethod(method="POST",path="d01")
+ public InputStream d01d(@Body(usePartSerializer=true) String foo);
+ }
+
+ @Test
+ public void d01_returnTypes_partSerialization() throws Exception {
+ D01 t = rd.getRemoteResource(D01.class);
+ assertEquals("foo", t.d01a("foo"));
+ assertEquals("foo", IOUtils.read(t.d01b("foo").getEntity().getContent()));
+ assertEquals("foo", IOUtils.read(t.d01c("foo")));
+ assertEquals("foo", IOUtils.read(t.d01d("foo")));
+ }
}
diff --git a/juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/annotation/ResponseAnnotationTest.java b/juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/annotation/ResponseAnnotationTest.java
index a759bc7..9a58da7 100644
--- a/juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/annotation/ResponseAnnotationTest.java
+++ b/juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/annotation/ResponseAnnotationTest.java
@@ -742,6 +742,28 @@ public class ResponseAnnotationTest {
assertObjectEquals("{description:'OK',schema:{type:'array',items:{type:'integer',format:'int32'}}}", ri);
}
+
+ //=================================================================================================================
+ // @Response on RestMethod
+ //=================================================================================================================
+
+ @RestResource(serializers=SimpleJsonSerializer.class, parsers=JsonParser.class)
+ public static class J {
+
+ @RestMethod(name="POST")
+ @Response(usePartSerializer=true)
+ public String j01(@Body(usePartParser=true) String body) {
+ return body;
+ }
+ }
+ static MockRest j = MockRest.create(J.class);
+
+ @Test
+ public void j01a_basic() throws Exception {
+ j.post("/j01", "foo").execute().assertStatus(200).assertBody("foo").assertHeader("Content-Type", "text/plain");
+ }
+
+
//=================================================================================================================
// @Response on POJO
//=================================================================================================================