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 1c6e9f7 Remove redundancy in HttpPart annotations.
1c6e9f7 is described below
commit 1c6e9f7f683e673625ee83b8d16884dde64408e6
Author: JamesBognar <[email protected]>
AuthorDate: Fri Nov 26 15:50:35 2021 -0500
Remove redundancy in HttpPart annotations.
---
.../apache/juneau/dto/swagger/ResponseInfo.java | 53 +--------
.../apache/juneau/http/annotation/Response.java | 120 ---------------------
.../juneau/http/annotation/ResponseAnnotation.java | 21 +---
.../juneau/rest/BasicSwaggerProviderSession.java | 1 -
.../http/annotation/AnnotationUtils_Test.java | 1 -
.../http/annotation/ResponseAnnotation_Test.java | 5 -
.../java/org/apache/juneau/rest/Swagger_Test.java | 106 ------------------
.../rest/annotation/Swagger_Response_Test.java | 26 -----
8 files changed, 3 insertions(+), 330 deletions(-)
diff --git
a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/swagger/ResponseInfo.java
b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/swagger/ResponseInfo.java
index 5149e9f..a8188e7 100644
---
a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/swagger/ResponseInfo.java
+++
b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/swagger/ResponseInfo.java
@@ -61,13 +61,12 @@ import org.apache.juneau.internal.*;
* <li class='link'>{@doc DtoSwagger}
* </ul>
*/
-@Bean(properties="description,schema,headers,example,examples,*")
+@Bean(properties="description,schema,headers,examples,*")
public class ResponseInfo extends SwaggerElement {
private String description;
private SchemaInfo schema;
private Map<String,HeaderInfo> headers;
- private Object example;
private Map<String,Object> examples;
/**
@@ -84,7 +83,6 @@ public class ResponseInfo extends SwaggerElement {
super(copyFrom);
this.description = copyFrom.description;
- this.example = copyFrom.example;
this.schema = copyFrom.schema == null ? null :
copyFrom.schema.copy();
if (copyFrom.examples == null)
@@ -127,8 +125,6 @@ public class ResponseInfo extends SwaggerElement {
schema = r.schema;
if (r.headers != null)
headers = r.headers;
- if (r.example != null)
- example = r.example;
if (r.examples != null)
examples = r.examples;
}
@@ -195,50 +191,6 @@ public class ResponseInfo extends SwaggerElement {
}
//-----------------------------------------------------------------------------------------------------------------
- // example
-
//-----------------------------------------------------------------------------------------------------------------
-
- /**
- * Bean property getter: <property>example</property>.
- *
- * @return The property value, or <jk>null</jk> if it is not set.
- */
- public Object getExample() {
- return example;
- }
-
- /**
- * Bean property setter: <property>example</property>.
- *
- * @param value
- * The new value for this property.
- * <br>Can be <jk>null</jk> to unset the property.
- */
- public void setExample(Object value) {
- example = value;
- }
-
- /**
- * Bean property fluent getter: <property>example</property>.
- *
- * @return The property value as an {@link Optional}. Never
<jk>null</jk>.
- */
- public Optional<Object> example() {
- return Optional.ofNullable(getExample());
- }
-
- /**
- * Bean property fluent setter: <property>example</property>.
- *
- * @param value The property value.
- * @return This object.
- */
- public ResponseInfo example(Object value) {
- setExample(value);
- return this;
- }
-
-
//-----------------------------------------------------------------------------------------------------------------
// examples
//-----------------------------------------------------------------------------------------------------------------
@@ -543,7 +495,6 @@ public class ResponseInfo extends SwaggerElement {
return null;
switch (property) {
case "description": return toType(getDescription(),
type);
- case "example": return toType(getExample(), type);
case "examples": return toType(getExamples(), type);
case "headers": return toType(getHeaders(), type);
case "schema": return toType(getSchema(), type);
@@ -557,7 +508,6 @@ public class ResponseInfo extends SwaggerElement {
return this;
switch (property) {
case "description": return
description(stringify(value));
- case "example": return example(value);
case "examples": return
examples(mapBuilder(String.class,Object.class).sparse().addAny(value).build());
case "headers": return
headers(mapBuilder(String.class,HeaderInfo.class).sparse().addAny(value).build());
case "schema": return schema(stringify(value));
@@ -571,7 +521,6 @@ public class ResponseInfo extends SwaggerElement {
public Set<String> keySet() {
ASet<String> s = ASet.<String>of()
.appendIf(description != null, "description")
- .appendIf(example != null, "example")
.appendIf(examples != null, "examples")
.appendIf(headers != null, "headers")
.appendIf(schema != null, "schema");
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 61c5676..c8c14a2 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
@@ -19,8 +19,6 @@ import java.lang.annotation.*;
import org.apache.juneau.annotation.*;
import org.apache.juneau.httppart.*;
-import org.apache.juneau.json.*;
-import org.apache.juneau.jsonschema.*;
import org.apache.juneau.oapi.*;
/**
@@ -62,129 +60,11 @@ public @interface Response {
int[] code() default {};
/**
- * A serialized example of the body of a response.
- *
- * <p>
- * This is the {@doc SimplifiedJson} of an example of the body.
- *
- * <p>
- * This value is converted to a POJO and then serialized to all the
registered serializers on the REST method to produce examples for all
- * supported language types.
- * <br>These values are then used to automatically populate the {@link
#examples} field.
- *
- * <h5 class='section'>Example:</h5>
- * <p class='bcode w800'>
- * <jc>// A JSON representation of a PetCreate object.</jc>
- * <ja>@Response</ja>(
- *
example=<js>"{name:'Doggie',price:9.99,species:'Dog',tags:['friendly','cute']}"</js>
- * )
- * </p>
- *
- * <p>
- * There are several other options for defining this example:
- * <ul class='spaced-list'>
- * <li>
- * Defining an <js>"example"</js> field in the inherited
Swagger JSON response object (classpath file or
<code><ja>@Swagger</ja>(value)</code>/<code><ja>@OpSwagger</ja>(value)</code>).
- * <li>
- * Defining an <js>"example"</js> field in the Swagger
Schema Object for the response object (including referenced <js>"$ref"</js>
schemas).
- * <li>
- * Allowing Juneau to auto-generate a code example.
- * </ul>
- *
- * <p>
- * The latter is important because Juneau also supports auto-generation
of JSON-Schema from POJO classes using {@link JsonSchemaSerializer} which has
several of it's own
- * options for auto-detecting and calculation POJO examples.
- *
- * <p>
- * In particular, examples can be defined via static methods, fields,
and annotations on the classes themselves.
- *
- * <p class='bcode w800'>
- * <jc>// Annotation on class.</jc>
- *
<ja>@Example</ja>(<js>"{name:'Doggie',price:9.99,species:'Dog',tags:['friendly','cute']}"</js>)
- * <jk>public class</jk> PetCreate {
- * ...
- * }
- * </p>
- * <p class='bcode w800'>
- * <jc>// Annotation on static method.</jc>
- * <jk>public class</jk> PetCreate {
- *
- * <ja>@Example</ja>
- * <jk>public static</jk> PetCreate <jsm>sample</jsm>() {
- * <jk>return new</jk>
PetCreate(<js>"Doggie"</js>, 9.99f, <js>"Dog"</js>, <jk>new</jk> String[]
{<js>"friendly"</js>,<js>"cute"</js>});
- * }
- * }
- * </p>
- * <p class='bcode w800'>
- * <jc>// Static method with specific name 'example'.</jc>
- * <jk>public class</jk> PetCreate {
- *
- * <jk>public static</jk> PetCreate <jsm>example</jsm>() {
- * <jk>return new</jk>
PetCreate(<js>"Doggie"</js>, 9.99f, <js>"Dog"</js>, <jk>new</jk> String[]
{<js>"friendly"</js>,<js>"cute"</js>});
- * }
- * }
- * </p>
- * <p class='bcode w800'>
- * <jc>// Static field.</jc>
- * <jk>public class</jk> PetCreate {
- *
- * <ja>@Example</ja>
- * <jk>public static</jk> PetCreate <jsf>EXAMPLE</jsf> =
<jk>new</jk> PetCreate(<js>"Doggie"</js>, 9.99f, <js>"Dog"</js>, <jk>new</jk>
String[] {<js>"friendly"</js>,<js>"cute"</js>});
- * }
- * </p>
- *
- * <p>
- * Examples can also be specified via generic properties as well using
the {@link Marshalled#example() @Marshalled(example)} annotation at either the
class or method level.
- * <p class='bcode w800'>
- * <jc>// Examples defined at class level.</jc>
- * <ja>@Rest</ja>
- * <ja>@BeanConfig</ja>(
- * applyMarshalled={
- *
<ja>@Marshalled</ja>(on=<js>"PetCreate"</js>,example=<js>"{name:'Doggie',price:9.99,species:'Dog',tags:['friendly','cute']}"</js>)
- * }
- * )
- * </p>
- *
- * <h5 class='section'>Used for:</h5>
- * <ul class='spaced-list'>
- * <li>
- * Server-side generated Swagger documentation.
- * </ul>
- *
- * <ul class='seealso'>
- * <li class='ja'>{@link Example}
- * <li class='ja'>{@link Bean#example() Bean(example)}
- * <li class='ja'>{@link Marshalled#example() Marshalled(example)}
- * <li class='jc'>{@link
org.apache.juneau.jsonschema.JsonSchemaGenerator.Builder}
- * <ul>
- * <li class='jm'>{@link
org.apache.juneau.jsonschema.JsonSchemaGenerator.Builder#addExamplesTo(TypeCategory...)
addExamplesTo(TypeCategory...)}
- * <li class='jm'>{@link
org.apache.juneau.jsonschema.JsonSchemaGenerator.Builder#allowNestedExamples()
allowNestedExamples()}
- * </ul>
- * </ul>
- *
- * <ul class='notes'>
- * <li>
- * The format is any {@doc SimplifiedJson} if the object
can be converted to a POJO using {@link JsonParser#DEFAULT} or a simple String
if the object
- * has a schema associated with it meancan be converted
from a String.
- * <br>Multiple lines are concatenated with newlines.
- * <li>
- * The format of this object can also be a simple String
if the body has a schema associated with it, meaning it's meant to be treated
as an HTTP part.
- * <li>
- * Supports {@doc RestSvlVariables} (e.g.
<js>"$L{my.localized.variable}"</js>) for the swagger generator.
- * </ul>
- */
- String[] example() default {};
-
- /**
* Serialized examples of the body of a response.
*
* <p>
* This is a {@doc SimplifiedJson} object whose keys are media types
and values are string representations of that value.
*
- * <p>
- * In general you won't need to populate this value directly since it
will automatically be calculated based on the value provided in the {@link
#example()} field.
- * <br>However, this field allows you to override the behavior and show
examples for only specified media types or different examples for different
media types.
- *
* <p class='bcode w800'>
* <jc>// A JSON representation of a PetCreate object.</jc>
* <ja>@Response</ja>(
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 b0c1c92..23dbbc3 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[] example={}, examples={};
+ String[] examples={};
/**
* Constructor.
@@ -125,17 +125,6 @@ public class ResponseAnnotation {
}
/**
- * Sets the {@link Response#example} property on this
annotation.
- *
- * @param value The new value for this property.
- * @return This object.
- */
- public Builder example(String...value) {
- this.example = value;
- return this;
- }
-
- /**
* Sets the {@link Response#examples} property on this
annotation.
*
* @param value The new value for this property.
@@ -241,12 +230,11 @@ public class ResponseAnnotation {
private final int[] code, value;
private final ResponseHeader[] headers;
private final Schema schema;
- private final String[] example, examples;
+ private final String[] examples;
Impl(Builder b) {
super(b);
this.code = Arrays.copyOf(b.code, b.code.length);
- this.example = copyOf(b.example);
this.examples = copyOf(b.examples);
this.headers = copyOf(b.headers);
this.parser = b.parser;
@@ -262,11 +250,6 @@ public class ResponseAnnotation {
}
@Override /* Response */
- public String[] example() {
- return example;
- }
-
- @Override /* Response */
public String[] examples() {
return examples;
}
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 4598a2d..ad13bb1 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
@@ -1003,7 +1003,6 @@ public class BasicSwaggerProviderSession {
if (! SchemaAnnotation.empty(a.schema()))
merge(om, a.schema());
return om
- .appendSkipEmpty("example", resolve(a.example()))
.appendSkipEmpty("examples", parseMap(a.examples()))
.appendSkipEmpty("headers", merge(om.getMap("headers"),
a.headers()))
.appendSkipEmpty("schema", merge(om.getMap("schema"),
a.schema()))
diff --git
a/juneau-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 93b050f..0c602d8 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
@@ -200,7 +200,6 @@ public class AnnotationUtils_Test {
assertTrue(ResponseAnnotation.empty((Response)null));
assertFalse(ResponseAnnotation.empty(response().code(a(0)).build()));
-
assertFalse(ResponseAnnotation.empty(response().example(a("foo")).build()));
assertFalse(ResponseAnnotation.empty(response().examples(a("foo")).build()));
assertFalse(ResponseAnnotation.empty(response().headers(new
ResponseHeader[]{responseHeader().name("foo").build()}).build()));
assertFalse(ResponseAnnotation.empty(response().parser(OpenApiParser.class).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 4cb9d0a..db2043a 100644
---
a/juneau-utest/src/test/java/org/apache/juneau/http/annotation/ResponseAnnotation_Test.java
+++
b/juneau-utest/src/test/java/org/apache/juneau/http/annotation/ResponseAnnotation_Test.java
@@ -33,7 +33,6 @@ public class ResponseAnnotation_Test {
Response a1 = ResponseAnnotation.create()
.code(1)
- .example("example")
.examples("examples")
.headers(ResponseHeaderAnnotation.DEFAULT)
.on("on")
@@ -46,7 +45,6 @@ public class ResponseAnnotation_Test {
Response a2 = ResponseAnnotation.create()
.code(1)
- .example("example")
.examples("examples")
.headers(ResponseHeaderAnnotation.DEFAULT)
.on("on")
@@ -62,7 +60,6 @@ public class ResponseAnnotation_Test {
assertObject(a1).asJson().matches(""
+ "{"
+ "code:[1],"
- + "example:['example'],"
+ "examples:['examples'],"
+ "headers:[*],"
+ "on:['on'],"
@@ -122,7 +119,6 @@ public class ResponseAnnotation_Test {
@Response(
code=1,
- example="example",
examples="examples",
headers=@ResponseHeader,
on="on",
@@ -137,7 +133,6 @@ public class ResponseAnnotation_Test {
@Response(
code=1,
- example="example",
examples="examples",
headers=@ResponseHeader,
on="on",
diff --git
a/juneau-utest/src/test/java/org/apache/juneau/rest/Swagger_Test.java
b/juneau-utest/src/test/java/org/apache/juneau/rest/Swagger_Test.java
index a93f462..608990b 100644
--- a/juneau-utest/src/test/java/org/apache/juneau/rest/Swagger_Test.java
+++ b/juneau-utest/src/test/java/org/apache/juneau/rest/Swagger_Test.java
@@ -1865,112 +1865,6 @@ public class Swagger_Test {
}
//------------------------------------------------------------------------------------------------------------------
- // /paths/<path>/<method>/responses/<response>/example
-
//------------------------------------------------------------------------------------------------------------------
-
- @Rest
- public static class Q1a {
- @RestGet(path="/path/{foo}/responses/100")
- public void a(Value<Q1c> foo) {}
- }
- @Rest
- public static class Q1b {
- @RestGet(path="/path/{foo}/responses/100")
- public Q1c a() {return null;}
- }
- @Response(code=100)
- public static class Q1c {
- public String a;
- }
-
- @Test
- public void q01a_responses_100_example_default() throws Exception {
- assertEquals(null, getSwagger(new
Q1a()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getExample());
- assertEquals("{foo:'a'}", getSwaggerWithFile(new
Q1a()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getExample());
- }
- @Test
- public void q01b_responses_100_example_default() throws Exception {
- assertEquals(null, getSwagger(new
Q1b()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getExample());
- assertEquals("{foo:'a'}", getSwaggerWithFile(new
Q1b()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getExample());
- }
-
-
@Rest(swagger=@Swagger("paths:{'/path/{foo}/responses/100':{get:{responses:{100:{example:{foo:'b'}}}}}}"))
- public static class Q2 {
- @RestGet(path="/path/{foo}/responses/100")
- public void a(@ResponseStatus Value<Integer> foo) {}
- }
-
- @Test
- public void q02_response_100_example_swaggerOnClass() throws Exception {
- assertObject(getSwagger(new
Q2()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getExample()).asJson().is("{foo:'b'}");
- assertObject(getSwaggerWithFile(new
Q2()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getExample()).asJson().is("{foo:'b'}");
- }
-
-
@Rest(swagger=@Swagger("paths:{'/path/{foo}/responses/100':{get:{responses:{100:{example:{foo:'b'}}}}}}"))
- public static class Q3 {
-
@RestGet(path="/path/{foo}/responses/100",swagger=@OpSwagger("responses:{100:{example:{foo:'c'}}}"))
- public void a(@ResponseStatus Value<Integer> foo) {}
- }
-
- @Test
- public void q03_response_100_example_swaggerOnMethod() throws Exception
{
- assertObject(getSwagger(new
Q3()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getExample()).asJson().is("{foo:'c'}");
- assertObject(getSwaggerWithFile(new
Q3()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getExample()).asJson().is("{foo:'c'}");
- }
-
-
@Rest(swagger=@Swagger("paths:{'/path/{foo}/responses/100':{get:{responses:{100:{example:{foo:'b'}}}}}}"))
- public static class Q4a {
- @RestGet(path="/path/{foo}/responses/100")
- public void a(Value<Q4c> foo) {}
- }
-
@Rest(swagger=@Swagger("paths:{'/path/{foo}/responses/100':{get:{responses:{100:{example:{foo:'b'}}}}}}"))
- public static class Q4b {
- @RestGet(path="/path/{foo}/responses/100")
- public Q4c a() {return null;}
- }
- @Response(code=100,example="{foo:'d'}")
- public static class Q4c {
- public String a;
- }
-
- @Test
- public void q04a_response_100_example_swaggerOnAnnotation() throws
Exception {
- assertEquals("{foo:'d'}", getSwagger(new
Q4a()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getExample());
- assertEquals("{foo:'d'}", getSwaggerWithFile(new
Q4a()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getExample());
- }
- @Test
- public void q04b_response_100_example_swaggerOnAnnotation() throws
Exception {
- assertEquals("{foo:'d'}", getSwagger(new
Q4b()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getExample());
- assertEquals("{foo:'d'}", getSwaggerWithFile(new
Q4b()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getExample());
- }
-
- @Rest(messages="BasicRestInfoProviderTest",
swagger=@Swagger("paths:{'/path/{foo}/responses/100':{get:{responses:{100:{example:{foo:'b'}}}}}}"))
- public static class Q5a {
- @RestGet(path="/path/{foo}/responses/100")
- public void a(Value<Q5c> foo) {}
- }
- @Rest(messages="BasicRestInfoProviderTest",
swagger=@Swagger("paths:{'/path/{foo}/responses/100':{get:{responses:{100:{example:{foo:'b'}}}}}}"))
- public static class Q5b {
- @RestGet(path="/path/{foo}/responses/100")
- public Q5c a() {return null;}
- }
- @Response(code=100,example="{foo:'$L{foo}'}")
- public static class Q5c {
- public String a;
- }
-
- @Test
- public void q05a_response_100_example_swaggerOnAnnotation_localized()
throws Exception {
- assertEquals("{foo:'l-foo'}", getSwagger(new
Q5a()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getExample());
- assertEquals("{foo:'l-foo'}", getSwaggerWithFile(new
Q5a()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getExample());
- }
- @Test
- public void q05b_response_100_example_swaggerOnAnnotation_localized()
throws Exception {
- assertEquals("{foo:'l-foo'}", getSwagger(new
Q5b()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getExample());
- assertEquals("{foo:'l-foo'}", getSwaggerWithFile(new
Q5b()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getExample());
- }
-
-
//------------------------------------------------------------------------------------------------------------------
// /paths/<path>/<method>/responses/<response>/examples
//------------------------------------------------------------------------------------------------------------------
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 de69547..27aa62b 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
@@ -38,7 +38,6 @@ public class Swagger_Response_Test {
@Response(
schema=@Schema(description={"a","b"},type="string"),
headers=@ResponseHeader(name="foo",schema=@Schema(type="string")),
- example="'a'",
examples=" {foo:'a'} "
)
public static class A1 {
@@ -52,7 +51,6 @@ public class Swagger_Response_Test {
@Response(
schema=@Schema(description="a\nb",type="string"),
headers=@ResponseHeader(name="foo",schema=@Schema(type="string")),
- example="'a'",
examples=" {foo:'a'} "
)
public static class A2 {
@@ -66,7 +64,6 @@ public class Swagger_Response_Test {
@Response(
schema=@Schema(description={"a","b"},type="string"),
headers=@ResponseHeader(name="foo",schema=@Schema(type="string")),
- example="'a'",
examples=" {foo:'a'} "
)
public static class A3 {
@@ -108,42 +105,36 @@ 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());
assertObject(x.getExamples()).asJson().is("{foo:'a'}");
x = s.getResponseInfo("/b","put",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());
assertObject(x.getExamples()).asJson().is("{foo:'a'}");
x = s.getResponseInfo("/c","post",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());
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());
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("{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("{foo:{type:'string'}}");
- assertEquals("'a'", x.getExample());
assertObject(x.getExamples()).asJson().is("{foo:'a'}");
x = s.getResponseInfo("/g","get",100);
@@ -234,7 +225,6 @@ public class Swagger_Response_Test {
@Rest
public static class C {
- @Response(example="{f1:'a'}")
public static class C1 {
public String f1;
}
@@ -259,10 +249,8 @@ public class Swagger_Response_Test {
ResponseInfo x;
x = sc.getResponseInfo("/a","get",200);
- assertEquals("{f1:'a'}", x.getExample());
x = sc.getResponseInfo("/b","put",200);
- assertEquals("{f1:'a'}", x.getExample());
x = sc.getResponseInfo("/c","post",200);
assertObject(x.getExamples()).asJson().is("{foo:'b'}");
@@ -277,7 +265,6 @@ public class Swagger_Response_Test {
@Response(
schema=@Schema(description={"a","b"},type="string"),
headers=@ResponseHeader(name="foo",schema=@Schema(type="string")),
- example=" 'a' ",
examples=" {foo:'a'} "
)
public static class D1 extends Throwable {}
@@ -287,7 +274,6 @@ public class Swagger_Response_Test {
@Response(
schema=@Schema(description={"a","b"},type="string"),
headers=@ResponseHeader(name="foo",schema=@Schema(type="string")),
- example=" 'a' ",
examples=" {foo:'a'} "
)
public static class D2 extends Throwable {}
@@ -297,7 +283,6 @@ public class Swagger_Response_Test {
@Response(
schema=@Schema(description={"a","b"},type="string"),
headers=@ResponseHeader(name="foo",schema=@Schema(type="string")),
- example=" 'a' ",
examples=" {foo:'a'} "
)
public static class D3 extends Throwable {}
@@ -329,21 +314,18 @@ 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());
assertObject(x.getExamples()).asJson().is("{foo:'a'}");
x = s.getResponseInfo("/b","put",500);
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.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("{foo:{type:'string'}}");
- assertEquals("'a'", x.getExample());
assertObject(x.getExamples()).asJson().is("{foo:'a'}");
x = s.getResponseInfo("/d","delete",100);
@@ -380,11 +362,6 @@ public class Swagger_Response_Test {
@Rest
public static class F {
- @Response(example={" {f1:'b'} "})
- public static class F1 extends Throwable {}
- @RestGet
- public void a() throws F1 {}
-
@Response(examples={" foo:'b' "})
public static class F2 extends Throwable {}
@RestPut
@@ -396,9 +373,6 @@ public class Swagger_Response_Test {
org.apache.juneau.dto.swagger.Swagger s = getSwagger(F.class);
ResponseInfo x;
- x = s.getResponseInfo("/a","get",500);
- assertEquals("{f1:'b'}", x.getExample());
-
x = s.getResponseInfo("/b","put",500);
assertObject(x.getExamples()).asJson().is("{foo:'b'}");
}