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 dd3289e  Remove redundancy in HttpPart annotations.
dd3289e is described below

commit dd3289ed657689ffb81d6ee1c87d6ec314135a63
Author: JamesBognar <[email protected]>
AuthorDate: Mon Nov 22 13:27:39 2021 -0500

    Remove redundancy in HttpPart annotations.
---
 .../apache/juneau/http/annotation/Response.java    | 86 ----------------------
 .../juneau/http/annotation/ResponseAnnotation.java | 21 +-----
 .../juneau/rest/BasicSwaggerProviderSession.java   |  2 -
 .../http/annotation/AnnotationUtils_Test.java      |  1 -
 .../http/annotation/ResponseAnnotation_Test.java   |  5 --
 .../rest/annotation/Swagger_Response_Test.java     | 50 ++++---------
 6 files changed, 18 insertions(+), 147 deletions(-)

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 0f6895a..4404bf0 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
@@ -56,92 +56,6 @@ import org.apache.juneau.oapi.*;
 public @interface Response {
 
        /**
-        * Free-form value for the {@doc ExtSwaggerResponseObject}.
-        *
-        * <p>
-        * This is a {@doc SimplifiedJson} object that makes up the swagger 
information for this field.
-        *
-        * <p>
-        * The following are completely equivalent ways of defining the swagger 
description of the Response object:
-        * <p class='bcode w800'>
-        *      <jc>// Normal</jc>
-        *      <ja>@Response</ja>(
-        *              code=302,
-        *              description=<js>"Redirect"</js>,
-        *              headers={
-        *                      <ja>@ResponseHeader</ja>(
-        *                              name=<js>"Location"</js>,
-        *                              type=<js>"string"</js>,
-        *                              format=<js>"uri"</js>
-        *                      )
-        *              }
-        *      )
-        * </p>
-        * <p class='bcode w800'>
-        *      <jc>// Free-form</jc>
-        *      <ja>@Response</ja>(
-        *              code=302,
-        *              api={
-        *                      <js>"description: 'Redirect',"</js>,
-        *                      <js>"headers: {"</js>,
-        *                              <js>"Location: {"</js>,
-        *                                      <js>"type: 'string',"</js>,
-        *                                      <js>"format: 'uri'"</js>,
-        *                              <js>"}"</js>,
-        *                      <js>"}"</js>
-        *              }
-        *      )
-        * </p>
-        * <p class='bcode w800'>
-        *      <jc>// Free-form using variables</jc>
-        *      <ja>@Response</ja>(
-        *              code=302,
-        *              api=<js>"$L{redirectSwagger}"</js>
-        *      )
-        * </p>
-        * <p class='bcode w800'>
-        *      <mc>// Contents of MyResource.properties</mc>
-        *      <mk>redirectSwagger</mk> = <mv>{ description: "Redirect", 
headers: { Location: { type: "string", format: "uri" } } }</mv>
-        * </p>
-        *
-        * <p>
-        *      The reasons why you may want to use this field include:
-        * <ul>
-        *      <li>You want to pull in the entire Swagger JSON definition for 
this field from an external source such as a properties file.
-        *      <li>You want to add extra fields to the Swagger documentation 
that are not officially part of the Swagger specification.
-        * </ul>
-        *
-        * <h5 class='section'>Used for:</h5>
-        * <ul class='spaced-list'>
-        *      <li>
-        *              Server-side generated Swagger documentation.
-        * </ul>
-        *
-        * <ul class='notes'>
-        *      <li>
-        *              Note that the only swagger field you can't specify 
using this value is <js>"code"</js> whose value needs to be known during 
servlet initialization.
-        *      <li>
-        *              The format is a {@doc SimplifiedJson} object.
-        *      <li>
-        *              The leading/trailing <c>{ }</c> characters are optional.
-        *              <br>The following two example are considered equivalent:
-        *              <p class='bcode w800'>
-        *      <ja>@Response</ja>(api=<js>"{description: 'Redirect'}"</js>)
-        *              </p>
-        *              <p class='bcode w800'>
-        *      <ja>@Response</ja>(api=<js>"description: 'Redirect''"</js>)
-        *              </p>
-        *      <li>
-        *              Multiple lines are concatenated with newlines so that 
you can format the value to be readable.
-        *      <li>
-        *              Supports {@doc RestSvlVariables} (e.g. 
<js>"$L{my.localized.variable}"</js>) for the swagger generator.
-        *      <li>
-        *              Values defined in this field supersede values pulled 
from the Swagger JSON file and are superseded by individual values defined on 
this annotation.
-        * </ul>
-        */
-       String[] api() default {};
-
-       /**
         * The HTTP response code.
         *
         * The default value is <c>500</c> for exceptions and <c>200</c> for 
return types.
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 3d8ee9b..3b90982 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[] api={}, d={}, description={}, ex={}, example={}, 
examples={}, exs={};
+               String[] d={}, description={}, ex={}, example={}, examples={}, 
exs={};
 
                /**
                 * Constructor.
@@ -114,17 +114,6 @@ public class ResponseAnnotation {
                }
 
                /**
-                * Sets the {@link Response#api} property on this annotation.
-                *
-                * @param value The new value for this property.
-                * @return This object.
-                */
-               public Builder api(String...value) {
-                       this.api = value;
-                       return this;
-               }
-
-               /**
                 * Sets the {@link Response#code} property on this annotation.
                 *
                 * @param value The new value for this property.
@@ -296,11 +285,10 @@ public class ResponseAnnotation {
                private final int[] code, value;
                private final ResponseHeader[] headers;
                private final Schema schema;
-               private final String[] api, d, description, ex, example, 
examples, exs;
+               private final String[] d, description, ex, example, examples, 
exs;
 
                Impl(Builder b) {
                        super(b);
-                       this.api = copyOf(b.api);
                        this.code = Arrays.copyOf(b.code, b.code.length);
                        this.d = copyOf(b.d);
                        this.description = copyOf(b.description);
@@ -317,11 +305,6 @@ public class ResponseAnnotation {
                }
 
                @Override /* Response */
-               public String[] api() {
-                       return api;
-               }
-
-               @Override /* Response */
                public int[] code() {
                        return code;
                }
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 e802703..d4a0c3a 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
@@ -1092,8 +1092,6 @@ public class BasicSwaggerProviderSession {
                if (ResponseAnnotation.empty(a))
                        return om;
                om = newMap(om);
-               if (a.api().length > 0)
-                       om.putAll(parseMap(a.api()));
                return om
                        .appendSkipEmpty("description", 
resolve(a.description(), a.d()))
                        .appendSkipEmpty("example", resolve(a.example(), 
a.ex()))
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 8d7d742..01413c4 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
@@ -219,7 +219,6 @@ public class AnnotationUtils_Test {
                assertTrue(ResponseAnnotation.empty(response().build()));
                assertTrue(ResponseAnnotation.empty((Response)null));
 
-               
assertFalse(ResponseAnnotation.empty(response().api(a("foo")).build()));
                
assertFalse(ResponseAnnotation.empty(response().code(a(0)).build()));
                
assertFalse(ResponseAnnotation.empty(response().d(a("foo")).build()));
                
assertFalse(ResponseAnnotation.empty(response().description(a("foo")).build()));
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 920a486..e106a80 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
@@ -32,7 +32,6 @@ public class ResponseAnnotation_Test {
        
//------------------------------------------------------------------------------------------------------------------
 
        Response a1 = ResponseAnnotation.create()
-               .api("api")
                .code(1)
                .d("d")
                .description("description")
@@ -50,7 +49,6 @@ public class ResponseAnnotation_Test {
                .build();
 
        Response a2 = ResponseAnnotation.create()
-               .api("api")
                .code(1)
                .d("d")
                .description("description")
@@ -71,7 +69,6 @@ public class ResponseAnnotation_Test {
        public void a01_basic() {
                assertObject(a1).asJson().matches(""
                        + "{"
-                               + "api:['api'],"
                                + "code:[1],"
                                + "d:['d'],"
                                + "description:['description'],"
@@ -136,7 +133,6 @@ public class ResponseAnnotation_Test {
        
//------------------------------------------------------------------------------------------------------------------
 
        @Response(
-               api="api",
                code=1,
                d="d",
                description="description",
@@ -156,7 +152,6 @@ public class ResponseAnnotation_Test {
        Response d1 = D1.class.getAnnotationsByType(Response.class)[0];
 
        @Response(
-               api="api",
                code=1,
                d="d",
                description="description",
diff --git 
a/juneau-utest/src/test/java/org/apache/juneau/rest/annotation/Swagger_Response_Test.java
 
b/juneau-utest/src/test/java/org/apache/juneau/rest/annotation/Swagger_Response_Test.java
index 4223d8a..a58f889 100644
--- 
a/juneau-utest/src/test/java/org/apache/juneau/rest/annotation/Swagger_Response_Test.java
+++ 
b/juneau-utest/src/test/java/org/apache/juneau/rest/annotation/Swagger_Response_Test.java
@@ -51,13 +51,11 @@ public class Swagger_Response_Test {
                public A1 b() {return null;}
 
                @Response(
-                       api={
-                               "description:'a\nb',",
-                               "schema:{type:'string'},",
-                               "headers:{foo:{type:'string'}},",
-                               "example:'a',",
-                               "examples:{foo:'a'}"
-                       }
+                       description="a\nb",
+                       schema=@Schema(type="string"),
+                       
headers=@ResponseHeader(name="foo",schema=@Schema(type="string")),
+                       example="'a'",
+                       examples=" {foo:'a'} "
                )
                public static class A2 {
                        public A2(String x){}
@@ -68,13 +66,6 @@ public class Swagger_Response_Test {
                public A2 d() {return null;}
 
                @Response(
-                       api={
-                               "description:'b',",
-                               "schema:{type:'number'},",
-                               "headers:{bar:{type:'number'}},",
-                               "example:'b',",
-                               "examples:{bar:'b'}"
-                       },
                        description={"a","b"},
                        schema=@Schema(type="string"),
                        
headers=@ResponseHeader(name="foo",schema=@Schema(type="string")),
@@ -134,27 +125,27 @@ public class Swagger_Response_Test {
                assertEquals("a\nb", x.getDescription());
                assertObject(x.getSchema()).asJson().is("{type:'string'}");
                
assertObject(x.getHeaders()).asJson().is("{foo:{type:'string'}}");
-               assertEquals("a", x.getExample());
+               assertEquals("'a'", x.getExample());
                assertObject(x.getExamples()).asJson().is("{foo:'a'}");
 
                x = s.getResponseInfo("/d","delete",200);
                assertEquals("a\nb", x.getDescription());
                assertObject(x.getSchema()).asJson().is("{type:'string'}");
                
assertObject(x.getHeaders()).asJson().is("{foo:{type:'string'}}");
-               assertEquals("a", x.getExample());
+               assertEquals("'a'", x.getExample());
                assertObject(x.getExamples()).asJson().is("{foo:'a'}");
 
                x = s.getResponseInfo("/e","get",200);
                assertEquals("a\nb", x.getDescription());
                assertObject(x.getSchema()).asJson().is("{type:'string'}");
-               
assertObject(x.getHeaders()).asJson().is("{bar:{type:'number'},foo:{type:'string'}}");
+               
assertObject(x.getHeaders()).asJson().is("{foo:{type:'string'}}");
                assertEquals("'a'", x.getExample());
                assertObject(x.getExamples()).asJson().is("{foo:'a'}");
 
                x = s.getResponseInfo("/f","get",200);
                assertEquals("a\nb", x.getDescription());
                assertObject(x.getSchema()).asJson().is("{type:'string'}");
-               
assertObject(x.getHeaders()).asJson().is("{bar:{type:'number'},foo:{type:'string'}}");
+               
assertObject(x.getHeaders()).asJson().is("{foo:{type:'string'}}");
                assertEquals("'a'", x.getExample());
                assertObject(x.getExamples()).asJson().is("{foo:'a'}");
 
@@ -298,26 +289,17 @@ public class Swagger_Response_Test {
                public void a() throws D1 {}
 
                @Response(
-                       api={
-                               "description:'a\nb',",
-                               "schema:{type:'string'},",
-                               "headers:{foo:{type:'string'}},",
-                               "example:'a',",
-                               "examples:{foo:'a'}"
-                       }
+                       description= {"a","b"},
+                       schema=@Schema(type="string"),
+                       
headers=@ResponseHeader(name="foo",schema=@Schema(type="string")),
+                       example=" 'a' ",
+                       examples=" {foo:'a'} "
                )
                public static class D2 extends Throwable {}
                @RestPut
                public void b() throws D2 {}
 
                @Response(
-                       api={
-                               "description:'b',",
-                               "schema:{type:'number'},",
-                               "headers:{bar:{type:'number'}},",
-                               "example:'b',",
-                               "examples:{bar:'b'}"
-                       },
                        description= {"a","b"},
                        schema=@Schema(type="string"),
                        
headers=@ResponseHeader(name="foo",schema=@Schema(type="string")),
@@ -360,13 +342,13 @@ public class Swagger_Response_Test {
                assertEquals("a\nb", x.getDescription());
                assertObject(x.getSchema()).asJson().is("{type:'string'}");
                
assertObject(x.getHeaders()).asJson().is("{foo:{type:'string'}}");
-               assertObject(x.getExample()).asJson().is("'a'");
+               assertObject(x.getExample()).asJson().is("'\\'a\\''");
                assertObject(x.getExamples()).asJson().is("{foo:'a'}");
 
                x = s.getResponseInfo("/c","post",500);
                assertEquals("a\nb", x.getDescription());
                assertObject(x.getSchema()).asJson().is("{type:'string'}");
-               
assertObject(x.getHeaders()).asJson().is("{bar:{type:'number'},foo:{type:'string'}}");
+               
assertObject(x.getHeaders()).asJson().is("{foo:{type:'string'}}");
                assertEquals("'a'", x.getExample());
                assertObject(x.getExamples()).asJson().is("{foo:'a'}");
 

Reply via email to