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 1819a5d Javadocs
1819a5d is described below
commit 1819a5d3d45e2941a599fa9d706764099e46ce03
Author: JamesBognar <[email protected]>
AuthorDate: Sat Jul 28 17:11:34 2018 -0400
Javadocs
---
.../juneau/http/annotation/ResponseStatus.java | 47 ------
.../juneau/http/annotation/ResponseStatuses.java | 39 -----
juneau-doc/src/main/javadoc/overview.html | 158 +++++++++++++++++++--
.../09.HttpPartAnnotations/09.Response.html | 2 +-
.../09.HttpPartAnnotations/10.ResponseHeader.html | 2 +-
.../09.HttpPartAnnotations/11.ResponseStatus.html | 80 ++++++++++-
.../12.ResponseStatuses.html | 71 ++++++++-
7 files changed, 299 insertions(+), 100 deletions(-)
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/ResponseStatus.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/ResponseStatus.java
index 2159770..1c98f49 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/ResponseStatus.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/ResponseStatus.java
@@ -16,8 +16,6 @@ import static java.lang.annotation.RetentionPolicy.*;
import java.lang.annotation.*;
-import org.apache.juneau.*;
-
/**
* REST response status annotation.
*
@@ -30,51 +28,6 @@ import org.apache.juneau.*;
* <li>Java method arguments and argument-types of server-side
<ja>@RestMethod</ja>-annotated REST Java methods.
* </ul>
*
- * <p>
- * This can only be applied to parameters and subclasses of the {@link Value}
class with an {@link Integer} type.
- * <br>The {@link Value} object is mean to be a place-holder for the set value.
- *
- * <h5 class='section'>Examples:</h5>
- * <p class='bcode w800'>
- * <jc>// Defined on parameter.</jc>
- * <ja>@RestMethod</ja>(name=<js>"GET"</js>, path=<js>"/user/login"</js>)
- * <jk>public void</jk> login(String username, String password,
- * <ja>@ResponseStatus</ja>(code=401,
description=<js>"Invalid user/pw"</js>) Value<Integer> status) {
- * <jk>if</jk> (! isValid(username, password))
- * status.set(401);
- * }
- * </p>
- * <p class='bcode w800'>
- * <jc>// Defined on parameter class.</jc>
- * <ja>@RestMethod</ja>(name=<js>"GET"</js>, path=<js>"/user/login"</js>)
- * <jk>public void</jk> login(String username, String password,
LoginStatus status) {
- * <jk>if</jk> (! isValid(username, password))
- * status.set(401);
- * }
- *
- * <ja>@ResponseStatus</ja>(code=401, description=<js>"Invalid
user/pw"</js>)
- * <jk>public class</jk> LoginStatus <jk>extends</jk> Value<Integer>
{}
- * </p>
- *
- * <p>
- * The attributes on this annotation are used to populate the generated
Swagger for the method.
- * <br>In this case, the Swagger is populated with the following:
- *
- * <p class='bcode w800'>
- * <js>'/user/login'</js>: {
- * get: {
- * responses: {
- * 200: {
- * description: <js>'OK'</js>
- * },
- * 401: {
- * description: <js>'Invalid user/pw'</js>
- * }
- * }
- * }
- * }
- * </p>
- *
* <h5 class='section'>See Also:</h5>
* <ul>
* <li class='link'><a class="doclink"
href="../../../../../overview-summary.html#juneau-rest-server.HttpPartAnnotations.ResponseStatus">Overview
> juneau-rest-server > @ResponseStatus</a>
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/ResponseStatuses.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/ResponseStatuses.java
index 9479d9d..f236867 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/ResponseStatuses.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/ResponseStatuses.java
@@ -17,51 +17,12 @@ import static java.lang.annotation.RetentionPolicy.*;
import java.lang.annotation.*;
-import org.apache.juneau.*;
-
/**
* REST response statuses annotation.
*
* <p>
* Used to associate multiple {@link ResponseStatus @ResponseStatus}
annotations to the same parameter or class.
*
- * <h5 class='section'>Example:</h5>
- * <p class='bcode w800'>
- * <ja>@RestMethod</ja>(name=<js>"GET"</js>, path=<js>"/user/login"</js>)
- * <jk>public void</jk> login(String username, String password,
- * <ja>@ResponseStatuses</ja>{
- * <ja>@ResponseStatus</ja>(200)
- * <ja>@ResponseStatus</ja>(code=401,
description=<js>"Invalid user/pw"</js>)
- * }
- * Value<Integer> status) {
- *
- * <jk>if</jk> (! isValid(username, password))
- * status.set(401);
- * <jk>else</jk>
- * status.set(200);
- * }
- * </p>
- *
- * <p>
- * The other option is to apply this annotation to a subclass of {@link Value}
which often leads to a cleaner
- * REST method:
- *
- * <p class='bcode w800'>
- * <ja>@ResponseStatuses</ja>{
- * <ja>@ResponseStatus</ja>(200)
- * <ja>@ResponseStatus</ja>(code=401, description=<js>"Invalid
user/pw"</js>)
- * }
- * <jk>public class</jk> LoginStatus <jk>extends</jk> Value<Integer>
{}
- *
- * <ja>@RestMethod</ja>(name=<js>"GET"</js>, path=<js>"/user/login"</js>)
- * <jk>public void</jk> login(String username, String password,
LoginStatus status) {
- * <jk>if</jk> (! isValid(username, password))
- * status.set(401);
- * <jk>else</jk>
- * status.set(200);
- * }
- * </p>
- *
* <p>
* Since Juneau currently prereq's Java 1.7, we cannot take advantage of
annotation duplication support in Java 8.
* <br>This annotation overcomes that limitation.
diff --git a/juneau-doc/src/main/javadoc/overview.html
b/juneau-doc/src/main/javadoc/overview.html
index 0bf1ecd..3995ccd 100644
--- a/juneau-doc/src/main/javadoc/overview.html
+++ b/juneau-doc/src/main/javadoc/overview.html
@@ -315,8 +315,8 @@
<li><p class='new'><a class='doclink'
href='#juneau-rest-server.HttpPartAnnotations.RequestBean'>@RequestBean</a></p>
<li><p class='new'><a class='doclink'
href='#juneau-rest-server.HttpPartAnnotations.Response'>@Response</a></p>
<li><p class='new'><a class='doclink'
href='#juneau-rest-server.HttpPartAnnotations.ResponseHeader'>@ResponseHeader</a></p>
- <li><p class='todo'><a class='doclink'
href='#juneau-rest-server.HttpPartAnnotations.ResponseStatus'>@ResponseStatus</a></p>
- <li><p class='todo'><a class='doclink'
href='#juneau-rest-server.HttpPartAnnotations.ResponseStatuses'>@ResponseStatuses</a></p>
+ <li><p class='new'><a class='doclink'
href='#juneau-rest-server.HttpPartAnnotations.ResponseStatus'>@ResponseStatus</a></p>
+ <li><p class='new'><a class='doclink'
href='#juneau-rest-server.HttpPartAnnotations.ResponseStatuses'>@ResponseStatuses</a></p>
</ol>
<li><p class=''><a class='doclink'
href='#juneau-rest-server.HandlingFormPosts'>Handling Form Posts</a></p>
<li><p class=''><a class='doclink'
href='#juneau-rest-server.HandlingMultiPartFormPosts'>Handling Multi-Part Form
Posts</a></p>
@@ -15585,7 +15585,7 @@ VariantAlsoNegotiates
By default, POJOs representing the body of the request are serialized
using the Juneau serializer
matching the requesting <code>Accept</code> header.
<br>It is also possible to use OpenAPI part serialization for the body
of the response using
- the {@link org.apache.juneau.http.Response#usePartSerializer()
usePartSerializer} flag.
+ the {@link
org.apache.juneau.http.annotation.Response#usePartSerializer()
usePartSerializer} flag.
<br>The flag is needed to identify that we should use the part
serializer instead of normal serializers for the POJO.
</p>
<p>
@@ -15717,7 +15717,7 @@ VariantAlsoNegotiates
<li>Java method arguments and argument-types of server-side
<ja>@RestMethod</ja>-annotated REST Java methods.
</ul>
<p>
- This annotation can only be applied to subclasses or parameters of type
{@link Value}.
+ This annotation can only be applied to subclasses or parameters of type
{@link org.apache.juneau.Value}.
</p>
<p>
The following examples show 3 different ways of accomplishing the same
task of setting an HTTP header
@@ -15792,16 +15792,158 @@ VariantAlsoNegotiates
<!--
====================================================================================================
-->
-<h4 class='topic todo' onclick='toggle(this)'><a
href='#juneau-rest-server.HttpPartAnnotations.ResponseStatus'
id='juneau-rest-server.HttpPartAnnotations.ResponseStatus'>7.9.11 -
@ResponseStatus</a></h4>
+<h4 class='topic new' onclick='toggle(this)'><a
href='#juneau-rest-server.HttpPartAnnotations.ResponseStatus'
id='juneau-rest-server.HttpPartAnnotations.ResponseStatus'>7.9.11 -
@ResponseStatus</a></h4>
<div class='topic'><!-- START: 7.9.11 -
juneau-rest-server.HttpPartAnnotations.ResponseStatus -->
-TODO(7.2.0)
+<p>
+ The {@link org.apache.juneau.http.annotation.ResponseStatus
@ResponseStatus} annotation is applied to parameters and parameter
+ types to denote them as an HTTP response status on server-side REST
method parameters.
+</p>
+<ul class='doctree'>
+ <li class='ja'>{@link org.apache.juneau.http.annotation.ResponseStatus
ResponseStatus}
+ <ul>
+ <li class='jf'>{@link
org.apache.juneau.http.annotation.ResponseStatus#api() api()} - Free-form
Swagger JSON.
+ <li class='jf'>{@link
org.apache.juneau.http.annotation.ResponseStatus#code() code()} - The HTTP
status of the response.
+ <li class='jf'>{@link
org.apache.juneau.http.annotation.ResponseStatus#description() description()} -
Description.
+ <li class='jf'>{@link
org.apache.juneau.http.annotation.ResponseStatus#value() value()} - A synonym
for <code>code</code>.
+ </ul>
+</ul>
+<p>
+ It can be used in the following locations:
+</p>
+<ul>
+ <li>Java method arguments and argument-types of server-side
<ja>@RestMethod</ja>-annotated REST Java methods.
+</ul>
+<p>
+ This can only be applied to parameters and subclasses of the {@link
org.apache.juneau.Value} class with an {@link java.lang.Integer} type.
+ <br>The {@link org.apache.juneau.Value} object is mean to be a
place-holder for the set value.
+</p>
+
+<h5 class='section'>Examples:</h5>
+<p class='bpcode w800'>
+ <jc>// Defined on parameter.</jc>
+ <ja>@RestMethod</ja>(name=<js>"GET"</js>, path=<js>"/user/login"</js>)
+ <jk>public void</jk> login(
+ <ja>@FormData</ja>(<js>"username"</js>) String username,
+ <ja>@FormData</ja>(<js>"password"</js>) String password,
+ <ja>@ResponseStatus</ja>(
+ code=401,
+ description=<js>"Invalid user/pw"</js>
+ )
+ Value<Integer> status
+ )
+ {
+ <jk>if</jk> (! isValid(username, password))
+ status.set(401);
+ }
+</p>
+<p class='bpcode w800'>
+ <jc>// Defined on parameter class.</jc>
+ <ja>@RestMethod</ja>(name=<js>"GET"</js>, path=<js>"/user/login"</js>)
+ <jk>public void</jk> login(
+ <ja>@FormData</ja>(<js>"username"</js>) String username,
+ <ja>@FormData</ja>(<js>"password"</js>) String password,
+ LoginStatus status
+ )
+ {
+ <jk>if</jk> (! isValid(username, password))
+ status.set(401);
+ }
+
+ <ja>@ResponseStatus</ja>(
+ code=401,
+ description=<js>"Invalid user/pw"</js>
+ )
+ <jk>public class</jk> LoginStatus <jk>extends</jk> Value<Integer>
{}
+</p>
+
+<p>
+ The attributes on this annotation are used to populate the generated
Swagger for the method.
+ <br>In this case, the Swagger is populated with the following:
+</p>
+<p class='bpcode w800'>
+ <jok>'/user/login'</jok>: {
+ <jok>get: {
+ <jok>responses: {
+ <jok>401</jok>: {
+ <jok>description</jok>: <jov>'Invalid
user/pw'</jov>
+ }
+ }
+ }
+ }
+</p>
</div><!-- END: 7.9.11 - juneau-rest-server.HttpPartAnnotations.ResponseStatus
-->
<!--
====================================================================================================
-->
-<h4 class='topic todo' onclick='toggle(this)'><a
href='#juneau-rest-server.HttpPartAnnotations.ResponseStatuses'
id='juneau-rest-server.HttpPartAnnotations.ResponseStatuses'>7.9.12 -
@ResponseStatuses</a></h4>
+<h4 class='topic new' onclick='toggle(this)'><a
href='#juneau-rest-server.HttpPartAnnotations.ResponseStatuses'
id='juneau-rest-server.HttpPartAnnotations.ResponseStatuses'>7.9.12 -
@ResponseStatuses</a></h4>
<div class='topic'><!-- START: 7.9.12 -
juneau-rest-server.HttpPartAnnotations.ResponseStatuses -->
-TODO(7.2.0)
+<p>
+ The {@link org.apache.juneau.http.annotation.ResponseStatuses
@ResponseStatuses} annotation is used to
+ associate multiple {@link
org.apache.juneau.http.annotation.ResponseStatus @ResponseStatus} annotations
to the same parameter or class.
+</p>
+
+<h5 class='section'>Example:</h5>
+<p class='bpcode w800'>
+ <ja>@RestMethod</ja>(name=<js>"GET"</js>, path=<js>"/user/login"</js>)
+ <jk>public void</jk> login(
+ <ja>@FormData</ja>(<js>"username"</js>) String username,
+ <ja>@FormData</ja>(<js>"password"</js>) String password,
+ <ja>@ResponseStatuses=</ja>{
+ <ja>@ResponseStatus</ja>(200)
+ <ja>@ResponseStatus</ja>(code=401,
description=<js>"Invalid user/pw"</js>)
+ }
+ Value<Integer> status
+ )
+ {
+ <jk>if</jk> (! isValid(username, password))
+ status.set(401);
+ <jk>else</jk>
+ status.set(200);
+ }
+</p>
+
+<p>
+The other option is to apply this annotation to a subclass of {@link
org.apache.juneau.Value} which often leads to a cleaner
+REST method:
+</p>
+<p class='bpcode w800'>
+ <ja>@ResponseStatuses=</ja>{
+ <ja>@ResponseStatus</ja>(200)
+ <ja>@ResponseStatus</ja>(code=401, description=<js>"Invalid
user/pw"</js>)
+ }
+ <jk>public class</jk> LoginStatus <jk>extends</jk> Value<Integer>
{}
+
+ <ja>@RestMethod</ja>(name=<js>"GET"</js>, path=<js>"/user/login"</js>)
+ <jk>public void</jk> login(
+ <ja>@FormData</ja>(<js>"username"</js>) String username,
+ <ja>@FormData</ja>(<js>"password"</js>) String password,
+ LoginStatus status
+ )
+ {
+ <jk>if</jk> (! isValid(username, password))
+ status.set(401);
+ <jk>else</jk>
+ status.set(200);
+ }
+</p>
+<p>
+ The attributes on this annotation are used to populate the generated
Swagger for the method.
+ <br>In this case, the Swagger is populated with the following:
+</p>
+<p class='bpcode w800'>
+ <jok>'/user/login'</jok>: {
+ <jok>get: {
+ <jok>responses: {
+ <jok>200</jok>: {
+ <jok>description</jok>: <jov>'OK'</jov>
+ },
+ <jok>401</jok>: {
+ <jok>description</jok>: <jov>'Invalid
user/pw'</jov>
+ }
+ }
+ }
+ }
+</p>
</div><!-- END: 7.9.12 -
juneau-rest-server.HttpPartAnnotations.ResponseStatuses -->
</div><!-- END: 7.9 - juneau-rest-server.HttpPartAnnotations -->
diff --git
a/juneau-doc/src/main/resources/Topics/07.juneau-rest-server/09.HttpPartAnnotations/09.Response.html
b/juneau-doc/src/main/resources/Topics/07.juneau-rest-server/09.HttpPartAnnotations/09.Response.html
index 3389fc5..d5905cc 100644
---
a/juneau-doc/src/main/resources/Topics/07.juneau-rest-server/09.HttpPartAnnotations/09.Response.html
+++
b/juneau-doc/src/main/resources/Topics/07.juneau-rest-server/09.HttpPartAnnotations/09.Response.html
@@ -191,7 +191,7 @@
By default, POJOs representing the body of the request are serialized
using the Juneau serializer
matching the requesting <code>Accept</code> header.
<br>It is also possible to use OpenAPI part serialization for the body
of the response using
- the {@link org.apache.juneau.http.Response#usePartSerializer()
usePartSerializer} flag.
+ the {@link
org.apache.juneau.http.annotation.Response#usePartSerializer()
usePartSerializer} flag.
<br>The flag is needed to identify that we should use the part
serializer instead of normal serializers for the POJO.
</p>
<p>
diff --git
a/juneau-doc/src/main/resources/Topics/07.juneau-rest-server/09.HttpPartAnnotations/10.ResponseHeader.html
b/juneau-doc/src/main/resources/Topics/07.juneau-rest-server/09.HttpPartAnnotations/10.ResponseHeader.html
index ef9a916..7565e22 100644
---
a/juneau-doc/src/main/resources/Topics/07.juneau-rest-server/09.HttpPartAnnotations/10.ResponseHeader.html
+++
b/juneau-doc/src/main/resources/Topics/07.juneau-rest-server/09.HttpPartAnnotations/10.ResponseHeader.html
@@ -55,7 +55,7 @@
<li>Java method arguments and argument-types of server-side
<ja>@RestMethod</ja>-annotated REST Java methods.
</ul>
<p>
- This annotation can only be applied to subclasses or parameters of type
{@link Value}.
+ This annotation can only be applied to subclasses or parameters of type
{@link org.apache.juneau.Value}.
</p>
<p>
The following examples show 3 different ways of accomplishing the same
task of setting an HTTP header
diff --git
a/juneau-doc/src/main/resources/Topics/07.juneau-rest-server/09.HttpPartAnnotations/11.ResponseStatus.html
b/juneau-doc/src/main/resources/Topics/07.juneau-rest-server/09.HttpPartAnnotations/11.ResponseStatus.html
index 2a1e962..4e41225 100644
---
a/juneau-doc/src/main/resources/Topics/07.juneau-rest-server/09.HttpPartAnnotations/11.ResponseStatus.html
+++
b/juneau-doc/src/main/resources/Topics/07.juneau-rest-server/09.HttpPartAnnotations/11.ResponseStatus.html
@@ -13,6 +13,82 @@
***************************************************************************************************************************/
-->
-{todo} @ResponseStatus
+{new} @ResponseStatus
-TODO(7.2.0)
\ No newline at end of file
+<p>
+ The {@link org.apache.juneau.http.annotation.ResponseStatus
@ResponseStatus} annotation is applied to parameters and parameter
+ types to denote them as an HTTP response status on server-side REST
method parameters.
+</p>
+<ul class='doctree'>
+ <li class='ja'>{@link org.apache.juneau.http.annotation.ResponseStatus
ResponseStatus}
+ <ul>
+ <li class='jf'>{@link
org.apache.juneau.http.annotation.ResponseStatus#api() api()} - Free-form
Swagger JSON.
+ <li class='jf'>{@link
org.apache.juneau.http.annotation.ResponseStatus#code() code()} - The HTTP
status of the response.
+ <li class='jf'>{@link
org.apache.juneau.http.annotation.ResponseStatus#description() description()} -
Description.
+ <li class='jf'>{@link
org.apache.juneau.http.annotation.ResponseStatus#value() value()} - A synonym
for <code>code</code>.
+ </ul>
+</ul>
+<p>
+ It can be used in the following locations:
+</p>
+<ul>
+ <li>Java method arguments and argument-types of server-side
<ja>@RestMethod</ja>-annotated REST Java methods.
+</ul>
+<p>
+ This can only be applied to parameters and subclasses of the {@link
org.apache.juneau.Value} class with an {@link java.lang.Integer} type.
+ <br>The {@link org.apache.juneau.Value} object is mean to be a
place-holder for the set value.
+</p>
+
+<h5 class='section'>Examples:</h5>
+<p class='bpcode w800'>
+ <jc>// Defined on parameter.</jc>
+ <ja>@RestMethod</ja>(name=<js>"GET"</js>, path=<js>"/user/login"</js>)
+ <jk>public void</jk> login(
+ <ja>@FormData</ja>(<js>"username"</js>) String username,
+ <ja>@FormData</ja>(<js>"password"</js>) String password,
+ <ja>@ResponseStatus</ja>(
+ code=401,
+ description=<js>"Invalid user/pw"</js>
+ )
+ Value<Integer> status
+ )
+ {
+ <jk>if</jk> (! isValid(username, password))
+ status.set(401);
+ }
+</p>
+<p class='bpcode w800'>
+ <jc>// Defined on parameter class.</jc>
+ <ja>@RestMethod</ja>(name=<js>"GET"</js>, path=<js>"/user/login"</js>)
+ <jk>public void</jk> login(
+ <ja>@FormData</ja>(<js>"username"</js>) String username,
+ <ja>@FormData</ja>(<js>"password"</js>) String password,
+ LoginStatus status
+ )
+ {
+ <jk>if</jk> (! isValid(username, password))
+ status.set(401);
+ }
+
+ <ja>@ResponseStatus</ja>(
+ code=401,
+ description=<js>"Invalid user/pw"</js>
+ )
+ <jk>public class</jk> LoginStatus <jk>extends</jk> Value<Integer>
{}
+</p>
+
+<p>
+ The attributes on this annotation are used to populate the generated
Swagger for the method.
+ <br>In this case, the Swagger is populated with the following:
+</p>
+<p class='bpcode w800'>
+ <jok>'/user/login'</jok>: {
+ <jok>get: {
+ <jok>responses: {
+ <jok>401</jok>: {
+ <jok>description</jok>: <jov>'Invalid
user/pw'</jov>
+ }
+ }
+ }
+ }
+</p>
diff --git
a/juneau-doc/src/main/resources/Topics/07.juneau-rest-server/09.HttpPartAnnotations/12.ResponseStatuses.html
b/juneau-doc/src/main/resources/Topics/07.juneau-rest-server/09.HttpPartAnnotations/12.ResponseStatuses.html
index 0ccb9aa..067ef96 100644
---
a/juneau-doc/src/main/resources/Topics/07.juneau-rest-server/09.HttpPartAnnotations/12.ResponseStatuses.html
+++
b/juneau-doc/src/main/resources/Topics/07.juneau-rest-server/09.HttpPartAnnotations/12.ResponseStatuses.html
@@ -13,6 +13,73 @@
***************************************************************************************************************************/
-->
-{todo} @ResponseStatuses
+{new} @ResponseStatuses
+
+<p>
+ The {@link org.apache.juneau.http.annotation.ResponseStatuses
@ResponseStatuses} annotation is used to
+ associate multiple {@link
org.apache.juneau.http.annotation.ResponseStatus @ResponseStatus} annotations
to the same parameter or class.
+</p>
+
+<h5 class='section'>Example:</h5>
+<p class='bpcode w800'>
+ <ja>@RestMethod</ja>(name=<js>"GET"</js>, path=<js>"/user/login"</js>)
+ <jk>public void</jk> login(
+ <ja>@FormData</ja>(<js>"username"</js>) String username,
+ <ja>@FormData</ja>(<js>"password"</js>) String password,
+ <ja>@ResponseStatuses=</ja>{
+ <ja>@ResponseStatus</ja>(200)
+ <ja>@ResponseStatus</ja>(code=401,
description=<js>"Invalid user/pw"</js>)
+ }
+ Value<Integer> status
+ )
+ {
+ <jk>if</jk> (! isValid(username, password))
+ status.set(401);
+ <jk>else</jk>
+ status.set(200);
+ }
+</p>
+
+<p>
+The other option is to apply this annotation to a subclass of {@link
org.apache.juneau.Value} which often leads to a cleaner
+REST method:
+</p>
+<p class='bpcode w800'>
+ <ja>@ResponseStatuses=</ja>{
+ <ja>@ResponseStatus</ja>(200)
+ <ja>@ResponseStatus</ja>(code=401, description=<js>"Invalid
user/pw"</js>)
+ }
+ <jk>public class</jk> LoginStatus <jk>extends</jk> Value<Integer>
{}
+
+ <ja>@RestMethod</ja>(name=<js>"GET"</js>, path=<js>"/user/login"</js>)
+ <jk>public void</jk> login(
+ <ja>@FormData</ja>(<js>"username"</js>) String username,
+ <ja>@FormData</ja>(<js>"password"</js>) String password,
+ LoginStatus status
+ )
+ {
+ <jk>if</jk> (! isValid(username, password))
+ status.set(401);
+ <jk>else</jk>
+ status.set(200);
+ }
+</p>
+<p>
+ The attributes on this annotation are used to populate the generated
Swagger for the method.
+ <br>In this case, the Swagger is populated with the following:
+</p>
+<p class='bpcode w800'>
+ <jok>'/user/login'</jok>: {
+ <jok>get: {
+ <jok>responses: {
+ <jok>200</jok>: {
+ <jok>description</jok>: <jov>'OK'</jov>
+ },
+ <jok>401</jok>: {
+ <jok>description</jok>: <jov>'Invalid
user/pw'</jov>
+ }
+ }
+ }
+ }
+</p>
-TODO(7.2.0)
\ No newline at end of file