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/26 16:39:57 UTC
[juneau] branch master updated: New oapi package.
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 b58c65d New oapi package.
b58c65d is described below
commit b58c65db629addc8ba93722b85e55c9d69a72bf2
Author: JamesBognar <ja...@apache.org>
AuthorDate: Sun Aug 26 12:39:39 2018 -0400
New oapi package.
---
.../http/annotation/AnnotationUtilsTest.java | 46 --
.../juneau/httppart/OpenApiPartParserTest.java | 3 +-
.../juneau/httppart/OpenApiPartSerializerTest.java | 33 +-
.../apache/juneau/httppart/UonPartParserTest.java | 7 +-
.../juneau/transforms/LocalizedDatesTest.java | 2 +-
.../java/org/apache/juneau/xml/XmlContentTest.java | 8 +-
.../java/org/apache/juneau/dto/LinkString.java | 3 +-
.../main/java/org/apache/juneau/BeanSession.java | 13 +
.../java/org/apache/juneau/BeanSessionArgs.java | 8 +-
.../juneau/http/annotation/AnnotationUtils.java | 54 --
.../org/apache/juneau/http/annotation/Body.java | 32 --
.../apache/juneau/http/annotation/FormData.java | 5 +-
.../org/apache/juneau/http/annotation/Header.java | 5 +-
.../org/apache/juneau/http/annotation/Items.java | 4 +-
.../org/apache/juneau/http/annotation/Path.java | 5 +-
.../org/apache/juneau/http/annotation/Query.java | 5 +-
.../org/apache/juneau/http/annotation/Request.java | 5 +-
.../apache/juneau/http/annotation/Response.java | 21 +-
.../juneau/http/annotation/ResponseHeader.java | 3 +-
.../org/apache/juneau/http/annotation/Schema.java | 4 +-
...ializerSession.java => BaseHttpPartParser.java} | 36 +-
...Session.java => BaseHttpPartParserSession.java} | 73 +--
...zerSession.java => BaseHttpPartSerializer.java} | 27 +-
...ion.java => BaseHttpPartSerializerSession.java} | 22 +-
.../java/org/apache/juneau/httppart/HttpPart.java | 4 +-
.../org/apache/juneau/httppart/HttpPartParser.java | 44 +-
.../juneau/httppart/HttpPartParserSession.java | 46 ++
.../org/apache/juneau/httppart/HttpPartSchema.java | 39 +-
.../juneau/httppart/HttpPartSchemaBuilder.java | 43 +-
.../apache/juneau/httppart/HttpPartSerializer.java | 15 +-
.../juneau/httppart/HttpPartSerializerSession.java | 14 +
.../apache/juneau/httppart/OpenApiPartParser.java | 132 -----
.../juneau/httppart/OpenApiPartParserBuilder.java | 501 ----------------
.../juneau/httppart/OpenApiPartSerializer.java | 131 -----
.../httppart/OpenApiPartSerializerBuilder.java | 639 ---------------------
.../apache/juneau/httppart/SimplePartParser.java | 31 +-
.../juneau/httppart/SimplePartParserSession.java | 2 +-
.../juneau/httppart/SimplePartSerializer.java | 22 +-
.../httppart/SimplePartSerializerSession.java | 2 +-
.../httppart/SimpleUonPartSerializerBuilder.java | 639 ---------------------
.../org/apache/juneau/httppart/UonPartParser.java | 118 ----
.../juneau/httppart/UonPartParserSession.java | 132 -----
.../juneau/httppart/UonPartSerializerSession.java | 65 ---
.../juneau/httppart/bean/ResponseBeanMeta.java | 13 -
.../org/apache/juneau/internal/ClassUtils.java | 10 +
.../org/apache/juneau/internal/TransformCache.java | 15 +-
.../OpenApiParser.java} | 74 +--
.../OpenApiParserBuilder.java} | 160 +++---
.../OpenApiParserSession.java} | 14 +-
.../OpenApiSerializer.java} | 87 ++-
.../OpenApiSerializerBuilder.java} | 202 +++----
.../OpenApiSerializerSession.java} | 62 +-
.../apache/juneau/parser/ParserSessionArgs.java | 8 +-
.../juneau/serializer/SerializerSessionArgs.java | 8 +-
.../main/java/org/apache/juneau/uon/UonParser.java | 44 +-
.../org/apache/juneau/uon/UonParserSession.java | 53 +-
.../java/org/apache/juneau/uon/UonSerializer.java | 23 +-
.../apache/juneau/uon/UonSerializerSession.java | 37 +-
.../src/main/resources/ReleaseNotes/7.2.0.html | 13 +
.../rest/test/client/RequestBeanProxyTest.java | 65 +--
.../rest/test/client/ThirdPartyProxyTest.java | 14 +-
.../apache/juneau/rest/client/NameValuePairs.java | 3 +-
.../org/apache/juneau/rest/client/RestCall.java | 129 ++---
.../org/apache/juneau/rest/client/RestClient.java | 17 +-
.../juneau/rest/client/RestClientBuilder.java | 20 +-
.../juneau/rest/client/RestRequestEntity.java | 9 +-
.../rest/client/SerializedNameValuePair.java | 5 +-
.../juneau/rest/client/remote/RemoteMethodArg.java | 2 -
.../rest/client/remote/BodyAnnotationTest.java | 73 ++-
.../client/remote/RemoteMethodAnnotationTest.java | 17 +-
.../org/apache/juneau/rest/jaxrs/BaseProvider.java | 4 +-
.../org/apache/juneau/rest/BasicRestConfig.java | 3 +
.../java/org/apache/juneau/rest/RequestBody.java | 61 +-
.../org/apache/juneau/rest/RequestFormData.java | 15 +-
.../org/apache/juneau/rest/RequestHeaders.java | 9 +-
.../java/org/apache/juneau/rest/RequestPath.java | 7 +-
.../java/org/apache/juneau/rest/RequestQuery.java | 13 +-
.../java/org/apache/juneau/rest/RestContext.java | 17 +-
.../org/apache/juneau/rest/RestContextBuilder.java | 43 +-
.../org/apache/juneau/rest/RestJavaMethod.java | 10 +-
.../org/apache/juneau/rest/RestParamDefaults.java | 4 +-
.../java/org/apache/juneau/rest/RestRequest.java | 14 +-
.../java/org/apache/juneau/rest/RestResponse.java | 2 +-
.../org/apache/juneau/rest/SwaggerGenerator.java | 32 +-
.../apache/juneau/rest/annotation/RestMethod.java | 22 +
.../juneau/rest/annotation/RestResource.java | 36 ++
.../juneau/rest/reshandlers/DefaultHandler.java | 38 +-
.../apache/juneau/rest/widget/MenuItemWidget.java | 2 +-
.../juneau/rest/BasicRestInfoProviderTest.java | 2 +-
.../juneau/rest/annotation/BodyAnnotationTest.java | 14 +-
.../rest/annotation/ResponseAnnotationTest.java | 351 +----------
.../juneau/rest/testutils/XPartSerializer.java | 14 +-
92 files changed, 1160 insertions(+), 3773 deletions(-)
diff --git a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/http/annotation/AnnotationUtilsTest.java b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/http/annotation/AnnotationUtilsTest.java
index 684e09a..b1ab4d7 100644
--- a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/http/annotation/AnnotationUtilsTest.java
+++ b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/http/annotation/AnnotationUtilsTest.java
@@ -20,7 +20,6 @@ import static org.apache.juneau.http.annotation.AnnotationUtils.*;
import java.lang.annotation.*;
import java.lang.reflect.*;
-import org.apache.juneau.httppart.*;
import org.junit.*;
import org.junit.runners.*;
@@ -137,49 +136,4 @@ public class AnnotationUtilsTest {
assertFalse(allMinusOne(-1l,0l));
assertFalse(allMinusOne(0l));
}
-
- @Body public static class C01a {}
- @Body(usePartParser=true) public static class C01b {}
- @Body(schema=@Schema) public static class C01c {}
- @Body(schema=@Schema(description="foo")) public static class C01d {}
- @Body(partParser=OpenApiPartParser.class) public static class C01e {}
-
- @Test
- public void usePartParserBody() {
- assertFalse(usePartParser(C01a.class.getAnnotation(Body.class)));
- assertTrue(usePartParser(C01b.class.getAnnotation(Body.class)));
- assertFalse(usePartParser(C01c.class.getAnnotation(Body.class)));
- assertTrue(usePartParser(C01d.class.getAnnotation(Body.class)));
- assertTrue(usePartParser(C01e.class.getAnnotation(Body.class)));
- }
-
- @Body public static class D01a {}
- @Body(usePartSerializer=true) public static class D01b {}
- @Body(schema=@Schema) public static class D01c {}
- @Body(schema=@Schema(description="foo")) public static class D01d {}
- @Body(partSerializer=OpenApiPartSerializer.class) public static class D01e {}
-
- @Test
- public void usePartSerializerBody() {
- assertFalse(usePartSerializer(D01a.class.getAnnotation(Body.class)));
- assertTrue(usePartSerializer(D01b.class.getAnnotation(Body.class)));
- assertFalse(usePartSerializer(D01c.class.getAnnotation(Body.class)));
- assertTrue(usePartSerializer(D01d.class.getAnnotation(Body.class)));
- assertTrue(usePartSerializer(D01e.class.getAnnotation(Body.class)));
- }
-
- @Response public static class F01a {}
- @Response(usePartSerializer=true) public static class F01b {}
- @Response(schema=@Schema) public static class F01c {}
- @Response(schema=@Schema(description="foo")) public static class F01d {}
- @Response(partSerializer=OpenApiPartSerializer.class) public static class F01e {}
-
- @Test
- public void usePartSerializerResponse() {
- assertFalse(usePartSerializer(F01a.class.getAnnotation(Response.class)));
- assertTrue(usePartSerializer(F01b.class.getAnnotation(Response.class)));
- assertFalse(usePartSerializer(F01c.class.getAnnotation(Response.class)));
- assertTrue(usePartSerializer(F01d.class.getAnnotation(Response.class)));
- assertTrue(usePartSerializer(F01e.class.getAnnotation(Response.class)));
- }
}
\ No newline at end of file
diff --git a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/httppart/OpenApiPartParserTest.java b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/httppart/OpenApiPartParserTest.java
index 38b97ca..30d61ba 100644
--- a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/httppart/OpenApiPartParserTest.java
+++ b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/httppart/OpenApiPartParserTest.java
@@ -22,13 +22,14 @@ import java.util.*;
import org.apache.juneau.*;
import org.apache.juneau.internal.*;
import org.apache.juneau.json.*;
+import org.apache.juneau.oapi.*;
import org.junit.*;
import org.junit.runners.*;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class OpenApiPartParserTest {
- static OpenApiPartParserSession p = OpenApiPartParser.DEFAULT.createSession();
+ static OpenApiParserSession p = OpenApiParser.DEFAULT.createSession();
//-----------------------------------------------------------------------------------------------------------------
// Input validations
diff --git a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/httppart/OpenApiPartSerializerTest.java b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/httppart/OpenApiPartSerializerTest.java
index b6e5f9e..e9d85cb 100644
--- a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/httppart/OpenApiPartSerializerTest.java
+++ b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/httppart/OpenApiPartSerializerTest.java
@@ -20,6 +20,7 @@ import java.util.*;
import org.apache.juneau.*;
import org.apache.juneau.internal.*;
+import org.apache.juneau.oapi.*;
import org.apache.juneau.utils.*;
import org.junit.*;
import org.junit.runners.*;
@@ -27,7 +28,7 @@ import org.junit.runners.*;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class OpenApiPartSerializerTest {
- static OpenApiPartSerializerSession s = OpenApiPartSerializer.DEFAULT.createSession();
+ static OpenApiSerializerSession s = OpenApiSerializer.DEFAULT.createSession();
//-----------------------------------------------------------------------------------------------------------------
// Input validations
@@ -1088,96 +1089,96 @@ public class OpenApiPartSerializerTest {
//-----------------------------------------------------------------------------------------------------------------
@Test
public void i01a_noSchemaTests_Integer() throws Exception {
- HttpPartSerializer s = OpenApiPartSerializer.DEFAULT;
+ HttpPartSerializer s = OpenApiSerializer.DEFAULT;
for (Integer v : AList.create(new Integer(1), Integer.MAX_VALUE, Integer.MIN_VALUE))
assertEquals(valueOf(v), s.serialize(null, v));
}
@Test
public void i01b_noSchemaTests_IntegerArray() throws Exception {
- HttpPartSerializer s = OpenApiPartSerializer.DEFAULT;
+ HttpPartSerializer s = OpenApiSerializer.DEFAULT;
assertEquals("1,2147483647,-2147483648", s.serialize(null, new Integer[]{new Integer(1), Integer.MAX_VALUE, Integer.MIN_VALUE}));
}
@Test
public void i02a_noSchemaTests_Short() throws Exception {
- HttpPartSerializer s = OpenApiPartSerializer.DEFAULT;
+ HttpPartSerializer s = OpenApiSerializer.DEFAULT;
for (Short v : AList.create(new Short((short)1), Short.MAX_VALUE, Short.MIN_VALUE))
assertEquals(valueOf(v), s.serialize(null, v));
}
@Test
public void i02b_noSchemaTests_ShortArray() throws Exception {
- HttpPartSerializer s = OpenApiPartSerializer.DEFAULT;
+ HttpPartSerializer s = OpenApiSerializer.DEFAULT;
assertEquals("1,32767,-32768,null", s.serialize(null, new Short[]{new Short((short)1), Short.MAX_VALUE, Short.MIN_VALUE, null}));
}
@Test
public void i03a_noSchemaTests_Long() throws Exception {
- HttpPartSerializer s = OpenApiPartSerializer.DEFAULT;
+ HttpPartSerializer s = OpenApiSerializer.DEFAULT;
for (Long v : AList.create(new Long(1), Long.MAX_VALUE, Long.MIN_VALUE))
assertEquals(valueOf(v), s.serialize(null, v));
}
@Test
public void i03b_noSchemaTests_LongArray() throws Exception {
- HttpPartSerializer s = OpenApiPartSerializer.DEFAULT;
+ HttpPartSerializer s = OpenApiSerializer.DEFAULT;
assertEquals("1,9223372036854775807,-9223372036854775808,null", s.serialize(null, new Long[]{new Long(1), Long.MAX_VALUE, Long.MIN_VALUE, null}));
}
@Test
public void i04a_noSchemaTests_Float() throws Exception {
- HttpPartSerializer s = OpenApiPartSerializer.DEFAULT;
+ HttpPartSerializer s = OpenApiSerializer.DEFAULT;
for (Float v : AList.create(new Float(1f), Float.MAX_VALUE, Float.MIN_VALUE))
assertEquals(valueOf(v), s.serialize(null, v));
}
@Test
public void i04b_noSchemaTests_FloatArray() throws Exception {
- HttpPartSerializer s = OpenApiPartSerializer.DEFAULT;
+ HttpPartSerializer s = OpenApiSerializer.DEFAULT;
assertEquals("1.0,3.4028235E38,1.4E-45", s.serialize(null, new Float[]{new Float(1f), Float.MAX_VALUE, Float.MIN_VALUE}));
}
@Test
public void i05a_noSchemaTests_Double() throws Exception {
- HttpPartSerializer s = OpenApiPartSerializer.DEFAULT;
+ HttpPartSerializer s = OpenApiSerializer.DEFAULT;
for (Double v : AList.create(new Double(1d), Double.MAX_VALUE, Double.MIN_VALUE))
assertEquals(valueOf(v), s.serialize(null, v));
}
@Test
public void i05b_noSchemaTests_DoubleArray() throws Exception {
- HttpPartSerializer s = OpenApiPartSerializer.DEFAULT;
+ HttpPartSerializer s = OpenApiSerializer.DEFAULT;
assertEquals("1.0,1.7976931348623157E308,4.9E-324", s.serialize(null, new Double[]{new Double(1), Double.MAX_VALUE, Double.MIN_VALUE}));
}
@Test
public void i06a_noSchemaTests_Boolean() throws Exception {
- HttpPartSerializer s = OpenApiPartSerializer.DEFAULT;
+ HttpPartSerializer s = OpenApiSerializer.DEFAULT;
for (Boolean v : AList.create(Boolean.TRUE, Boolean.FALSE))
assertEquals(valueOf(v), s.serialize(null, v));
}
@Test
public void i06b_noSchemaTests_BooleanArray() throws Exception {
- HttpPartSerializer s = OpenApiPartSerializer.DEFAULT;
+ HttpPartSerializer s = OpenApiSerializer.DEFAULT;
assertEquals("true,false,null", s.serialize(null, new Boolean[]{Boolean.TRUE, Boolean.FALSE, null}));
}
@Test
public void i07_noSchemaTests_Null() throws Exception {
- HttpPartSerializer s = OpenApiPartSerializer.DEFAULT;
+ HttpPartSerializer s = OpenApiSerializer.DEFAULT;
assertEquals("null", s.serialize(null, null));
}
@Test
public void i08a_noSchemaTests_String() throws Exception {
- HttpPartSerializer s = OpenApiPartSerializer.DEFAULT;
+ HttpPartSerializer s = OpenApiSerializer.DEFAULT;
for (String v : AList.create("foo", "", null))
assertEquals(valueOf(v), s.serialize(null, v));
}
@Test
public void i08b_noSchemaTests_StringArray() throws Exception {
- HttpPartSerializer s = OpenApiPartSerializer.DEFAULT;
+ HttpPartSerializer s = OpenApiSerializer.DEFAULT;
assertEquals("foo,,null", s.serialize(null, new String[]{"foo", "", null}));
}
diff --git a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/httppart/UonPartParserTest.java b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/httppart/UonPartParserTest.java
index 9bffad8..5f5d169 100644
--- a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/httppart/UonPartParserTest.java
+++ b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/httppart/UonPartParserTest.java
@@ -18,6 +18,7 @@ import java.util.*;
import org.apache.juneau.*;
import org.apache.juneau.json.*;
+import org.apache.juneau.uon.*;
import org.junit.*;
import org.junit.runners.*;
@@ -25,7 +26,7 @@ import org.junit.runners.*;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class UonPartParserTest {
- static UonPartParserSession p = UonPartParser.DEFAULT.createSession();
+ static UonParserSession p = UonParser.DEFAULT.createSession();
static BeanSession bs = p;
//====================================================================================================
@@ -250,7 +251,7 @@ public class UonPartParserTest {
//====================================================================================================
@Test
public void testSimpleBean() throws Exception {
- UonPartParserSession p = UonPartParser.DEFAULT.createSession();
+ UonParserSession p = UonParser.DEFAULT.createSession();
A t;
String s = null;
@@ -274,7 +275,7 @@ public class UonPartParserTest {
public void testParseParameterObjectMap() throws Exception {
String in = "(name='foo bar')";
- ObjectMap r = UonPartParser.DEFAULT.createSession().parse(null, in, BeanContext.DEFAULT.createSession().getClassMeta(ObjectMap.class));
+ ObjectMap r = UonParser.DEFAULT.createSession().parse(null, in, BeanContext.DEFAULT.createSession().getClassMeta(ObjectMap.class));
assertEquals("{name:'foo bar'}", SimpleJsonSerializer.DEFAULT.toString(r));
}
diff --git a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/transforms/LocalizedDatesTest.java b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/transforms/LocalizedDatesTest.java
index 0c101c0..a5033fb 100644
--- a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/transforms/LocalizedDatesTest.java
+++ b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/transforms/LocalizedDatesTest.java
@@ -642,7 +642,7 @@ public class LocalizedDatesTest {
@Test
public void test() {
- BeanSession session = bc.createSession(new BeanSessionArgs(null, sessionLocale, sessionTimeZone, null, null));
+ BeanSession session = bc.createSession(new BeanSessionArgs(null, sessionLocale, sessionTimeZone, null, null, null));
String actual = session.convertToType(calendar, String.class);
String actual2 = actual;
if (expected.indexOf('(') == -1)
diff --git a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/xml/XmlContentTest.java b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/xml/XmlContentTest.java
index a8845a1..d025f1b 100755
--- a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/xml/XmlContentTest.java
+++ b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/xml/XmlContentTest.java
@@ -44,7 +44,7 @@ public class XmlContentTest {
t.f2 = null;
sw = new StringWriter();
- session = s1.createSession(new SerializerSessionArgs(null, null, null, null, null, null, null, null));
+ session = s1.createSession(new SerializerSessionArgs(null, null, null, null, null, null, null, null, null));
session.serialize(t, sw);
r = sw.toString();
assertEquals("<A f1='f1'>_x0000_</A>", r);
@@ -52,7 +52,7 @@ public class XmlContentTest {
assertEqualObjects(t, t2);
sw = new StringWriter();
- session = s2.createSession(new SerializerSessionArgs(null, null, null, null, null, null, null, null));
+ session = s2.createSession(new SerializerSessionArgs(null, null, null, null, null, null, null, null, null));
session.serialize(t, sw);
r = sw.toString();
assertEquals("<A f1='f1'>_x0000_</A>\n", r);
@@ -152,7 +152,7 @@ public class XmlContentTest {
t.f2 = null;
sw = new StringWriter();
- session = s1.createSession(new SerializerSessionArgs(null, null, null, null, null, null, null, null));
+ session = s1.createSession(new SerializerSessionArgs(null, null, null, null, null, null, null, null, null));
session.serialize(t, sw);
r = sw.toString();
assertEquals("<A f1='f1'>_x0000_</A>", r);
@@ -160,7 +160,7 @@ public class XmlContentTest {
assertEqualObjects(t, t2);
sw = new StringWriter();
- session = s2.createSession(new SerializerSessionArgs(null, null, null, null, null, null, null, null));
+ session = s2.createSession(new SerializerSessionArgs(null, null, null, null, null, null, null, null, null));
session.serialize(t, sw);
r = sw.toString();
assertEquals("<A f1='f1'>_x0000_</A>\n", r);
diff --git a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/LinkString.java b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/LinkString.java
index 8d52fd3..8ce2a0d 100644
--- a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/LinkString.java
+++ b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/LinkString.java
@@ -20,6 +20,7 @@ import org.apache.juneau.annotation.*;
import org.apache.juneau.html.*;
import org.apache.juneau.html.annotation.*;
import org.apache.juneau.httppart.*;
+import org.apache.juneau.oapi.*;
import org.apache.juneau.serializer.*;
import org.apache.juneau.utils.*;
@@ -121,7 +122,7 @@ public class LinkString implements Comparable<LinkString> {
public LinkString uri(String uri, Object...args) {
for (int i = 0; i < args.length; i++)
try {
- args[i] = SimpleUonPartSerializer.DEFAULT.createSession().serialize(HttpPartType.PATH, null, args[i]);
+ args[i] = OpenApiSerializer.DEFAULT.createSession().serialize(HttpPartType.PATH, null, args[i]);
} catch (SchemaValidationException | SerializeException e) {
throw new RuntimeException(e);
}
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanSession.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanSession.java
index 04acae0..4d6c432 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanSession.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanSession.java
@@ -23,6 +23,7 @@ import java.util.Date;
import java.util.concurrent.atomic.*;
import org.apache.juneau.http.*;
+import org.apache.juneau.httppart.*;
import org.apache.juneau.internal.*;
import org.apache.juneau.json.*;
import org.apache.juneau.parser.*;
@@ -43,6 +44,7 @@ public class BeanSession extends Session {
private final TimeZone timeZone;
private final MediaType mediaType;
private final boolean debug;
+ private final HttpPartSchema schema;
private Stack<StringBuilder> sbStack = new Stack<>();
/**
@@ -60,6 +62,7 @@ public class BeanSession extends Session {
locale = ObjectUtils.firstNonNull(args.locale, ctx.getLocale(), Locale.getDefault());
timeZone = ObjectUtils.firstNonNull(args.timeZone, ctx.getTimeZone());
debug = ObjectUtils.firstNonNull(args.debug, ctx.isDebug(), false);
+ schema = args.schema;
mediaType = ObjectUtils.firstNonNull(args.mediaType, ctx.getMediaType());
}
@@ -70,6 +73,7 @@ public class BeanSession extends Session {
.append("BeanSession", new ObjectMap()
.append("debug", debug)
.append("locale", locale)
+ .append("schema", schema)
.append("mediaType", mediaType)
.append("timeZone", timeZone)
);
@@ -1501,6 +1505,15 @@ public class BeanSession extends Session {
return mediaType;
}
+ /**
+ * HTTP part schema of object being serialized or parsed.
+ *
+ * @return HTTP part schema of object being serialized or parsed, or <jk>null</jk> if not specified.
+ */
+ public final HttpPartSchema getSchema() {
+ return schema;
+ }
+
@Override /* Session */
public void checkForWarnings() {
if (debug)
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanSessionArgs.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanSessionArgs.java
index d14a929..7f0fa89 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanSessionArgs.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanSessionArgs.java
@@ -15,6 +15,7 @@ package org.apache.juneau;
import java.util.*;
import org.apache.juneau.http.*;
+import org.apache.juneau.httppart.*;
/**
* Runtime arguments common to all bean, serializer, and parser sessions.
@@ -30,6 +31,7 @@ public class BeanSessionArgs extends SessionArgs {
TimeZone timeZone;
MediaType mediaType;
Boolean debug;
+ HttpPartSchema schema;
/**
* Constructor
@@ -52,15 +54,19 @@ public class BeanSessionArgs extends SessionArgs {
* @param mediaType
* The session media type (e.g. <js>"application/json"</js>).
* <br>Can be <jk>null</jk>.
+ * @param schema
+ * The part schema for the serialized part.
+ * <br>Can be <jk>null</jk>.
* @param debug
* Enable debug mode for this session.
* <br>Can be <jk>null</jk> to use the debug setting on the bean context..
*/
- public BeanSessionArgs(ObjectMap properties, Locale locale, TimeZone timeZone, MediaType mediaType, Boolean debug) {
+ public BeanSessionArgs(ObjectMap properties, Locale locale, TimeZone timeZone, MediaType mediaType, HttpPartSchema schema, Boolean debug) {
super(properties);
this.locale = locale;
this.timeZone = timeZone;
this.mediaType = mediaType;
+ this.schema = schema;
this.debug = debug;
}
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 5cc648e..4cc2a5e 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
@@ -12,8 +12,6 @@
// ***************************************************************************************************************************
package org.apache.juneau.http.annotation;
-import org.apache.juneau.httppart.*;
-
/**
* Various reusable utility methods when working with annotations.
*/
@@ -285,56 +283,4 @@ public class AnnotationUtils {
return false;
return true;
}
-
- /**
- * 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(Body a) {
- return
- a.usePartParser()
- || a.partParser() != HttpPartParser.Null.class
- || ! empty(a.schema());
- }
-
- /**
- * 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.
- * @return <jk>true</jk> if the part serializer should be used on the specified part.
- */
- public static boolean usePartSerializer(Body a) {
- return
- a.usePartSerializer()
- || a.partSerializer() != HttpPartSerializer.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.
- * @return <jk>true</jk> if the part serializer should be used on the specified part.
- */
- public static boolean usePartSerializer(Response a) {
- return
- a.usePartSerializer()
- || a.partSerializer() != HttpPartSerializer.Null.class
- || ! empty(a.schema());
- }
}
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/Body.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/Body.java
index 584ee7a..a049885 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/Body.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/Body.java
@@ -126,38 +126,6 @@ import org.apache.juneau.jsonschema.*;
@Inherited
public @interface Body {
- /**
- * Specifies the {@link HttpPartSerializer} class used for serializing values to strings when using schema-based HTTP part serializing.
- *
- * <p>
- * Overrides for this part the part serializer defined on the REST client which by default is {@link OpenApiPartSerializer}.
- */
- Class<? extends HttpPartSerializer> partSerializer() default HttpPartSerializer.Null.class;
-
- /**
- * Specifies the {@link HttpPartParser} class used for parsing strings to values when using when using schema-based HTTP part parsing.
- *
- * <p>
- * Overrides for this part the part parser defined on the REST resource which by default is {@link OpenApiPartParser}.
- */
- Class<? extends HttpPartParser> partParser() default HttpPartParser.Null.class;
-
- /**
- * Specifies whether a part serializer should be used for serializing this value.
- *
- * <p>
- * If <jk>false</jk>, then it indicates that normal Juneau serializers (e.g. {@link JsonSerializer}) should be used for this part.
- */
- public boolean usePartSerializer() default false;
-
- /**
- * Specifies whether a part parser should be used for parsing this value.
- *
- * <p>
- * If <jk>false</jk>, then it indicates that normal Juneau parsers (e.g. {@link JsonParser}) should be used for this part.
- */
- public boolean usePartParser() default false;
-
//=================================================================================================================
// Attributes common to all Swagger Parameter objects
//=================================================================================================================
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 2fca9c0..32649a1 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
@@ -23,6 +23,7 @@ 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.*;
/**
* REST request form-data annotation.
@@ -124,7 +125,7 @@ public @interface FormData {
* Specifies the {@link HttpPartSerializer} class used for serializing values to strings.
*
* <p>
- * Overrides for this part the part serializer defined on the REST client which by default is {@link OpenApiPartSerializer}.
+ * Overrides for this part the part serializer defined on the REST client which by default is {@link OpenApiSerializer}.
*/
Class<? extends HttpPartSerializer> serializer() default HttpPartSerializer.Null.class;
@@ -132,7 +133,7 @@ public @interface FormData {
* Specifies the {@link HttpPartParser} class used for parsing strings to values.
*
* <p>
- * Overrides for this part the part parser defined on the REST resource which by default is {@link OpenApiPartParser}.
+ * Overrides for this part the part parser defined on the REST resource which by default is {@link OpenApiParser}.
*/
Class<? extends HttpPartParser> parser() default HttpPartParser.Null.class;
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 c79ec2a..95537b2 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
@@ -23,6 +23,7 @@ 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.*;
/**
* REST request header annotation.
@@ -108,7 +109,7 @@ public @interface Header {
* Specifies the {@link HttpPartSerializer} class used for serializing values to strings.
*
* <p>
- * Overrides for this part the part serializer defined on the REST client which by default is {@link OpenApiPartSerializer}.
+ * Overrides for this part the part serializer defined on the REST client which by default is {@link OpenApiSerializer}.
*/
Class<? extends HttpPartSerializer> serializer() default HttpPartSerializer.Null.class;
@@ -116,7 +117,7 @@ public @interface Header {
* Specifies the {@link HttpPartParser} class used for parsing strings to values.
*
* <p>
- * Overrides for this part the part parser defined on the REST resource which by default is {@link OpenApiPartParser}.
+ * Overrides for this part the part parser defined on the REST resource which by default is {@link OpenApiParser}.
*/
Class<? extends HttpPartParser> parser() default HttpPartParser.Null.class;
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/Items.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/Items.java
index e13d886..1bcb9c7 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/Items.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/Items.java
@@ -16,7 +16,7 @@ import static java.lang.annotation.RetentionPolicy.*;
import java.lang.annotation.*;
-import org.apache.juneau.httppart.*;
+import org.apache.juneau.oapi.*;
/**
* Swagger items annotation.
@@ -26,7 +26,7 @@ import org.apache.juneau.httppart.*;
*
* <p>
* Used to populate the auto-generated Swagger documentation and UI for server-side <ja>@RestResource</ja>-annotated classes.
- * <br>Also used to define OpenAPI schema information for POJOs serialized through {@link OpenApiPartSerializer} and parsed through {@link OpenApiPartParser}.
+ * <br>Also used to define OpenAPI schema information for POJOs serialized through {@link OpenApiSerializer} and parsed through {@link OpenApiParser}.
*
* <h5 class='section'>Examples:</h5>
* <p class='bcode w800'>
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 d9c2c78..bc6073a 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
@@ -22,6 +22,7 @@ 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.*;
/**
* REST request path annotation.
@@ -90,7 +91,7 @@ public @interface Path {
* Specifies the {@link HttpPartSerializer} class used for serializing values to strings.
*
* <p>
- * Overrides for this part the part serializer defined on the REST client which by default is {@link OpenApiPartSerializer}.
+ * Overrides for this part the part serializer defined on the REST client which by default is {@link OpenApiSerializer}.
*/
Class<? extends HttpPartSerializer> serializer() default HttpPartSerializer.Null.class;
@@ -98,7 +99,7 @@ public @interface Path {
* Specifies the {@link HttpPartParser} class used for parsing strings to values.
*
* <p>
- * Overrides for this part the part parser defined on the REST resource which by default is {@link OpenApiPartParser}.
+ * Overrides for this part the part parser defined on the REST resource which by default is {@link OpenApiParser}.
*/
Class<? extends HttpPartParser> parser() default HttpPartParser.Null.class;
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/Query.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/Query.java
index 6cb386b..3d90855 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/Query.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/Query.java
@@ -23,6 +23,7 @@ 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.*;
/**
* REST request form-data annotation.
@@ -116,7 +117,7 @@ public @interface Query {
* Specifies the {@link HttpPartSerializer} class used for serializing values to strings.
*
* <p>
- * Overrides for this part the part serializer defined on the REST client which by default is {@link OpenApiPartSerializer}.
+ * Overrides for this part the part serializer defined on the REST client which by default is {@link OpenApiSerializer}.
*/
Class<? extends HttpPartSerializer> serializer() default HttpPartSerializer.Null.class;
@@ -124,7 +125,7 @@ public @interface Query {
* Specifies the {@link HttpPartParser} class used for parsing strings to values.
*
* <p>
- * Overrides for this part the part parser defined on the REST resource which by default is {@link OpenApiPartParser}.
+ * Overrides for this part the part parser defined on the REST resource which by default is {@link OpenApiParser}.
*/
Class<? extends HttpPartParser> parser() default HttpPartParser.Null.class;
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/Request.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/Request.java
index 4eed973..69c7ec2 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/Request.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/Request.java
@@ -18,6 +18,7 @@ import static java.lang.annotation.RetentionPolicy.*;
import java.lang.annotation.*;
import org.apache.juneau.httppart.*;
+import org.apache.juneau.oapi.*;
/**
* Request bean annotation.
@@ -146,7 +147,7 @@ public @interface Request {
* Specifies the {@link HttpPartSerializer} class used for serializing values to strings.
*
* <p>
- * Overrides for this part the part serializer defined on the REST client which by default is {@link OpenApiPartSerializer}.
+ * Overrides for this part the part serializer defined on the REST client which by default is {@link OpenApiSerializer}.
*/
Class<? extends HttpPartSerializer> partSerializer() default HttpPartSerializer.Null.class;
@@ -154,7 +155,7 @@ public @interface Request {
* Specifies the {@link HttpPartParser} class used for parsing strings to values.
*
* <p>
- * Overrides for this part the part parser defined on the REST resource which by default is {@link OpenApiPartParser}.
+ * Overrides for this part the part parser defined on the REST resource which by default is {@link OpenApiParser}.
*/
Class<? extends HttpPartParser> partParser() default HttpPartParser.Null.class;
}
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 e55ec19..3156183 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
@@ -22,6 +22,7 @@ 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.*;
/**
* REST response annotation.
@@ -58,35 +59,19 @@ public @interface Response {
* Specifies the {@link HttpPartParser} class used for parsing strings to values.
*
* <p>
- * Overrides for this part the part parser defined on the REST resource which by default is {@link OpenApiPartParser}.
+ * Overrides for this part the part parser defined on the REST resource which by default is {@link OpenApiParser}.
*/
Class<? extends HttpPartParser> partParser() default HttpPartParser.Null.class;
/**
- * Specifies whether a part parser should be used for parsing this value.
- *
- * <p>
- * If <jk>false</jk>, then it indicates that normal Juneau parsers (e.g. {@link JsonParser}) should be used for this part.
- */
- public boolean usePartParser() default false;
-
- /**
* Specifies the {@link HttpPartSerializer} class used for serializing values to strings.
*
* <p>
- * Overrides for this part the part serializer defined on the REST resource which by default is {@link OpenApiPartSerializer}.
+ * Overrides for this part the part serializer defined on the REST resource which by default is {@link OpenApiSerializer}.
*/
Class<? extends HttpPartSerializer> partSerializer() default HttpPartSerializer.Null.class;
/**
- * Specifies whether a part serializer should be used for serializing this value.
- *
- * <p>
- * If <jk>false</jk>, then it indicates that normal Juneau serializers (e.g. {@link JsonSerializer}) should be used for this part.
- */
- public boolean usePartSerializer() default false;
-
- /**
* The HTTP response code.
*
* The default value is <code>500</code> for exceptions and <code>200</code> for return types.
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/ResponseHeader.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/ResponseHeader.java
index a66a020..d156cbb 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/ResponseHeader.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/ResponseHeader.java
@@ -19,6 +19,7 @@ import java.lang.annotation.*;
import org.apache.juneau.*;
import org.apache.juneau.httppart.*;
+import org.apache.juneau.oapi.*;
/**
* REST response header annotation.
@@ -176,7 +177,7 @@ public @interface ResponseHeader {
* Specifies the {@link HttpPartSerializer} class used for serializing values to strings.
*
* <p>
- * Overrides for this part the part serializer defined on the REST resource which by default is {@link OpenApiPartSerializer}.
+ * Overrides for this part the part serializer defined on the REST resource which by default is {@link OpenApiSerializer}.
*/
Class<? extends HttpPartSerializer> serializer() default HttpPartSerializer.Null.class;
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/Schema.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/Schema.java
index a643c21..255139e 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/Schema.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/Schema.java
@@ -16,7 +16,7 @@ import static java.lang.annotation.RetentionPolicy.*;
import java.lang.annotation.*;
-import org.apache.juneau.httppart.*;
+import org.apache.juneau.oapi.*;
/**
* Swagger schema annotation.
@@ -29,7 +29,7 @@ import org.apache.juneau.httppart.*;
*
* <p>
* Used to populate the auto-generated Swagger documentation and UI for server-side <ja>@RestResource</ja>-annotated classes.
- * <br>Also used to define OpenAPI schema information for POJOs serialized through {@link OpenApiPartSerializer} and parsed through {@link OpenApiPartParser}.
+ * <br>Also used to define OpenAPI schema information for POJOs serialized through {@link OpenApiSerializer} and parsed through {@link OpenApiParser}.
*
* <h5 class='section'>Examples:</h5>
* <p class='bcode w800'>
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/SimpleUonPartSerializerSession.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/BaseHttpPartParser.java
similarity index 68%
copy from juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/SimpleUonPartSerializerSession.java
copy to juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/BaseHttpPartParser.java
index 7e5b4a8..76a6607 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/SimpleUonPartSerializerSession.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/BaseHttpPartParser.java
@@ -12,27 +12,27 @@
// ***************************************************************************************************************************
package org.apache.juneau.httppart;
-import org.apache.juneau.serializer.*;
+import java.lang.reflect.*;
+
+import org.apache.juneau.parser.*;
/**
- * Session object that lives for the duration of a single use of {@link SimpleUonPartSerializer}.
- *
- * <p>
- * This class is NOT thread safe.
- * It is typically discarded after one-time use although it can be reused within the same thread.
+ * Base class for implementations of {@link HttpPartParser}
*/
-public class SimpleUonPartSerializerSession extends UonPartSerializerSession {
+public abstract class BaseHttpPartParser implements HttpPartParser {
+
+ @Override /* HttpPartParser */
+ public HttpPartParserSession createPartSession() {
+ return createPartSession(null);
+ }
+
+ @Override /* HttpPartParser */
+ public <T> T parse(HttpPartSchema schema, String in, Class<T> toType) throws ParseException, SchemaValidationException {
+ return parse(null, schema, in, toType);
+ }
- /**
- * Create a new session using properties specified in the context.
- *
- * @param ctx
- * The context creating this session object.
- * The context contains all the configuration settings for this object.
- * @param args
- * Runtime session arguments.
- */
- protected SimpleUonPartSerializerSession(UonPartSerializer ctx, SerializerSessionArgs args) {
- super(ctx, args);
+ @Override /* HttpPartParser */
+ public <T> T parse(HttpPartSchema schema, String in, Type toType, Type...toTypeArgs) throws ParseException, SchemaValidationException {
+ return parse(null, schema, in, toType, toTypeArgs);
}
}
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/SimplePartSerializerSession.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/BaseHttpPartParserSession.java
similarity index 64%
copy from juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/SimplePartSerializerSession.java
copy to juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/BaseHttpPartParserSession.java
index 628f28d..ba70c04 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/SimplePartSerializerSession.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/BaseHttpPartParserSession.java
@@ -1,34 +1,39 @@
-// ***************************************************************************************************************************
-// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
-// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
-// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
-// * with the License. You may obtain a copy of the License at *
-// * *
-// * http://www.apache.org/licenses/LICENSE-2.0 *
-// * *
-// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
-// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
-// * specific language governing permissions and limitations under the License. *
-// ***************************************************************************************************************************
-package org.apache.juneau.httppart;
-
-import org.apache.juneau.internal.*;
-
-/**
- * Session object that lives for the duration of a single use of {@link SimplePartSerializer}.
- *
- * <p>
- * This class is NOT thread safe.
- * It is typically discarded after one-time use although it can be reused within the same thread.
- */
-public class SimplePartSerializerSession implements HttpPartSerializerSession {
-
- //-------------------------------------------------------------------------------------------------------------------
- // Instance
- //-------------------------------------------------------------------------------------------------------------------
-
- @Override /* PartSerializer */
- public String serialize(HttpPartType type, HttpPartSchema schema, Object value) {
- return ClassUtils.toString(value);
- }
-}
+// ***************************************************************************************************************************
+// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
+// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
+// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
+// * with the License. You may obtain a copy of the License at *
+// * *
+// * http://www.apache.org/licenses/LICENSE-2.0 *
+// * *
+// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
+// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
+// * specific language governing permissions and limitations under the License. *
+// ***************************************************************************************************************************
+package org.apache.juneau.httppart;
+
+import java.lang.reflect.*;
+
+import org.apache.juneau.*;
+import org.apache.juneau.parser.*;
+
+/**
+ * Base class for implementations of {@link HttpPartParserSession}
+ */
+public abstract class BaseHttpPartParserSession implements HttpPartParserSession {
+
+ @Override /* HttpPartParserSession */
+ public <T> T parse(HttpPartSchema schema, String in, ClassMeta<T> toType) throws ParseException, SchemaValidationException {
+ return parse(null, in, toType);
+ }
+
+ @Override /* HttpPartParserSession */
+ public <T> T parse(HttpPartSchema schema, String in, Class<T> toType) throws ParseException, SchemaValidationException {
+ return parse(null, in, toType);
+ }
+
+ @Override /* HttpPartParserSession */
+ public <T> T parse(HttpPartSchema schema, String in, Type toType, Type...toTypeArgs) throws ParseException, SchemaValidationException {
+ return parse(null, in, toType, toTypeArgs);
+ }
+}
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/SimpleUonPartSerializerSession.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/BaseHttpPartSerializer.java
similarity index 69%
copy from juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/SimpleUonPartSerializerSession.java
copy to juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/BaseHttpPartSerializer.java
index 7e5b4a8..92f756e 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/SimpleUonPartSerializerSession.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/BaseHttpPartSerializer.java
@@ -15,24 +15,17 @@ package org.apache.juneau.httppart;
import org.apache.juneau.serializer.*;
/**
- * Session object that lives for the duration of a single use of {@link SimpleUonPartSerializer}.
- *
- * <p>
- * This class is NOT thread safe.
- * It is typically discarded after one-time use although it can be reused within the same thread.
+ * Base class for implementations of {@link HttpPartSerializer}
*/
-public class SimpleUonPartSerializerSession extends UonPartSerializerSession {
+public abstract class BaseHttpPartSerializer implements HttpPartSerializer {
- /**
- * Create a new session using properties specified in the context.
- *
- * @param ctx
- * The context creating this session object.
- * The context contains all the configuration settings for this object.
- * @param args
- * Runtime session arguments.
- */
- protected SimpleUonPartSerializerSession(UonPartSerializer ctx, SerializerSessionArgs args) {
- super(ctx, args);
+ @Override
+ public HttpPartSerializerSession createPartSession() {
+ return createPartSession(null);
+ }
+
+ @Override
+ public String serialize(HttpPartSchema schema, Object value) throws SchemaValidationException, SerializeException {
+ return serialize(null, schema, value);
}
}
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/SimpleUonPartSerializerSession.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/BaseHttpPartSerializerSession.java
similarity index 69%
rename from juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/SimpleUonPartSerializerSession.java
rename to juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/BaseHttpPartSerializerSession.java
index 7e5b4a8..d308695 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/SimpleUonPartSerializerSession.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/BaseHttpPartSerializerSession.java
@@ -15,24 +15,12 @@ package org.apache.juneau.httppart;
import org.apache.juneau.serializer.*;
/**
- * Session object that lives for the duration of a single use of {@link SimpleUonPartSerializer}.
- *
- * <p>
- * This class is NOT thread safe.
- * It is typically discarded after one-time use although it can be reused within the same thread.
+ * Base class for implementations of {@link HttpPartSerializerSession}
*/
-public class SimpleUonPartSerializerSession extends UonPartSerializerSession {
+public abstract class BaseHttpPartSerializerSession implements HttpPartSerializerSession {
- /**
- * Create a new session using properties specified in the context.
- *
- * @param ctx
- * The context creating this session object.
- * The context contains all the configuration settings for this object.
- * @param args
- * Runtime session arguments.
- */
- protected SimpleUonPartSerializerSession(UonPartSerializer ctx, SerializerSessionArgs args) {
- super(ctx, args);
+ @Override /* HttpPartSerializerSession */
+ public String serialize(HttpPartSchema schema, Object value) throws SerializeException, SchemaValidationException {
+ return serialize(null, schema, value);
}
}
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/HttpPart.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/HttpPart.java
index 0404e56..d6d845d 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/HttpPart.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/HttpPart.java
@@ -101,7 +101,7 @@ public class HttpPart {
public String asString() throws SchemaValidationException, SerializeException {
if (spart != null)
return spart;
- return serializer.createSession(sargs).serialize(partType, schema, opart);
+ return serializer.createPartSession(sargs).serialize(partType, schema, opart);
}
/**
@@ -113,6 +113,6 @@ public class HttpPart {
* @throws ParseException
*/
public <T> T asType(Class<T> c) throws SchemaValidationException, ParseException {
- return parser.createSession(pargs).parse(partType, schema, spart, c);
+ return parser.createPartSession(pargs).parse(partType, schema, spart, c);
}
}
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/HttpPartParser.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/HttpPartParser.java
index 060a8c7..b3ecd97 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/HttpPartParser.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/HttpPartParser.java
@@ -23,8 +23,8 @@ import org.apache.juneau.parser.*;
* <p>
* The following default implementations are provided:
* <ul class='doctree'>
- * <li class='jc'>{@link org.apache.juneau.httppart.OpenApiPartParser} - Parts encoded in based on OpenAPI schema.
- * <li class='jc'>{@link org.apache.juneau.httppart.UonPartParser} - Parts encoded in UON notation.
+ * <li class='jc'>{@link org.apache.juneau.oapi.OpenApiParser} - Parts encoded in based on OpenAPI schema.
+ * <li class='jc'>{@link org.apache.juneau.uon.UonParser} - Parts encoded in UON notation.
* <li class='jc'>{@link org.apache.juneau.httppart.SimplePartParser} - Parts encoded in plain text.
* </ul>
*
@@ -48,24 +48,15 @@ public interface HttpPartParser {
* @param args The runtime arguments for the session.
* @return A new parser session.
*/
- public HttpPartParserSession createSession(ParserSessionArgs args);
+ public HttpPartParserSession createPartSession(ParserSessionArgs args);
+
+ /**
+ * Creates a new no-argument parser session.
+ *
+ * @return A new parser session.
+ */
+ public HttpPartParserSession createPartSession();
-// /**
-// * Convenience method for creating a no-arg session and parsing a part.
-// *
-// * @param partType The category of value being parsed.
-// * @param schema
-// * Schema information about the part.
-// * <br>May be <jk>null</jk>.
-// * <br>Not all part parsers use the schema information.
-// * @param in The value being parsed.
-// * @param toType The POJO type to transform the input into.
-// * @return The parsed value.
-// * @throws ParseException If a problem occurred while trying to parse the input.
-// * @throws SchemaValidationException If the input fails schema validation.
-// */
-// public <T> T parse(HttpPartType partType, HttpPartSchema schema, String in, ClassMeta<T> toType) throws ParseException, SchemaValidationException;
-//
/**
* Convenience method for creating a no-arg session and parsing a part.
*
@@ -99,21 +90,6 @@ public interface HttpPartParser {
*/
public <T> T parse(HttpPartType partType, HttpPartSchema schema, String in, Type toType, Type...toTypeArgs) throws ParseException, SchemaValidationException;
-// /**
-// * Convenience method for creating a no-arg session and parsing a part of an unspecified part type.
-// *
-// * @param schema
-// * Schema information about the part.
-// * <br>May be <jk>null</jk>.
-// * <br>Not all part parsers use the schema information.
-// * @param in The value being parsed.
-// * @param toType The POJO type to transform the input into.
-// * @return The parsed value.
-// * @throws ParseException If a problem occurred while trying to parse the input.
-// * @throws SchemaValidationException If the input fails schema validation.
-// */
-// public <T> T parse(HttpPartSchema schema, String in, ClassMeta<T> toType) throws ParseException, SchemaValidationException;
-//
/**
* Convenience method for creating a no-arg session and parsing a part of an unspecified part type.
*
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/HttpPartParserSession.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/HttpPartParserSession.java
index 136531f..28b2927 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/HttpPartParserSession.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/HttpPartParserSession.java
@@ -74,4 +74,50 @@ public interface HttpPartParserSession {
* @throws SchemaValidationException If the input or resulting HTTP part object fails schema validation.
*/
public <T> T parse(HttpPartType partType, HttpPartSchema schema, String in, Type toType, Type...toTypeArgs) throws ParseException, SchemaValidationException;
+
+ /**
+ * Same as {@link #parse(HttpPartType, HttpPartSchema, String, ClassMeta)} but defaults to a <jk>null</jk> part type.
+ *
+ * @param schema
+ * Schema information about the part.
+ * <br>May be <jk>null</jk>.
+ * <br>Not all part parsers use the schema information.
+ * @param in The input being parsed.
+ * @param toType The POJO type to transform the input into.
+ * @return The parsed value.
+ * @throws ParseException If a problem occurred while trying to parse the input.
+ * @throws SchemaValidationException If the input or resulting HTTP part object fails schema validation.
+ */
+ public <T> T parse(HttpPartSchema schema, String in, ClassMeta<T> toType) throws ParseException, SchemaValidationException;
+
+ /**
+ * Same as {@link #parse(HttpPartType, HttpPartSchema, String, Class)} but defaults to a <jk>null</jk> part type.
+ *
+ * @param schema
+ * Schema information about the part.
+ * <br>May be <jk>null</jk>.
+ * <br>Not all part parsers use the schema information.
+ * @param in The input being parsed.
+ * @param toType The POJO type to transform the input into.
+ * @return The parsed value.
+ * @throws ParseException If a problem occurred while trying to parse the input.
+ * @throws SchemaValidationException If the input or resulting HTTP part object fails schema validation.
+ */
+ public <T> T parse(HttpPartSchema schema, String in, Class<T> toType) throws ParseException, SchemaValidationException;
+
+ /**
+ * Same as {@link #parse(HttpPartType, HttpPartSchema, String, Type, Type...)} but defaults to a <jk>null</jk> part type.
+ *
+ * @param schema
+ * Schema information about the part.
+ * <br>May be <jk>null</jk>.
+ * <br>Not all part parsers use the schema information.
+ * @param in The input being parsed.
+ * @param toType The POJO type to transform the input into.
+ * @param toTypeArgs The POJO type arguments for Collection and Map types.
+ * @return The parsed value.
+ * @throws ParseException If a problem occurred while trying to parse the input.
+ * @throws SchemaValidationException If the input or resulting HTTP part object fails schema validation.
+ */
+ public <T> T parse(HttpPartSchema schema, String in, Type toType, Type...toTypeArgs) throws ParseException, SchemaValidationException;
}
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/HttpPartSchema.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/HttpPartSchema.java
index 9e9c85d..ae2f4e7 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/HttpPartSchema.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/HttpPartSchema.java
@@ -13,9 +13,9 @@
package org.apache.juneau.httppart;
import static java.util.Collections.*;
-import static org.apache.juneau.internal.StringUtils.*;
-import static org.apache.juneau.httppart.HttpPartSchema.Type.*;
import static org.apache.juneau.httppart.HttpPartSchema.Format.*;
+import static org.apache.juneau.httppart.HttpPartSchema.Type.*;
+import static org.apache.juneau.internal.StringUtils.*;
import java.lang.annotation.*;
import java.lang.reflect.*;
@@ -25,7 +25,6 @@ import java.util.regex.*;
import org.apache.juneau.*;
import org.apache.juneau.http.annotation.*;
import org.apache.juneau.internal.*;
-import org.apache.juneau.json.*;
import org.apache.juneau.parser.*;
import org.apache.juneau.utils.*;
@@ -53,7 +52,7 @@ public class HttpPartSchema {
// Predefined instances
//-------------------------------------------------------------------------------------------------------------------
- /** Reusable instance of {@link OpenApiPartSerializer}, all default settings. */
+ /** Reusable instance of this object, all default settings. */
public static final HttpPartSchema DEFAULT = HttpPartSchema.create().allowEmptyValue(true).build();
final String name;
@@ -61,7 +60,7 @@ public class HttpPartSchema {
final String _default;
final Set<String> _enum;
final Map<String,HttpPartSchema> properties;
- final boolean allowEmptyValue, exclusiveMaximum, exclusiveMinimum, required, uniqueItems, skipIfEmpty, usePartSerializer, usePartParser;
+ final boolean allowEmptyValue, exclusiveMaximum, exclusiveMinimum, required, uniqueItems, skipIfEmpty;
final CollectionFormat collectionFormat;
final Type type;
final Format format;
@@ -235,8 +234,6 @@ public class HttpPartSchema {
this.required = resolve(b.required);
this.uniqueItems = resolve(b.uniqueItems);
this.skipIfEmpty = resolve(b.skipIfEmpty);
- this.usePartSerializer = resolve(b.usePartSerializer);
- this.usePartParser = resolve(b.usePartParser);
this.collectionFormat = b.collectionFormat;
this.type = b.type;
this.format = b.format;
@@ -948,34 +945,6 @@ public class HttpPartSchema {
}
/**
- * Returns the <code>usePartSerializer</code> field of this schema.
- *
- * <p>
- * This flag is only applicable for HTTP bodies.
- * It specifies whether the HTTP body should be serialized using normal Juneau serializers (e.g. {@link JsonSerializer}) or HTTP part serializers (e.g. {@link OpenApiPartSerializer}.
- *
- * @return The <code>usePartSerializer</code> field of this schema.
- * @see HttpPartSchemaBuilder#usePartSerializer(Boolean)
- */
- public boolean isUsePartSerializer() {
- return usePartSerializer;
- }
-
- /**
- * Returns the <code>usePartParser</code> field of this schema.
- *
- * <p>
- * This flag is only applicable for HTTP bodies.
- * It specifies whether the HTTP body should be parsed using normal Juneau parser (e.g. {@link JsonParser}) or HTTP part serializers (e.g. {@link OpenApiPartParser}.
- *
- * @return The <code>usePartParser</code> field of this schema.
- * @see HttpPartSchemaBuilder#usePartParser(Boolean)
- */
- public boolean isUsePartParser() {
- return usePartParser;
- }
-
- /**
* Returns the <code>allowEmptyValue</code> field of this schema.
*
* @return The <code>skipIfEmpty</code> field of this schema.
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 3e24cf5..ba6e593 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
@@ -24,7 +24,6 @@ import org.apache.juneau.http.annotation.*;
import org.apache.juneau.httppart.HttpPartSchema.*;
import org.apache.juneau.httppart.HttpPartSchema.Type;
import org.apache.juneau.internal.*;
-import org.apache.juneau.json.*;
import org.apache.juneau.utils.*;
/**
@@ -35,7 +34,7 @@ public class HttpPartSchemaBuilder {
String name, _default;
Set<Integer> codes;
Set<String> _enum;
- Boolean allowEmptyValue, exclusiveMaximum, exclusiveMinimum, required, uniqueItems, skipIfEmpty, usePartSerializer, usePartParser;
+ Boolean allowEmptyValue, exclusiveMaximum, exclusiveMinimum, required, uniqueItems, skipIfEmpty;
CollectionFormat collectionFormat = CollectionFormat.NO_COLLECTION_FORMAT;
Type type = Type.NO_TYPE;
Format format = Format.NO_FORMAT;
@@ -124,10 +123,6 @@ public class HttpPartSchemaBuilder {
HttpPartSchemaBuilder apply(Body a) {
required(a.required());
allowEmptyValue(! a.required());
- serializer(a.partSerializer());
- parser(a.partParser());
- usePartSerializer(AnnotationUtils.usePartSerializer(a));
- usePartParser(AnnotationUtils.usePartParser(a));
apply(a.schema());
return this;
}
@@ -276,8 +271,6 @@ public class HttpPartSchemaBuilder {
allowEmptyValue(true);
serializer(a.partSerializer());
parser(a.partParser());
- usePartSerializer(AnnotationUtils.usePartSerializer(a));
- usePartParser(AnnotationUtils.usePartParser(a));
apply(a.schema());
return this;
}
@@ -1549,40 +1542,6 @@ public class HttpPartSchemaBuilder {
}
/**
- * Identifies whether a part serializer should be used for serializing this part.
- *
- * <p>
- * This flag is only applicable for HTTP bodies.
- * It specifies whether the HTTP body should be serialized using normal Juneau serializers (e.g. {@link JsonSerializer}) or HTTP part serializers (e.g. {@link OpenApiPartSerializer}.
- *
- * @param value
- * The new value for this property.
- * <br>Ignored if value is <jk>null</jk>.
- * @return This object (for method chaining).
- */
- public HttpPartSchemaBuilder usePartSerializer(Boolean value) {
- usePartSerializer = resolve(value, usePartSerializer);
- return this;
- }
-
- /**
- * Identifies whether a part parser should be used for parsing this part.
- *
- * <p>
- * This flag is only applicable for HTTP bodies.
- * It specifies whether the HTTP body should be parsed using normal Juneau parser (e.g. {@link JsonParser}) or HTTP part serializers (e.g. {@link OpenApiPartParser}.
- *
- * @param value
- * The new value for this property.
- * <br>Ignored if value is <jk>null</jk>.
- * @return This object (for method chaining).
- */
- public HttpPartSchemaBuilder usePartParser(Boolean value) {
- usePartParser = resolve(value, usePartParser);
- return this;
- }
-
- /**
* Disables Swagger schema usage validation checking.
*
* @param value Specify <jk>true</jk> to prevent {@link ContextRuntimeException} from being thrown if invalid Swagger usage was detected.
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/HttpPartSerializer.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/HttpPartSerializer.java
index 16583e6..537bab4 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/HttpPartSerializer.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/HttpPartSerializer.java
@@ -23,10 +23,8 @@ import org.apache.juneau.serializer.*;
* <p>
* The following default implementations are provided:
* <ul class='doctree'>
- * <li class='jc'>{@link org.apache.juneau.httppart.OpenApiPartSerializer} - Parts encoded based on OpenAPI schema.
- * <li class='jc'>{@link org.apache.juneau.httppart.UonPartSerializer} - Parts encoded in UON notation.
- * <li class='jc'>{@link org.apache.juneau.httppart.SimpleUonPartSerializer} - Parts encoded in UON notation, but
- * strings are treated as plain-text and arrays/collections are serialized as comma-delimited lists.
+ * <li class='jc'>{@link org.apache.juneau.oapi.OpenApiSerializer} - Parts encoded based on OpenAPI schema.
+ * <li class='jc'>{@link org.apache.juneau.uon.UonSerializer} - Parts encoded in UON notation.
* <li class='jc'>{@link org.apache.juneau.httppart.SimplePartSerializer} - Parts encoded in plain text.
* </ul>
*
@@ -62,7 +60,14 @@ public interface HttpPartSerializer {
* @param args The runtime arguments for the session.
* @return A new serializer session.
*/
- public HttpPartSerializerSession createSession(SerializerSessionArgs args);
+ public HttpPartSerializerSession createPartSession(SerializerSessionArgs args);
+
+ /**
+ * Creates a new no-argument serializer session.
+ *
+ * @return A new serializer session.
+ */
+ public HttpPartSerializerSession createPartSession();
/**
* Convenience method for creating a no-arg session and serializing a part.
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/HttpPartSerializerSession.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/HttpPartSerializerSession.java
index 02f62b9..1dd2a03 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/HttpPartSerializerSession.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/HttpPartSerializerSession.java
@@ -41,4 +41,18 @@ public interface HttpPartSerializerSession {
* @throws SchemaValidationException If the output fails schema validation.
*/
public String serialize(HttpPartType type, HttpPartSchema schema, Object value) throws SerializeException, SchemaValidationException;
+
+ /**
+ * Same as {@link #serialize(HttpPartType, HttpPartSchema, Object)} but defaults to a <jk>null</jk> part type.
+ *
+ * @param schema
+ * Schema information about the part.
+ * <br>May be <jk>null</jk>.
+ * <br>Not all part serializers use the schema information.
+ * @param value The value being serialized.
+ * @return The serialized value.
+ * @throws SerializeException If a problem occurred while trying to parse the input.
+ * @throws SchemaValidationException If the output fails schema validation.
+ */
+ public String serialize(HttpPartSchema schema, Object value) throws SerializeException, SchemaValidationException;
}
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/OpenApiPartParser.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/OpenApiPartParser.java
deleted file mode 100644
index 156ec00..0000000
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/OpenApiPartParser.java
+++ /dev/null
@@ -1,132 +0,0 @@
-// ***************************************************************************************************************************
-// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
-// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
-// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
-// * with the License. You may obtain a copy of the License at *
-// * *
-// * http://www.apache.org/licenses/LICENSE-2.0 *
-// * *
-// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
-// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
-// * specific language governing permissions and limitations under the License. *
-// ***************************************************************************************************************************
-package org.apache.juneau.httppart;
-
-import org.apache.juneau.*;
-import org.apache.juneau.parser.*;
-
-/**
- * OpenAPI part parser.
- *
- * <h5 class='section'>See Also:</h5>
- * <ul>
- * <li class='link'>{@doc juneau-marshall.OpenApiDetails.Parsers}
- * </ul>
- */
-public class OpenApiPartParser extends UonPartParser {
-
- //-------------------------------------------------------------------------------------------------------------------
- // Configurable properties
- //-------------------------------------------------------------------------------------------------------------------
-
- private static final String PREFIX = "OpenApiPartParser.";
-
- /**
- * Configuration property: OpenAPI schema description.
- *
- * <h5 class='section'>Property:</h5>
- * <ul>
- * <li><b>Name:</b> <js>"OpenApiPartParser.schema"</js>
- * <li><b>Data type:</b> <code>HttpPartSchema</code>
- * <li><b>Default:</b> <jk>false</jk>
- * <li><b>Session property:</b> <jk>false</jk>
- * <li><b>Methods:</b>
- * <ul>
- * <li class='jm'>{@link OpenApiPartParserBuilder#schema(HttpPartSchema)}
- * </ul>
- * </ul>
- *
- * <h5 class='section'>Description:</h5>
- * <p>
- * Defines the OpenAPI schema for this part parser.
- */
- public static final String OAPI_schema = PREFIX + "schema.o";
-
- //-------------------------------------------------------------------------------------------------------------------
- // Predefined instances
- //-------------------------------------------------------------------------------------------------------------------
-
- /** Reusable instance of {@link OpenApiPartParser}. */
- public static final OpenApiPartParser DEFAULT = new OpenApiPartParser(PropertyStore.DEFAULT);
-
- // Cache these for faster lookup
- private static final HttpPartSchema DEFAULT_SCHEMA = HttpPartSchema.DEFAULT;
-
- //-------------------------------------------------------------------------------------------------------------------
- // Instance
- //-------------------------------------------------------------------------------------------------------------------
-
- private final HttpPartSchema schema;
-
- /**
- * Constructor.
- *
- * @param ps The property store containing all the settings for this object.
- */
- public OpenApiPartParser(PropertyStore ps) {
- super(
- ps.builder().build()
- );
- this.schema = getProperty(OAPI_schema, HttpPartSchema.class, DEFAULT_SCHEMA);
- }
-
- @Override /* Context */
- public UonPartParserBuilder builder() {
- return new UonPartParserBuilder(getPropertyStore());
- }
-
- /**
- * Instantiates a new clean-slate {@link UonPartParserBuilder} object.
- *
- * <p>
- * This is equivalent to simply calling <code><jk>new</jk> UonPartParserBuilder()</code>.
- *
- * <p>
- * Note that this method creates a builder initialized to all default settings, whereas {@link #builder()} copies
- * the settings of the object called on.
- *
- * @return A new {@link UonPartParserBuilder} object.
- */
- public static UonPartParserBuilder create() {
- return new UonPartParserBuilder();
- }
-
- //-------------------------------------------------------------------------------------------------------------------
- // Entry point methods
- //-------------------------------------------------------------------------------------------------------------------
-
- @Override
- public OpenApiPartParserSession createSession() {
- return new OpenApiPartParserSession(this, ParserSessionArgs.DEFAULT);
- }
-
- @Override
- public OpenApiPartParserSession createSession(ParserSessionArgs args) {
- return new OpenApiPartParserSession(this, args);
- }
-
- //-----------------------------------------------------------------------------------------------------------------
- // Properties
- //-----------------------------------------------------------------------------------------------------------------
-
- /**
- * Configuration property: OpenAPI schema description.
- *
- * @see #OAPI_schema
- * @return
- * The default part schema on this serializer, or <jk>null</jk> if none is defined.
- */
- protected final HttpPartSchema getSchema() {
- return schema;
- }
-}
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/OpenApiPartParserBuilder.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/OpenApiPartParserBuilder.java
deleted file mode 100644
index b10f7f9..0000000
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/OpenApiPartParserBuilder.java
+++ /dev/null
@@ -1,501 +0,0 @@
-// ***************************************************************************************************************************
-// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
-// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
-// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
-// * with the License. You may obtain a copy of the License at *
-// * *
-// * http://www.apache.org/licenses/LICENSE-2.0 *
-// * *
-// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
-// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
-// * specific language governing permissions and limitations under the License. *
-// ***************************************************************************************************************************
-package org.apache.juneau.httppart;
-
-import static org.apache.juneau.httppart.OpenApiPartParser.*;
-
-import java.util.*;
-
-import org.apache.juneau.*;
-import org.apache.juneau.http.*;
-import org.apache.juneau.parser.*;
-import org.apache.juneau.uon.*;
-import org.apache.juneau.urlencoding.*;
-
-/**
- * Builder class for building instances of {@link OpenApiPartParser}.
- */
-public class OpenApiPartParserBuilder extends UonPartParserBuilder {
-
- /**
- * Constructor, default settings.
- */
- public OpenApiPartParserBuilder() {
- super();
- }
-
- /**
- * Constructor.
- *
- * @param ps The initial configuration settings for this builder.
- */
- public OpenApiPartParserBuilder(PropertyStore ps) {
- super(ps);
- }
-
- @Override /* ContextBuilder */
- public OpenApiPartParser build() {
- return build(OpenApiPartParser.class);
- }
-
-
- //--------------------------------------------------------------------------------
- // Properties
- //--------------------------------------------------------------------------------
-
- /**
- * Configuration property: Decode <js>"%xx"</js> sequences.
- *
- * <p>
- * Specify <jk>true</jk> if URI encoded characters should be decoded, <jk>false</jk> if they've already been
- * decoded before being passed to this parser.
- *
- * <h5 class='section'>See Also:</h5>
- * <ul>
- * <li class='jf'>{@link UonParser#UON_decoding}
- * </ul>
- *
- * @param value
- * The new value for this property.
- * <br>Default is <jk>false</jk> for {@link UonParser}, <jk>true</jk> for {@link UrlEncodingParser}
- * @return This object (for method chaining).
- */
- public OpenApiPartParserBuilder schema(HttpPartSchema value) {
- return set(OAPI_schema, value);
- }
-
- @Override /* UonParserBuilder */
- public OpenApiPartParserBuilder decoding(boolean value) {
- return set(UonParser.UON_decoding, value);
- }
-
- @Override /* ParserBuilder */
- public OpenApiPartParserBuilder fileCharset(String value) {
- super.fileCharset(value);
- return this;
- }
-
- @Override /* ParserBuilder */
- public OpenApiPartParserBuilder inputStreamCharset(String value) {
- super.inputStreamCharset(value);
- return this;
- }
-
- @Override /* ParserBuilder */
- public OpenApiPartParserBuilder listener(Class<? extends ParserListener> value) {
- super.listener(value);
- return this;
- }
-
- @Override /* ParserBuilder */
- public OpenApiPartParserBuilder strict(boolean value) {
- super.strict(value);
- return this;
- }
-
- @Override /* ParserBuilder */
- public OpenApiPartParserBuilder strict() {
- super.strict();
- return this;
- }
-
- @Override /* ParserBuilder */
- public OpenApiPartParserBuilder trimStrings(boolean value) {
- super.trimStrings(value);
- return this;
- }
-
- @Override /* ParserBuilder */
- public OpenApiPartParserBuilder trimStrings() {
- super.trimStrings();
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public OpenApiPartParserBuilder beanClassVisibility(Visibility value) {
- super.beanClassVisibility(value);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public OpenApiPartParserBuilder beanConstructorVisibility(Visibility value) {
- super.beanConstructorVisibility(value);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public OpenApiPartParserBuilder beanDictionary(boolean append, Object...values) {
- super.beanDictionary(append, values);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public OpenApiPartParserBuilder beanDictionary(Class<?>...values) {
- super.beanDictionary(values);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public OpenApiPartParserBuilder beanDictionary(Object...values) {
- super.beanDictionary(values);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public OpenApiPartParserBuilder beanDictionaryRemove(Object...values) {
- super.beanDictionaryRemove(values);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public OpenApiPartParserBuilder beanFieldVisibility(Visibility value) {
- super.beanFieldVisibility(value);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public OpenApiPartParserBuilder beanFilters(boolean append, Object...values) {
- super.beanFilters(append, values);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public OpenApiPartParserBuilder beanFilters(Class<?>...values) {
- super.beanFilters(values);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public OpenApiPartParserBuilder beanFilters(Object...values) {
- super.beanFilters(values);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public OpenApiPartParserBuilder beanFiltersRemove(Object...values) {
- super.beanFiltersRemove(values);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public OpenApiPartParserBuilder beanMapPutReturnsOldValue(boolean value) {
- super.beanMapPutReturnsOldValue(value);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public OpenApiPartParserBuilder beanMapPutReturnsOldValue() {
- super.beanMapPutReturnsOldValue();
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public OpenApiPartParserBuilder beanMethodVisibility(Visibility value) {
- super.beanMethodVisibility(value);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public OpenApiPartParserBuilder beansRequireDefaultConstructor(boolean value) {
- super.beansRequireDefaultConstructor(value);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public OpenApiPartParserBuilder beansRequireDefaultConstructor() {
- super.beansRequireDefaultConstructor();
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public OpenApiPartParserBuilder beansRequireSerializable(boolean value) {
- super.beansRequireSerializable(value);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public OpenApiPartParserBuilder beansRequireSerializable() {
- super.beansRequireSerializable();
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public OpenApiPartParserBuilder beansRequireSettersForGetters(boolean value) {
- super.beansRequireSettersForGetters(value);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public OpenApiPartParserBuilder beansRequireSettersForGetters() {
- super.beansRequireSettersForGetters();
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public OpenApiPartParserBuilder beansRequireSomeProperties(boolean value) {
- super.beansRequireSomeProperties(value);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public OpenApiPartParserBuilder beanTypePropertyName(String value) {
- super.beanTypePropertyName(value);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public OpenApiPartParserBuilder debug() {
- super.debug();
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public <T> OpenApiPartParserBuilder example(Class<T> c, T o) {
- super.example(c, o);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public OpenApiPartParserBuilder ignoreInvocationExceptionsOnGetters(boolean value) {
- super.ignoreInvocationExceptionsOnGetters(value);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public OpenApiPartParserBuilder ignoreInvocationExceptionsOnGetters() {
- super.ignoreInvocationExceptionsOnGetters();
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public OpenApiPartParserBuilder ignoreInvocationExceptionsOnSetters(boolean value) {
- super.ignoreInvocationExceptionsOnSetters(value);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public OpenApiPartParserBuilder ignoreInvocationExceptionsOnSetters() {
- super.ignoreInvocationExceptionsOnSetters();
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public OpenApiPartParserBuilder ignorePropertiesWithoutSetters(boolean value) {
- super.ignorePropertiesWithoutSetters(value);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public OpenApiPartParserBuilder ignoreUnknownBeanProperties(boolean value) {
- super.ignoreUnknownBeanProperties(value);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public OpenApiPartParserBuilder ignoreUnknownBeanProperties() {
- super.ignoreUnknownBeanProperties();
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public OpenApiPartParserBuilder ignoreUnknownNullBeanProperties(boolean value) {
- super.ignoreUnknownNullBeanProperties(value);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public <T> OpenApiPartParserBuilder implClass(Class<T> interfaceClass, Class<? extends T> implClass) {
- super.implClass(interfaceClass, implClass);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public OpenApiPartParserBuilder implClasses(Map<String,Class<?>> values) {
- super.implClasses(values);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public OpenApiPartParserBuilder locale(Locale value) {
- super.locale(value);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public OpenApiPartParserBuilder mediaType(MediaType value) {
- super.mediaType(value);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public OpenApiPartParserBuilder notBeanClasses(boolean append, Object...values) {
- super.notBeanClasses(append, values);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public OpenApiPartParserBuilder notBeanClasses(Class<?>...values) {
- super.notBeanClasses(values);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public OpenApiPartParserBuilder notBeanClasses(Object...values) {
- super.notBeanClasses(values);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public OpenApiPartParserBuilder notBeanClassesRemove(Object...values) {
- super.notBeanClassesRemove(values);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public OpenApiPartParserBuilder notBeanPackages(boolean append, Object...values) {
- super.notBeanPackages(append, values);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public OpenApiPartParserBuilder notBeanPackages(Object...values) {
- super.notBeanPackages(values);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public OpenApiPartParserBuilder notBeanPackages(String...values) {
- super.notBeanPackages(values);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public OpenApiPartParserBuilder notBeanPackagesRemove(Object...values) {
- super.notBeanPackagesRemove(values);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public OpenApiPartParserBuilder pojoSwaps(boolean append, Object...values) {
- super.pojoSwaps(append, values);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public OpenApiPartParserBuilder pojoSwaps(Class<?>...values) {
- super.pojoSwaps(values);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public OpenApiPartParserBuilder pojoSwaps(Object...values) {
- super.pojoSwaps(values);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public OpenApiPartParserBuilder pojoSwapsRemove(Object...values) {
- super.pojoSwapsRemove(values);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public OpenApiPartParserBuilder sortProperties(boolean value) {
- super.sortProperties(value);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public OpenApiPartParserBuilder sortProperties() {
- super.sortProperties();
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public OpenApiPartParserBuilder timeZone(TimeZone value) {
- super.timeZone(value);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public OpenApiPartParserBuilder useEnumNames() {
- super.useEnumNames();
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public OpenApiPartParserBuilder useInterfaceProxies(boolean value) {
- super.useInterfaceProxies(value);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public OpenApiPartParserBuilder useJavaBeanIntrospector(boolean value) {
- super.useJavaBeanIntrospector(value);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public OpenApiPartParserBuilder useJavaBeanIntrospector() {
- super.useJavaBeanIntrospector();
- return this;
- }
-
- @Override /* ContextBuilder */
- public OpenApiPartParserBuilder set(String name, Object value) {
- super.set(name, value);
- return this;
- }
-
- @Override /* ContextBuilder */
- public OpenApiPartParserBuilder set(boolean append, String name, Object value) {
- super.set(append, name, value);
- return this;
- }
-
- @Override /* ContextBuilder */
- public OpenApiPartParserBuilder set(Map<String,Object> properties) {
- super.set(properties);
- return this;
- }
-
- @Override /* ContextBuilder */
- public OpenApiPartParserBuilder add(Map<String,Object> properties) {
- super.add(properties);
- return this;
- }
-
- @Override /* ContextBuilder */
- public OpenApiPartParserBuilder addTo(String name, Object value) {
- super.addTo(name, value);
- return this;
- }
-
- @Override /* ContextBuilder */
- public OpenApiPartParserBuilder addTo(String name, String key, Object value) {
- super.addTo(name, key, value);
- return this;
- }
-
- @Override /* ContextBuilder */
- public OpenApiPartParserBuilder removeFrom(String name, Object value) {
- super.removeFrom(name, value);
- return this;
- }
-
- @Override /* ContextBuilder */
- public OpenApiPartParserBuilder apply(PropertyStore copyFrom) {
- super.apply(copyFrom);
- return this;
- }
-}
\ No newline at end of file
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/OpenApiPartSerializer.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/OpenApiPartSerializer.java
deleted file mode 100644
index 1283014..0000000
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/OpenApiPartSerializer.java
+++ /dev/null
@@ -1,131 +0,0 @@
-// ***************************************************************************************************************************
-// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
-// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
-// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
-// * with the License. You may obtain a copy of the License at *
-// * *
-// * http://www.apache.org/licenses/LICENSE-2.0 *
-// * *
-// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
-// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
-// * specific language governing permissions and limitations under the License. *
-// ***************************************************************************************************************************
-package org.apache.juneau.httppart;
-
-import org.apache.juneau.*;
-import org.apache.juneau.serializer.*;
-
-/**
- * Serializes POJOs to values suitable for transmission as HTTP headers, query/form-data parameters, and path variables.
- *
- * <h5 class='section'>See Also:</h5>
- * <ul>
- * <li class='link'>{@doc juneau-marshall.OpenApiDetails.Serializers}
- * </ul>
- */
-public class OpenApiPartSerializer extends UonPartSerializer {
-
- //-------------------------------------------------------------------------------------------------------------------
- // Configurable properties
- //-------------------------------------------------------------------------------------------------------------------
-
- private static final String PREFIX = "OpenApiPartSerializer.";
-
- /**
- * Configuration property: OpenAPI schema description.
- *
- * <h5 class='section'>Property:</h5>
- * <ul>
- * <li><b>Name:</b> <js>"OpenApiPartSerializer.schema"</js>
- * <li><b>Data type:</b> <code>HttpPartSchema</code>
- * <li><b>Default:</b> <jk>false</jk>
- * <li><b>Session property:</b> <jk>false</jk>
- * <li><b>Methods:</b>
- * <ul>
- * <li class='jm'>{@link OpenApiPartSerializerBuilder#schema(HttpPartSchema)}
- * </ul>
- * </ul>
- *
- * <h5 class='section'>Description:</h5>
- * <p>
- * Defines the OpenAPI schema for this part serializer.
- */
- public static final String OAPI_schema = PREFIX + "schema.o";
-
-
- //-------------------------------------------------------------------------------------------------------------------
- // Predefined instances
- //-------------------------------------------------------------------------------------------------------------------
-
- /** Reusable instance of {@link OpenApiPartSerializer}, all default settings. */
- public static final OpenApiPartSerializer DEFAULT = new OpenApiPartSerializer(PropertyStore.DEFAULT);
-
-
- //-------------------------------------------------------------------------------------------------------------------
- // Instance
- //-------------------------------------------------------------------------------------------------------------------
-
- final HttpPartSchema schema;
-
- /**
- * Constructor.
- *
- * @param ps
- * The property store containing all the settings for this object.
- */
- public OpenApiPartSerializer(PropertyStore ps) {
- super(
- ps.builder()
- .set(UON_encoding, false)
- .build()
- );
- this.schema = getProperty(OAPI_schema, HttpPartSchema.class, HttpPartSchema.DEFAULT);
- }
-
- @Override /* Context */
- public OpenApiPartSerializerBuilder builder() {
- return new OpenApiPartSerializerBuilder(getPropertyStore());
- }
-
- /**
- * Instantiates a new clean-slate {@link UonPartSerializerBuilder} object.
- *
- * <p>
- * Note that this method creates a builder initialized to all default settings, whereas {@link #builder()} copies
- * the settings of the object called on.
- *
- * @return A new {@link UonPartSerializerBuilder} object.
- */
- public static OpenApiPartSerializerBuilder create() {
- return new OpenApiPartSerializerBuilder();
- }
-
- //-----------------------------------------------------------------------------------------------------------------
- // Entry point methods
- //-----------------------------------------------------------------------------------------------------------------
-
- @Override
- public OpenApiPartSerializerSession createSession(SerializerSessionArgs args) {
- return new OpenApiPartSerializerSession(this, args);
- }
-
- @Override
- public OpenApiPartSerializerSession createSession() {
- return new OpenApiPartSerializerSession(this, SerializerSessionArgs.DEFAULT);
- }
-
- //-----------------------------------------------------------------------------------------------------------------
- // Properties
- //-----------------------------------------------------------------------------------------------------------------
-
- /**
- * Configuration property: OpenAPI schema description.
- *
- * @see #OAPI_schema
- * @return
- * The default part schema on this serializer, or <jk>null</jk> if none is defined.
- */
- protected final HttpPartSchema getSchema() {
- return schema;
- }
-}
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/OpenApiPartSerializerBuilder.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/OpenApiPartSerializerBuilder.java
deleted file mode 100644
index 87cbd91..0000000
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/OpenApiPartSerializerBuilder.java
+++ /dev/null
@@ -1,639 +0,0 @@
-// ***************************************************************************************************************************
-// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
-// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
-// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
-// * with the License. You may obtain a copy of the License at *
-// * *
-// * http://www.apache.org/licenses/LICENSE-2.0 *
-// * *
-// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
-// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
-// * specific language governing permissions and limitations under the License. *
-// ***************************************************************************************************************************
-package org.apache.juneau.httppart;
-
-import static org.apache.juneau.httppart.OpenApiPartSerializer.*;
-
-import java.util.*;
-
-import org.apache.juneau.*;
-import org.apache.juneau.http.*;
-import org.apache.juneau.serializer.*;
-import org.apache.juneau.uon.*;
-import org.apache.juneau.urlencoding.*;
-
-/**
- * Builder class for building instances of {@link UonPartSerializer}.
- */
-public class OpenApiPartSerializerBuilder extends UonPartSerializerBuilder {
-
- /**
- * Constructor, default settings.
- */
- public OpenApiPartSerializerBuilder() {
- super();
- }
-
- /**
- * Constructor.
- *
- * @param ps The initial configuration settings for this builder.
- */
- public OpenApiPartSerializerBuilder(PropertyStore ps) {
- super(ps);
- }
-
- @Override /* ContextBuilder */
- public OpenApiPartSerializer build() {
- return build(OpenApiPartSerializer.class);
- }
-
-
- //--------------------------------------------------------------------------------
- // Properties
- //--------------------------------------------------------------------------------
-
- /**
- * Configuration property: Decode <js>"%xx"</js> sequences.
- *
- * <p>
- * Specify <jk>true</jk> if URI encoded characters should be decoded, <jk>false</jk> if they've already been
- * decoded before being passed to this parser.
- *
- * <h5 class='section'>See Also:</h5>
- * <ul>
- * <li class='jf'>{@link UonParser#UON_decoding}
- * </ul>
- *
- * @param value
- * The new value for this property.
- * <br>Default is <jk>false</jk> for {@link UonParser}, <jk>true</jk> for {@link UrlEncodingParser}
- * @return This object (for method chaining).
- */
- public OpenApiPartSerializerBuilder schema(HttpPartSchema value) {
- return set(OAPI_schema, value);
- }
-
- @Override /* SerializerBuilder */
- public OpenApiPartSerializerBuilder addBeanTypes(boolean value) {
- super.addBeanTypes(value);
- return this;
- }
-
- @Override /* SerializerBuilder */
- public OpenApiPartSerializerBuilder addBeanTypes() {
- super.addBeanTypes();
- return this;
- }
-
- @Override /* SerializerBuilder */
- public OpenApiPartSerializerBuilder addRootType(boolean value) {
- super.addRootType(value);
- return this;
- }
-
- @Override /* SerializerBuilder */
- public OpenApiPartSerializerBuilder addRootType() {
- super.addRootType();
- return this;
- }
-
- @Override /* SerializerBuilder */
- public OpenApiPartSerializerBuilder detectRecursions(boolean value) {
- super.detectRecursions(value);
- return this;
- }
-
- @Override /* SerializerBuilder */
- public OpenApiPartSerializerBuilder detectRecursions() {
- super.detectRecursions();
- return this;
- }
-
- @Override /* SerializerBuilder */
- public OpenApiPartSerializerBuilder ignoreRecursions(boolean value) {
- super.ignoreRecursions(value);
- return this;
- }
-
- @Override /* SerializerBuilder */
- public OpenApiPartSerializerBuilder ignoreRecursions() {
- super.ignoreRecursions();
- return this;
- }
- @Override /* SerializerBuilder */
- public OpenApiPartSerializerBuilder initialDepth(int value) {
- super.initialDepth(value);
- return this;
- }
-
- @Override /* SerializerBuilder */
- public OpenApiPartSerializerBuilder listener(Class<? extends SerializerListener> value) {
- super.listener(value);
- return this;
- }
-
- @Override /* SerializerBuilder */
- public OpenApiPartSerializerBuilder maxDepth(int value) {
- super.maxDepth(value);
- return this;
- }
-
- @Override /* SerializerBuilder */
- public OpenApiPartSerializerBuilder maxIndent(int value) {
- super.maxIndent(value);
- return this;
- }
-
- @Override /* SerializerBuilder */
- public OpenApiPartSerializerBuilder quoteChar(char value) {
- super.quoteChar(value);
- return this;
- }
-
- @Override /* SerializerBuilder */
- public OpenApiPartSerializerBuilder sortCollections(boolean value) {
- super.sortCollections(value);
- return this;
- }
-
- @Override /* SerializerBuilder */
- public OpenApiPartSerializerBuilder sortCollections() {
- super.sortCollections();
- return this;
- }
-
- @Override /* SerializerBuilder */
- public OpenApiPartSerializerBuilder sortMaps(boolean value) {
- super.sortMaps(value);
- return this;
- }
-
- @Override /* SerializerBuilder */
- public OpenApiPartSerializerBuilder sortMaps() {
- super.sortMaps();
- return this;
- }
-
- @Override /* SerializerBuilder */
- public OpenApiPartSerializerBuilder sq() {
- super.sq();
- return this;
- }
-
- @Override /* SerializerBuilder */
- public OpenApiPartSerializerBuilder trimEmptyCollections(boolean value) {
- super.trimEmptyCollections(value);
- return this;
- }
-
- @Override /* SerializerBuilder */
- public OpenApiPartSerializerBuilder trimEmptyCollections() {
- super.trimEmptyCollections();
- return this;
- }
-
- @Override /* SerializerBuilder */
- public OpenApiPartSerializerBuilder trimEmptyMaps(boolean value) {
- super.trimEmptyMaps(value);
- return this;
- }
-
- @Override /* SerializerBuilder */
- public OpenApiPartSerializerBuilder trimEmptyMaps() {
- super.trimEmptyMaps();
- return this;
- }
-
- @Override /* SerializerBuilder */
- public OpenApiPartSerializerBuilder trimNullProperties(boolean value) {
- super.trimNullProperties(value);
- return this;
- }
-
- @Override /* SerializerBuilder */
- public OpenApiPartSerializerBuilder trimStrings(boolean value) {
- super.trimStrings(value);
- return this;
- }
-
- @Override /* SerializerBuilder */
- public OpenApiPartSerializerBuilder trimStrings() {
- super.trimStrings();
- return this;
- }
-
- @Override /* SerializerBuilder */
- public OpenApiPartSerializerBuilder uriContext(UriContext value) {
- super.uriContext(value);
- return this;
- }
-
- @Override /* SerializerBuilder */
- public OpenApiPartSerializerBuilder uriRelativity(UriRelativity value) {
- super.uriRelativity(value);
- return this;
- }
-
- @Override /* SerializerBuilder */
- public OpenApiPartSerializerBuilder uriResolution(UriResolution value) {
- super.uriResolution(value);
- return this;
- }
-
- @Override /* SerializerBuilder */
- public OpenApiPartSerializerBuilder useWhitespace(boolean value) {
- super.useWhitespace(value);
- return this;
- }
-
- @Override /* SerializerBuilder */
- public OpenApiPartSerializerBuilder useWhitespace() {
- super.useWhitespace();
- return this;
- }
-
- @Override /* SerializerBuilder */
- public OpenApiPartSerializerBuilder ws() {
- super.ws();
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public OpenApiPartSerializerBuilder beanClassVisibility(Visibility value) {
- super.beanClassVisibility(value);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public OpenApiPartSerializerBuilder beanConstructorVisibility(Visibility value) {
- super.beanConstructorVisibility(value);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public OpenApiPartSerializerBuilder beanDictionary(boolean append, Object...values) {
- super.beanDictionary(append, values);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public OpenApiPartSerializerBuilder beanDictionary(Class<?>...values) {
- super.beanDictionary(values);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public OpenApiPartSerializerBuilder beanDictionary(Object...values) {
- super.beanDictionary(values);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public OpenApiPartSerializerBuilder beanDictionaryRemove(Object...values) {
- super.beanDictionaryRemove(values);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public OpenApiPartSerializerBuilder beanFieldVisibility(Visibility value) {
- super.beanFieldVisibility(value);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public OpenApiPartSerializerBuilder beanFilters(boolean append, Object...values) {
- super.beanFilters(append, values);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public OpenApiPartSerializerBuilder beanFilters(Class<?>...values) {
- super.beanFilters(values);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public OpenApiPartSerializerBuilder beanFilters(Object...values) {
- super.beanFilters(values);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public OpenApiPartSerializerBuilder beanFiltersRemove(Object...values) {
- super.beanFiltersRemove(values);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public OpenApiPartSerializerBuilder beanMapPutReturnsOldValue(boolean value) {
- super.beanMapPutReturnsOldValue(value);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public OpenApiPartSerializerBuilder beanMapPutReturnsOldValue() {
- super.beanMapPutReturnsOldValue();
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public OpenApiPartSerializerBuilder beanMethodVisibility(Visibility value) {
- super.beanMethodVisibility(value);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public OpenApiPartSerializerBuilder beansRequireDefaultConstructor(boolean value) {
- super.beansRequireDefaultConstructor(value);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public OpenApiPartSerializerBuilder beansRequireDefaultConstructor() {
- super.beansRequireDefaultConstructor();
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public OpenApiPartSerializerBuilder beansRequireSerializable(boolean value) {
- super.beansRequireSerializable(value);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public OpenApiPartSerializerBuilder beansRequireSerializable() {
- super.beansRequireSerializable();
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public OpenApiPartSerializerBuilder beansRequireSettersForGetters(boolean value) {
- super.beansRequireSettersForGetters(value);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public OpenApiPartSerializerBuilder beansRequireSettersForGetters() {
- super.beansRequireSettersForGetters();
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public OpenApiPartSerializerBuilder beansRequireSomeProperties(boolean value) {
- super.beansRequireSomeProperties(value);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public OpenApiPartSerializerBuilder beanTypePropertyName(String value) {
- super.beanTypePropertyName(value);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public OpenApiPartSerializerBuilder debug() {
- super.debug();
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public <T> OpenApiPartSerializerBuilder example(Class<T> c, T o) {
- super.example(c, o);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public OpenApiPartSerializerBuilder ignoreInvocationExceptionsOnGetters(boolean value) {
- super.ignoreInvocationExceptionsOnGetters(value);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public OpenApiPartSerializerBuilder ignoreInvocationExceptionsOnGetters() {
- super.ignoreInvocationExceptionsOnGetters();
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public OpenApiPartSerializerBuilder ignoreInvocationExceptionsOnSetters(boolean value) {
- super.ignoreInvocationExceptionsOnSetters(value);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public OpenApiPartSerializerBuilder ignoreInvocationExceptionsOnSetters() {
- super.ignoreInvocationExceptionsOnSetters();
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public OpenApiPartSerializerBuilder ignorePropertiesWithoutSetters(boolean value) {
- super.ignorePropertiesWithoutSetters(value);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public OpenApiPartSerializerBuilder ignoreUnknownBeanProperties(boolean value) {
- super.ignoreUnknownBeanProperties(value);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public OpenApiPartSerializerBuilder ignoreUnknownBeanProperties() {
- super.ignoreUnknownBeanProperties();
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public OpenApiPartSerializerBuilder ignoreUnknownNullBeanProperties(boolean value) {
- super.ignoreUnknownNullBeanProperties(value);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public <T> OpenApiPartSerializerBuilder implClass(Class<T> interfaceClass, Class<? extends T> implClass) {
- super.implClass(interfaceClass, implClass);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public OpenApiPartSerializerBuilder implClasses(Map<String,Class<?>> values) {
- super.implClasses(values);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public OpenApiPartSerializerBuilder locale(Locale value) {
- super.locale(value);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public OpenApiPartSerializerBuilder mediaType(MediaType value) {
- super.mediaType(value);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public OpenApiPartSerializerBuilder notBeanClasses(boolean append, Object...values) {
- super.notBeanClasses(append, values);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public OpenApiPartSerializerBuilder notBeanClasses(Class<?>...values) {
- super.notBeanClasses(values);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public OpenApiPartSerializerBuilder notBeanClasses(Object...values) {
- super.notBeanClasses(values);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public OpenApiPartSerializerBuilder notBeanClassesRemove(Object...values) {
- super.notBeanClassesRemove(values);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public OpenApiPartSerializerBuilder notBeanPackages(boolean append, Object...values) {
- super.notBeanPackages(append, values);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public OpenApiPartSerializerBuilder notBeanPackages(Object...values) {
- super.notBeanPackages(values);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public OpenApiPartSerializerBuilder notBeanPackages(String...values) {
- super.notBeanPackages(values);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public OpenApiPartSerializerBuilder notBeanPackagesRemove(Object...values) {
- super.notBeanPackagesRemove(values);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public OpenApiPartSerializerBuilder pojoSwaps(boolean append, Object...values) {
- super.pojoSwaps(append, values);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public OpenApiPartSerializerBuilder pojoSwaps(Class<?>...values) {
- super.pojoSwaps(values);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public OpenApiPartSerializerBuilder pojoSwaps(Object...values) {
- super.pojoSwaps(values);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public OpenApiPartSerializerBuilder pojoSwapsRemove(Object...values) {
- super.pojoSwapsRemove(values);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public OpenApiPartSerializerBuilder sortProperties(boolean value) {
- super.sortProperties(value);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public OpenApiPartSerializerBuilder sortProperties() {
- super.sortProperties();
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public OpenApiPartSerializerBuilder timeZone(TimeZone value) {
- super.timeZone(value);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public OpenApiPartSerializerBuilder useEnumNames() {
- super.useEnumNames();
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public OpenApiPartSerializerBuilder useInterfaceProxies(boolean value) {
- super.useInterfaceProxies(value);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public OpenApiPartSerializerBuilder useJavaBeanIntrospector(boolean value) {
- super.useJavaBeanIntrospector(value);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public OpenApiPartSerializerBuilder useJavaBeanIntrospector() {
- super.useJavaBeanIntrospector();
- return this;
- }
-
- @Override /* ContextBuilder */
- public OpenApiPartSerializerBuilder set(String name, Object value) {
- super.set(name, value);
- return this;
- }
-
- @Override /* ContextBuilder */
- public OpenApiPartSerializerBuilder set(boolean append, String name, Object value) {
- super.set(append, name, value);
- return this;
- }
-
- @Override /* ContextBuilder */
- public OpenApiPartSerializerBuilder set(Map<String,Object> properties) {
- super.set(properties);
- return this;
- }
-
- @Override /* ContextBuilder */
- public OpenApiPartSerializerBuilder add(Map<String,Object> properties) {
- super.add(properties);
- return this;
- }
-
- @Override /* ContextBuilder */
- public OpenApiPartSerializerBuilder addTo(String name, Object value) {
- super.addTo(name, value);
- return this;
- }
-
- @Override /* ContextBuilder */
- public OpenApiPartSerializerBuilder addTo(String name, String key, Object value) {
- super.addTo(name, key, value);
- return this;
- }
-
- @Override /* ContextBuilder */
- public OpenApiPartSerializerBuilder removeFrom(String name, Object value) {
- super.removeFrom(name, value);
- return this;
- }
-
- @Override /* ContextBuilder */
- public OpenApiPartSerializerBuilder apply(PropertyStore copyFrom) {
- super.apply(copyFrom);
- return this;
- }
-}
\ No newline at end of file
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/SimplePartParser.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/SimplePartParser.java
index 6874d94..14b6b4d 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/SimplePartParser.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/SimplePartParser.java
@@ -40,7 +40,7 @@ import org.apache.juneau.parser.*;
* </ul>
* </ul>
*/
-public class SimplePartParser implements HttpPartParser {
+public class SimplePartParser extends BaseHttpPartParser {
//-------------------------------------------------------------------------------------------------------------------
// Predefined instances
@@ -54,40 +54,17 @@ public class SimplePartParser implements HttpPartParser {
//-------------------------------------------------------------------------------------------------------------------
@Override
- public SimplePartParserSession createSession(ParserSessionArgs args) {
- return new SimplePartParserSession();
- }
-
- /**
- * Create a new parser session on the properties defined on this context.
- *
- * <p>
- * Use this method for creating sessions if you don't need to override any
- * properties or locale/timezone currently set on this context.
- *
- * @return A new session object.
- */
- public SimplePartParserSession createSession() {
+ public SimplePartParserSession createPartSession(ParserSessionArgs args) {
return new SimplePartParserSession();
}
@Override /* HttpPartParser */
public <T> T parse(HttpPartType partType, HttpPartSchema schema, String in, Class<T> toType) throws ParseException, SchemaValidationException {
- return createSession().parse(partType, schema, in, toType);
+ return createPartSession().parse(partType, schema, in, toType);
}
@Override /* HttpPartParser */
public <T> T parse(HttpPartType partType, HttpPartSchema schema, String in, Type toType, Type...toTypeArgs) throws ParseException, SchemaValidationException {
- return createSession().parse(partType, schema, in, toType, toTypeArgs);
- }
-
- @Override /* HttpPartParser */
- public <T> T parse(HttpPartSchema schema, String in, Class<T> toType) throws ParseException, SchemaValidationException {
- return createSession().parse(null, schema, in, toType);
- }
-
- @Override /* HttpPartParser */
- public <T> T parse(HttpPartSchema schema, String in, Type toType, Type...toTypeArgs) throws ParseException, SchemaValidationException {
- return createSession().parse(null, schema, in, toType, toTypeArgs);
+ return createPartSession().parse(partType, schema, in, toType, toTypeArgs);
}
}
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/SimplePartParserSession.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/SimplePartParserSession.java
index 569e8cb..2ccd0b8 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/SimplePartParserSession.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/SimplePartParserSession.java
@@ -25,7 +25,7 @@ import org.apache.juneau.parser.*;
* This class is NOT thread safe.
* It is typically discarded after one-time use although it can be reused within the same thread.
*/
-public class SimplePartParserSession implements HttpPartParserSession {
+public class SimplePartParserSession extends BaseHttpPartParserSession {
@Override /* HttpPartParserSession */
public <T> T parse(HttpPartType partType, HttpPartSchema schema, String in, ClassMeta<T> toType) throws ParseException, SchemaValidationException {
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/SimplePartSerializer.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/SimplePartSerializer.java
index 4166060..7852015 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/SimplePartSerializer.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/SimplePartSerializer.java
@@ -21,7 +21,7 @@ import org.apache.juneau.serializer.*;
* <p>
* More precisely, uses the {@link ClassUtils#toString(Object)} method to stringify objects.
*/
-public class SimplePartSerializer implements HttpPartSerializer {
+public class SimplePartSerializer extends BaseHttpPartSerializer {
//-------------------------------------------------------------------------------------------------------------------
// Predefined instances
@@ -35,26 +35,12 @@ public class SimplePartSerializer implements HttpPartSerializer {
//-------------------------------------------------------------------------------------------------------------------
@Override
- public SimplePartSerializerSession createSession(SerializerSessionArgs args) {
+ public SimplePartSerializerSession createPartSession(SerializerSessionArgs args) {
return new SimplePartSerializerSession();
}
- /**
- * Convenience method for creating a new serializer session with default session args.
- *
- * @return A new session object.
- */
- public SimplePartSerializerSession createSession() {
- return new SimplePartSerializerSession();
- }
-
- @Override /* HttpPartSerializer */
- public String serialize(HttpPartType partType, HttpPartSchema schema, Object value) {
- return createSession().serialize(partType, schema, value);
- }
-
@Override /* HttpPartSerializer */
- public String serialize(HttpPartSchema schema, Object value) {
- return createSession().serialize(null, schema, value);
+ public String serialize(HttpPartType partType, HttpPartSchema schema, Object value) throws SchemaValidationException, SerializeException {
+ return createPartSession().serialize(partType, schema, value);
}
}
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/SimplePartSerializerSession.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/SimplePartSerializerSession.java
index 628f28d..950da2d 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/SimplePartSerializerSession.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/SimplePartSerializerSession.java
@@ -21,7 +21,7 @@ import org.apache.juneau.internal.*;
* This class is NOT thread safe.
* It is typically discarded after one-time use although it can be reused within the same thread.
*/
-public class SimplePartSerializerSession implements HttpPartSerializerSession {
+public class SimplePartSerializerSession extends BaseHttpPartSerializerSession {
//-------------------------------------------------------------------------------------------------------------------
// Instance
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/SimpleUonPartSerializerBuilder.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/SimpleUonPartSerializerBuilder.java
deleted file mode 100644
index f459fbf..0000000
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/SimpleUonPartSerializerBuilder.java
+++ /dev/null
@@ -1,639 +0,0 @@
-// ***************************************************************************************************************************
-// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
-// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
-// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
-// * with the License. You may obtain a copy of the License at *
-// * *
-// * http://www.apache.org/licenses/LICENSE-2.0 *
-// * *
-// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
-// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
-// * specific language governing permissions and limitations under the License. *
-// ***************************************************************************************************************************
-package org.apache.juneau.httppart;
-
-import java.util.*;
-
-import org.apache.juneau.*;
-import org.apache.juneau.http.*;
-import org.apache.juneau.serializer.*;
-import org.apache.juneau.uon.*;
-
-/**
- * Builder class for building instances of {@link SimpleUonPartSerializer}.
- */
-public class SimpleUonPartSerializerBuilder extends UonPartSerializerBuilder {
-
- /**
- * Constructor, default settings.
- */
- public SimpleUonPartSerializerBuilder() {
- super();
- }
-
- /**
- * Constructor.
- *
- * @param ps The initial configuration settings for this builder.
- */
- public SimpleUonPartSerializerBuilder(PropertyStore ps) {
- super(ps);
- }
-
- @Override /* ContextBuilder */
- public SimpleUonPartSerializer build() {
- return build(SimpleUonPartSerializer.class);
- }
-
-
- //--------------------------------------------------------------------------------
- // Properties
- //--------------------------------------------------------------------------------
-
- @Override /* UonPartSerializerBuilder */
- public SimpleUonPartSerializerBuilder paramFormat(ParamFormat value) {
- super.paramFormat(value);
- return this;
- }
-
- @Override /* UonPartSerializerBuilder */
- public SimpleUonPartSerializerBuilder paramFormatPlain() {
- super.paramFormatPlain();
- return this;
- }
-
- @Override /* UonSerializerBuilder */
- public SimpleUonPartSerializerBuilder encoding(boolean value) {
- super.encoding(value);
- return this;
- }
-
- @Override /* UonSerializerBuilder */
- public SimpleUonPartSerializerBuilder encoding() {
- super.encoding();
- return this;
- }
-
- @Override /* SerializerBuilder */
- public SimpleUonPartSerializerBuilder addBeanTypes(boolean value) {
- super.addBeanTypes(value);
- return this;
- }
-
- @Override /* SerializerBuilder */
- public SimpleUonPartSerializerBuilder addBeanTypes() {
- super.addBeanTypes();
- return this;
- }
-
- @Override /* SerializerBuilder */
- public SimpleUonPartSerializerBuilder addRootType(boolean value) {
- super.addRootType(value);
- return this;
- }
-
- @Override /* SerializerBuilder */
- public SimpleUonPartSerializerBuilder addRootType() {
- super.addRootType();
- return this;
- }
-
- @Override /* SerializerBuilder */
- public SimpleUonPartSerializerBuilder detectRecursions(boolean value) {
- super.detectRecursions(value);
- return this;
- }
-
- @Override /* SerializerBuilder */
- public SimpleUonPartSerializerBuilder detectRecursions() {
- super.detectRecursions();
- return this;
- }
-
- @Override /* SerializerBuilder */
- public SimpleUonPartSerializerBuilder ignoreRecursions(boolean value) {
- super.ignoreRecursions(value);
- return this;
- }
-
- @Override /* SerializerBuilder */
- public SimpleUonPartSerializerBuilder ignoreRecursions() {
- super.ignoreRecursions();
- return this;
- }
- @Override /* SerializerBuilder */
- public SimpleUonPartSerializerBuilder initialDepth(int value) {
- super.initialDepth(value);
- return this;
- }
-
- @Override /* SerializerBuilder */
- public SimpleUonPartSerializerBuilder listener(Class<? extends SerializerListener> value) {
- super.listener(value);
- return this;
- }
-
- @Override /* SerializerBuilder */
- public SimpleUonPartSerializerBuilder maxDepth(int value) {
- super.maxDepth(value);
- return this;
- }
-
- @Override /* SerializerBuilder */
- public SimpleUonPartSerializerBuilder maxIndent(int value) {
- super.maxIndent(value);
- return this;
- }
-
- @Override /* SerializerBuilder */
- public SimpleUonPartSerializerBuilder quoteChar(char value) {
- super.quoteChar(value);
- return this;
- }
-
- @Override /* SerializerBuilder */
- public SimpleUonPartSerializerBuilder sortCollections(boolean value) {
- super.sortCollections(value);
- return this;
- }
-
- @Override /* SerializerBuilder */
- public SimpleUonPartSerializerBuilder sortCollections() {
- super.sortCollections();
- return this;
- }
-
- @Override /* SerializerBuilder */
- public SimpleUonPartSerializerBuilder sortMaps(boolean value) {
- super.sortMaps(value);
- return this;
- }
-
- @Override /* SerializerBuilder */
- public SimpleUonPartSerializerBuilder sortMaps() {
- super.sortMaps();
- return this;
- }
-
- @Override /* SerializerBuilder */
- public SimpleUonPartSerializerBuilder sq() {
- super.sq();
- return this;
- }
-
- @Override /* SerializerBuilder */
- public SimpleUonPartSerializerBuilder trimEmptyCollections(boolean value) {
- super.trimEmptyCollections(value);
- return this;
- }
-
- @Override /* SerializerBuilder */
- public SimpleUonPartSerializerBuilder trimEmptyCollections() {
- super.trimEmptyCollections();
- return this;
- }
-
- @Override /* SerializerBuilder */
- public SimpleUonPartSerializerBuilder trimEmptyMaps(boolean value) {
- super.trimEmptyMaps(value);
- return this;
- }
-
- @Override /* SerializerBuilder */
- public SimpleUonPartSerializerBuilder trimEmptyMaps() {
- super.trimEmptyMaps();
- return this;
- }
-
- @Override /* SerializerBuilder */
- public SimpleUonPartSerializerBuilder trimNullProperties(boolean value) {
- super.trimNullProperties(value);
- return this;
- }
-
- @Override /* SerializerBuilder */
- public SimpleUonPartSerializerBuilder trimStrings(boolean value) {
- super.trimStrings(value);
- return this;
- }
-
- @Override /* SerializerBuilder */
- public SimpleUonPartSerializerBuilder trimStrings() {
- super.trimStrings();
- return this;
- }
-
- @Override /* SerializerBuilder */
- public SimpleUonPartSerializerBuilder uriContext(UriContext value) {
- super.uriContext(value);
- return this;
- }
-
- @Override /* SerializerBuilder */
- public SimpleUonPartSerializerBuilder uriRelativity(UriRelativity value) {
- super.uriRelativity(value);
- return this;
- }
-
- @Override /* SerializerBuilder */
- public SimpleUonPartSerializerBuilder uriResolution(UriResolution value) {
- super.uriResolution(value);
- return this;
- }
-
- @Override /* SerializerBuilder */
- public SimpleUonPartSerializerBuilder useWhitespace(boolean value) {
- super.useWhitespace(value);
- return this;
- }
-
- @Override /* SerializerBuilder */
- public SimpleUonPartSerializerBuilder useWhitespace() {
- super.useWhitespace();
- return this;
- }
-
- @Override /* SerializerBuilder */
- public SimpleUonPartSerializerBuilder ws() {
- super.ws();
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public SimpleUonPartSerializerBuilder beanClassVisibility(Visibility value) {
- super.beanClassVisibility(value);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public SimpleUonPartSerializerBuilder beanConstructorVisibility(Visibility value) {
- super.beanConstructorVisibility(value);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public SimpleUonPartSerializerBuilder beanDictionary(boolean append, Object...values) {
- super.beanDictionary(append, values);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public SimpleUonPartSerializerBuilder beanDictionary(Class<?>...values) {
- super.beanDictionary(values);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public SimpleUonPartSerializerBuilder beanDictionary(Object...values) {
- super.beanDictionary(values);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public SimpleUonPartSerializerBuilder beanDictionaryRemove(Object...values) {
- super.beanDictionaryRemove(values);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public SimpleUonPartSerializerBuilder beanFieldVisibility(Visibility value) {
- super.beanFieldVisibility(value);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public SimpleUonPartSerializerBuilder beanFilters(boolean append, Object...values) {
- super.beanFilters(append, values);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public SimpleUonPartSerializerBuilder beanFilters(Class<?>...values) {
- super.beanFilters(values);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public SimpleUonPartSerializerBuilder beanFilters(Object...values) {
- super.beanFilters(values);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public SimpleUonPartSerializerBuilder beanFiltersRemove(Object...values) {
- super.beanFiltersRemove(values);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public SimpleUonPartSerializerBuilder beanMapPutReturnsOldValue(boolean value) {
- super.beanMapPutReturnsOldValue(value);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public SimpleUonPartSerializerBuilder beanMapPutReturnsOldValue() {
- super.beanMapPutReturnsOldValue();
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public SimpleUonPartSerializerBuilder beanMethodVisibility(Visibility value) {
- super.beanMethodVisibility(value);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public SimpleUonPartSerializerBuilder beansRequireDefaultConstructor(boolean value) {
- super.beansRequireDefaultConstructor(value);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public SimpleUonPartSerializerBuilder beansRequireDefaultConstructor() {
- super.beansRequireDefaultConstructor();
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public SimpleUonPartSerializerBuilder beansRequireSerializable(boolean value) {
- super.beansRequireSerializable(value);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public SimpleUonPartSerializerBuilder beansRequireSerializable() {
- super.beansRequireSerializable();
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public SimpleUonPartSerializerBuilder beansRequireSettersForGetters(boolean value) {
- super.beansRequireSettersForGetters(value);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public SimpleUonPartSerializerBuilder beansRequireSettersForGetters() {
- super.beansRequireSettersForGetters();
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public SimpleUonPartSerializerBuilder beansRequireSomeProperties(boolean value) {
- super.beansRequireSomeProperties(value);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public SimpleUonPartSerializerBuilder beanTypePropertyName(String value) {
- super.beanTypePropertyName(value);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public SimpleUonPartSerializerBuilder debug() {
- super.debug();
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public <T> SimpleUonPartSerializerBuilder example(Class<T> c, T o) {
- super.example(c, o);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public SimpleUonPartSerializerBuilder ignoreInvocationExceptionsOnGetters(boolean value) {
- super.ignoreInvocationExceptionsOnGetters(value);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public SimpleUonPartSerializerBuilder ignoreInvocationExceptionsOnGetters() {
- super.ignoreInvocationExceptionsOnGetters();
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public SimpleUonPartSerializerBuilder ignoreInvocationExceptionsOnSetters(boolean value) {
- super.ignoreInvocationExceptionsOnSetters(value);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public SimpleUonPartSerializerBuilder ignoreInvocationExceptionsOnSetters() {
- super.ignoreInvocationExceptionsOnSetters();
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public SimpleUonPartSerializerBuilder ignorePropertiesWithoutSetters(boolean value) {
- super.ignorePropertiesWithoutSetters(value);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public SimpleUonPartSerializerBuilder ignoreUnknownBeanProperties(boolean value) {
- super.ignoreUnknownBeanProperties(value);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public SimpleUonPartSerializerBuilder ignoreUnknownBeanProperties() {
- super.ignoreUnknownBeanProperties();
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public SimpleUonPartSerializerBuilder ignoreUnknownNullBeanProperties(boolean value) {
- super.ignoreUnknownNullBeanProperties(value);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public <T> SimpleUonPartSerializerBuilder implClass(Class<T> interfaceClass, Class<? extends T> implClass) {
- super.implClass(interfaceClass, implClass);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public SimpleUonPartSerializerBuilder implClasses(Map<String,Class<?>> values) {
- super.implClasses(values);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public SimpleUonPartSerializerBuilder locale(Locale value) {
- super.locale(value);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public SimpleUonPartSerializerBuilder mediaType(MediaType value) {
- super.mediaType(value);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public SimpleUonPartSerializerBuilder notBeanClasses(boolean append, Object...values) {
- super.notBeanClasses(append, values);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public SimpleUonPartSerializerBuilder notBeanClasses(Class<?>...values) {
- super.notBeanClasses(values);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public SimpleUonPartSerializerBuilder notBeanClasses(Object...values) {
- super.notBeanClasses(values);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public SimpleUonPartSerializerBuilder notBeanClassesRemove(Object...values) {
- super.notBeanClassesRemove(values);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public SimpleUonPartSerializerBuilder notBeanPackages(boolean append, Object...values) {
- super.notBeanPackages(append, values);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public SimpleUonPartSerializerBuilder notBeanPackages(Object...values) {
- super.notBeanPackages(values);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public SimpleUonPartSerializerBuilder notBeanPackages(String...values) {
- super.notBeanPackages(values);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public SimpleUonPartSerializerBuilder notBeanPackagesRemove(Object...values) {
- super.notBeanPackagesRemove(values);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public SimpleUonPartSerializerBuilder pojoSwaps(boolean append, Object...values) {
- super.pojoSwaps(append, values);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public SimpleUonPartSerializerBuilder pojoSwaps(Class<?>...values) {
- super.pojoSwaps(values);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public SimpleUonPartSerializerBuilder pojoSwaps(Object...values) {
- super.pojoSwaps(values);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public SimpleUonPartSerializerBuilder pojoSwapsRemove(Object...values) {
- super.pojoSwapsRemove(values);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public SimpleUonPartSerializerBuilder sortProperties(boolean value) {
- super.sortProperties(value);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public SimpleUonPartSerializerBuilder sortProperties() {
- super.sortProperties();
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public SimpleUonPartSerializerBuilder timeZone(TimeZone value) {
- super.timeZone(value);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public SimpleUonPartSerializerBuilder useEnumNames() {
- super.useEnumNames();
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public SimpleUonPartSerializerBuilder useInterfaceProxies(boolean value) {
- super.useInterfaceProxies(value);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public SimpleUonPartSerializerBuilder useJavaBeanIntrospector(boolean value) {
- super.useJavaBeanIntrospector(value);
- return this;
- }
-
- @Override /* BeanContextBuilder */
- public SimpleUonPartSerializerBuilder useJavaBeanIntrospector() {
- super.useJavaBeanIntrospector();
- return this;
- }
-
- @Override /* ContextBuilder */
- public SimpleUonPartSerializerBuilder set(String name, Object value) {
- super.set(name, value);
- return this;
- }
-
- @Override /* ContextBuilder */
- public SimpleUonPartSerializerBuilder set(boolean append, String name, Object value) {
- super.set(append, name, value);
- return this;
- }
-
- @Override /* ContextBuilder */
- public SimpleUonPartSerializerBuilder set(Map<String,Object> properties) {
- super.set(properties);
- return this;
- }
-
- @Override /* ContextBuilder */
- public SimpleUonPartSerializerBuilder add(Map<String,Object> properties) {
- super.add(properties);
- return this;
- }
-
- @Override /* ContextBuilder */
- public SimpleUonPartSerializerBuilder addTo(String name, Object value) {
- super.addTo(name, value);
- return this;
- }
-
- @Override /* ContextBuilder */
- public SimpleUonPartSerializerBuilder addTo(String name, String key, Object value) {
- super.addTo(name, key, value);
- return this;
- }
-
- @Override /* ContextBuilder */
- public SimpleUonPartSerializerBuilder removeFrom(String name, Object value) {
- super.removeFrom(name, value);
- return this;
- }
-
- @Override /* ContextBuilder */
- public SimpleUonPartSerializerBuilder apply(PropertyStore copyFrom) {
- super.apply(copyFrom);
- return this;
- }
-}
\ No newline at end of file
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/UonPartParser.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/UonPartParser.java
deleted file mode 100644
index fcbe670..0000000
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/UonPartParser.java
+++ /dev/null
@@ -1,118 +0,0 @@
-// ***************************************************************************************************************************
-// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
-// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
-// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
-// * with the License. You may obtain a copy of the License at *
-// * *
-// * http://www.apache.org/licenses/LICENSE-2.0 *
-// * *
-// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
-// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
-// * specific language governing permissions and limitations under the License. *
-// ***************************************************************************************************************************
-package org.apache.juneau.httppart;
-
-import java.lang.reflect.*;
-
-import org.apache.juneau.*;
-import org.apache.juneau.parser.*;
-import org.apache.juneau.uon.*;
-
-/**
- * Parses HTTP headers, query/form-data parameters, and path variables into POJOs.
- *
- * <p>
- * This parser expects UON notation for all parts by default.
- */
-public class UonPartParser extends UonParser implements HttpPartParser {
-
- //-------------------------------------------------------------------------------------------------------------------
- // Predefined instances
- //-------------------------------------------------------------------------------------------------------------------
-
- /** Reusable instance of {@link UonPartParser}. */
- public static final UonPartParser DEFAULT = new UonPartParser(PropertyStore.DEFAULT);
-
-
- //-------------------------------------------------------------------------------------------------------------------
- // Instance
- //-------------------------------------------------------------------------------------------------------------------
-
- /**
- * Constructor.
- *
- * @param ps The property store containing all the settings for this object.
- */
- public UonPartParser(PropertyStore ps) {
- super(
- ps.builder()
- .build(),
- "application/x-www-form-urlencoded"
- );
- }
-
- @Override /* Context */
- public UonPartParserBuilder builder() {
- return new UonPartParserBuilder(getPropertyStore());
- }
-
- /**
- * Instantiates a new clean-slate {@link UonPartParserBuilder} object.
- *
- * <p>
- * This is equivalent to simply calling <code><jk>new</jk> UonPartParserBuilder()</code>.
- *
- * <p>
- * Note that this method creates a builder initialized to all default settings, whereas {@link #builder()} copies
- * the settings of the object called on.
- *
- * @return A new {@link UonPartParserBuilder} object.
- */
- public static UonPartParserBuilder create() {
- return new UonPartParserBuilder();
- }
-
- //-------------------------------------------------------------------------------------------------------------------
- // Entry point methods
- //-------------------------------------------------------------------------------------------------------------------
-
- @Override
- public UonPartParserSession createSession(ParserSessionArgs args) {
- return new UonPartParserSession(this, args);
- }
-
- @Override
- public UonPartParserSession createSession() {
- return new UonPartParserSession(this, ParserSessionArgs.DEFAULT);
- }
-//
-// @Override /* HttpPartParser */
-// public <T> T parse(HttpPartType partType, HttpPartSchema schema, String in, ClassMeta<T> toType) throws ParseException, SchemaValidationException {
-// return createSession().parse(partType, schema, in, toType);
-// }
-
- @Override /* HttpPartParser */
- public <T> T parse(HttpPartType partType, HttpPartSchema schema, String in, Class<T> toType) throws ParseException, SchemaValidationException {
- return createSession().parse(partType, schema, in, toType);
- }
-
- @Override /* HttpPartParser */
- public <T> T parse(HttpPartType partType, HttpPartSchema schema, String in, Type toType, Type...toTypeArgs) throws ParseException, SchemaValidationException {
- return createSession().parse(partType, schema, in, toType, toTypeArgs);
- }
-//
-// @Override /* HttpPartParser */
-// public <T> T parse(HttpPartSchema schema, String in, ClassMeta<T> toType) throws ParseException, SchemaValidationException {
-// return createSession().parse(null, schema, in, toType);
-// }
-
- @Override /* HttpPartParser */
- public <T> T parse(HttpPartSchema schema, String in, Class<T> toType) throws ParseException, SchemaValidationException {
- return createSession().parse(null, schema, in, toType);
- }
-
- @Override /* HttpPartParser */
- public <T> T parse(HttpPartSchema schema, String in, Type toType, Type...toTypeArgs) throws ParseException, SchemaValidationException {
- return createSession().parse(null, schema, in, toType, toTypeArgs);
- }
-}
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/UonPartParserSession.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/UonPartParserSession.java
deleted file mode 100644
index 0c7d2b7..0000000
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/UonPartParserSession.java
+++ /dev/null
@@ -1,132 +0,0 @@
-// ***************************************************************************************************************************
-// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
-// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
-// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
-// * with the License. You may obtain a copy of the License at *
-// * *
-// * http://www.apache.org/licenses/LICENSE-2.0 *
-// * *
-// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
-// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
-// * specific language governing permissions and limitations under the License. *
-// ***************************************************************************************************************************
-package org.apache.juneau.httppart;
-
-import static org.apache.juneau.internal.StringUtils.*;
-
-import java.lang.reflect.*;
-
-import org.apache.juneau.*;
-import org.apache.juneau.parser.*;
-import org.apache.juneau.uon.*;
-
-/**
- * Session object that lives for the duration of a single use of {@link UonPartParser}.
- *
- * <p>
- * This class is NOT thread safe.
- * It is typically discarded after one-time use although it can be reused within the same thread.
- */
-@SuppressWarnings({ "unchecked" })
-public class UonPartParserSession extends UonParserSession implements HttpPartParserSession {
-
- /**
- * Create a new session using properties specified in the context.
- *
- * @param ctx
- * The context creating this session object.
- * The context contains all the configuration settings for this object.
- * @param args
- * Runtime session arguments.
- */
- protected UonPartParserSession(UonPartParser ctx, ParserSessionArgs args) {
- super(ctx, args);
- }
-
- @Override /* HttpPartParser */
- public <T> T parse(HttpPartType partType, HttpPartSchema schema, String in, ClassMeta<T> toType) throws ParseException, SchemaValidationException {
- if (in == null)
- return null;
- if (toType.isString() && in.length() > 0) {
- // Shortcut - If we're returning a string and the value doesn't start with "'" or is "null", then
- // just return the string since it's a plain value.
- // This allows us to bypass the creation of a UonParserSession object.
- char x = firstNonWhitespaceChar(in);
- if (x != '\'' && x != 'n' && in.indexOf('~') == -1)
- return (T)in;
- if (x == 'n' && "null".equals(in))
- return null;
- }
- try (ParserPipe pipe = createPipe(in)) {
- try (UonReader r = getUonReader(pipe, false)) {
- return parseAnything(toType, r, null, true, null);
- }
- } catch (ParseException e) {
- throw e;
- } catch (Exception e) {
- throw new ParseException(e);
- }
- }
-
- @Override /* HttpPartParser */
- public <T> T parse(HttpPartType partType, HttpPartSchema schema, String in, Class<T> toType) throws ParseException, SchemaValidationException {
- return parse(null, schema, in, getClassMeta(toType));
- }
-
- @Override /* HttpPartParser */
- public <T> T parse(HttpPartType partType, HttpPartSchema schema, String in, Type toType, Type...toTypeArgs) throws ParseException, SchemaValidationException {
- return (T)parse(null, schema, in, getClassMeta(toType, toTypeArgs));
- }
-
- /**
- * Convenience method for parsing a part.
- *
- * @param schema
- * Schema information about the part.
- * <br>May be <jk>null</jk>.
- * <br>Not all part parsers use the schema information.
- * @param in The input being parsed.
- * @param toType The POJO type being created.
- * @return The parsed value.
- * @throws ParseException If a problem occurred while trying to parse the input.
- * @throws SchemaValidationException If the input or resulting HTTP part object fails schema validation.
- */
- public <T> T parse(HttpPartSchema schema, String in, Class<T> toType) throws ParseException, SchemaValidationException {
- return parse(null, schema, in, getClassMeta(toType));
- }
-
- /**
- * Convenience method for parsing a part.
- *
- * @param schema
- * Schema information about the part.
- * <br>May be <jk>null</jk>.
- * <br>Not all part parsers use the schema information.
- * @param in The input being parsed.
- * @param toType The POJO type being created.
- * @return The parsed value.
- * @throws ParseException If a problem occurred while trying to parse the input.
- * @throws SchemaValidationException If the input or resulting HTTP part object fails schema validation.
- */
- public <T> T parse(HttpPartSchema schema, String in, ClassMeta<T> toType) throws ParseException, SchemaValidationException {
- return parse(null, schema, in, toType);
- }
-
- /**
- * Convenience method for parsing a part.
- *
- * @param schema
- * Schema information about the part.
- * <br>May be <jk>null</jk>.
- * <br>Not all part parsers use the schema information.
- * @param in The input being parsed.
- * @param toType The POJO type being created.
- * @param toTypeArgs The type arguments for the POJO collection or map type being created.
- * @return The parsed value.
- * @throws ParseException If a problem occurred while trying to parse the input.
- * @throws SchemaValidationException If the input or resulting HTTP part object fails schema validation.
- */
- public <T> T parse(HttpPartSchema schema, String in, Type toType, Type...toTypeArgs) throws ParseException, SchemaValidationException {
- return (T)parse(null, schema, in, getClassMeta(toType, toTypeArgs));
- }
-}
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/UonPartSerializerSession.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/UonPartSerializerSession.java
deleted file mode 100644
index cef43bf..0000000
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/UonPartSerializerSession.java
+++ /dev/null
@@ -1,65 +0,0 @@
-// ***************************************************************************************************************************
-// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
-// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
-// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
-// * with the License. You may obtain a copy of the License at *
-// * *
-// * http://www.apache.org/licenses/LICENSE-2.0 *
-// * *
-// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
-// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
-// * specific language governing permissions and limitations under the License. *
-// ***************************************************************************************************************************
-package org.apache.juneau.httppart;
-
-import java.io.*;
-
-import org.apache.juneau.*;
-import org.apache.juneau.internal.*;
-import org.apache.juneau.serializer.*;
-import org.apache.juneau.uon.*;
-
-/**
- * Session object that lives for the duration of a single use of {@link UonPartSerializer}.
- *
- * <p>
- * This class is NOT thread safe.
- * It is typically discarded after one-time use although it can be reused within the same thread.
- */
-public class UonPartSerializerSession extends UonSerializerSession implements HttpPartSerializerSession {
-
- /**
- * Create a new session using properties specified in the context.
- *
- * @param ctx
- * The context creating this session object.
- * The context contains all the configuration settings for this object.
- * @param args
- * Runtime session arguments.
- */
- protected UonPartSerializerSession(UonPartSerializer ctx, SerializerSessionArgs args) {
- super(ctx, false, args);
- }
-
- @Override /* PartSerializer */
- public String serialize(HttpPartType type, HttpPartSchema schema, Object value) throws SerializeException, SchemaValidationException {
- try {
- // Shortcut for simple types.
- ClassMeta<?> cm = getClassMetaForObject(value);
- if (cm != null) {
- if (cm.isNumber() || cm.isBoolean())
- return ClassUtils.toString(value);
- if (cm.isString()) {
- String s = ClassUtils.toString(value);
- if (s.isEmpty() || ! UonUtils.needsQuotes(s))
- return s;
- }
- }
- StringWriter w = new StringWriter();
- super.serialize(value, w);
- return w.toString();
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-}
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/bean/ResponseBeanMeta.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/bean/ResponseBeanMeta.java
index 59a0184..eab256f 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/bean/ResponseBeanMeta.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/bean/ResponseBeanMeta.java
@@ -116,14 +116,12 @@ public class ResponseBeanMeta {
private final HttpPartSerializer partSerializer;
private final HttpPartParser partParser;
private final HttpPartSchema schema;
- private final boolean usePartSerializer;
ResponseBeanMeta(Builder b) {
this.cm = b.cm;
this.code = b.code;
this.partSerializer = newInstance(HttpPartSerializer.class, b.partSerializer, true, b.ps);
this.partParser = newInstance(HttpPartParser.class, b.partParser, true, b.ps);
- this.usePartSerializer = b.usePartSerializer;
this.schema = b.schema.build();
Map<String,ResponseBeanPropertyMeta> properties = new LinkedHashMap<>();
@@ -154,7 +152,6 @@ public class ResponseBeanMeta {
Class<? extends HttpPartSerializer> partSerializer;
Class<? extends HttpPartParser> partParser;
HttpPartSchemaBuilder schema = HttpPartSchema.create();
- boolean usePartSerializer;
Map<String,ResponseBeanPropertyMeta.Builder> headerMethods = new LinkedHashMap<>();
ResponseBeanPropertyMeta.Builder bodyMethod;
@@ -202,7 +199,6 @@ public class ResponseBeanMeta {
code = a.value()[0];
if (a.code().length > 0)
code = a.code()[0];
- usePartSerializer = AnnotationUtils.usePartSerializer(a);
schema.apply(a.schema());
}
return this;
@@ -259,15 +255,6 @@ public class ResponseBeanMeta {
}
/**
- * Returns the flag for whether the part serializer should be used to serialize this response.
- *
- * @return The flag for whether the part serializer should be used to serialize this response.
- */
- public boolean isUsePartSerializer() {
- return usePartSerializer;
- }
-
- /**
* Returns the part serializer to use to serialize this response.
*
* @return The part serializer to use to serialize this response.
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/ClassUtils.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/ClassUtils.java
index 9b4ed01..493ccb2 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/ClassUtils.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/ClassUtils.java
@@ -215,6 +215,16 @@ public final class ClassUtils {
}
/**
+ * Returns <jk>true</jk> if the {@link #getPrimitiveWrapper(Class)} class returns a value for the specified class.
+ *
+ * @param c The class.
+ * @return <jk>true</jk> if the {@link #getPrimitiveWrapper(Class)} class returns a value for the specified class.
+ */
+ public static boolean hasPrimitiveWrapper(Class<?> c) {
+ return pmap1.containsKey(c);
+ }
+
+ /**
* If the specified class is a primitive (e.g. <code><jk>int</jk>.<jk>class</jk></code>) returns it's wrapper class
* (e.g. <code>Integer.<jk>class</jk></code>).
*
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/TransformCache.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/TransformCache.java
index 8381305..e7753a6 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/TransformCache.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/TransformCache.java
@@ -134,15 +134,16 @@ public class TransformCache {
}
};
} else if (ic == String.class) {
- if (oc.isEnum()) {
+ final Class<?> oc2 = hasPrimitiveWrapper(oc) ? getPrimitiveWrapper(oc) : oc;
+ if (oc2.isEnum()) {
t = new Transform<String,O>() {
@Override
public O transform(Object outer, String in) {
- return (O)Enum.valueOf((Class<? extends Enum>)oc, in);
+ return (O)Enum.valueOf((Class<? extends Enum>)oc2, in);
}
};
} else {
- final Method fromStringMethod = ClassUtils.findPublicFromStringMethod(oc);
+ final Method fromStringMethod = findPublicFromStringMethod(oc2);
if (fromStringMethod != null) {
t = new Transform<String,O>() {
@Override
@@ -159,9 +160,9 @@ public class TransformCache {
}
if (t == null) {
- Method createMethod = ClassUtils.findPublicStaticCreateMethod(oc, ic, "create");
+ Method createMethod = findPublicStaticCreateMethod(oc, ic, "create");
if (createMethod == null)
- createMethod = ClassUtils.findPublicStaticCreateMethod(oc, ic, "from" + ic.getSimpleName());
+ createMethod = findPublicStaticCreateMethod(oc, ic, "from" + ic.getSimpleName());
if (createMethod != null) {
final Method cm = createMethod;
t = new Transform<I,O>() {
@@ -175,9 +176,9 @@ public class TransformCache {
}
};
} else {
- final Constructor<?> c = ClassUtils.findPublicConstructor(oc, ic);
+ final Constructor<?> c = findPublicConstructor(oc, ic);
final boolean isMemberClass = oc.isMemberClass() && ! isStatic(oc);
- if (c != null && ! ClassUtils.isDeprecated(c)) {
+ if (c != null && ! isDeprecated(c)) {
t = new Transform<I,O>() {
@Override
public O transform(Object outer, I in) {
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/SimpleUonPartSerializer.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/oapi/OpenApiParser.java
similarity index 57%
rename from juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/SimpleUonPartSerializer.java
rename to juneau-core/juneau-marshall/src/main/java/org/apache/juneau/oapi/OpenApiParser.java
index a20709c..666156a 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/SimpleUonPartSerializer.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/oapi/OpenApiParser.java
@@ -10,33 +10,29 @@
// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
// * specific language governing permissions and limitations under the License. *
// ***************************************************************************************************************************
-package org.apache.juneau.httppart;
+package org.apache.juneau.oapi;
import org.apache.juneau.*;
-import org.apache.juneau.serializer.*;
+import org.apache.juneau.parser.*;
import org.apache.juneau.uon.*;
/**
- * An extension of {@link UonPartSerializer} with plain-text string handling.
+ * OpenAPI part parser.
*
- * <p>
- * Uses UON notation for beans and maps (serialized as UON objects), and plain text for everything else.
- * <br>Collections/arrays are also serialized as comma-delimited lists.
- *
- * <p>
- * The downside to this class vs. {@link UonPartSerializer} is that you may lose type information on the parse side.
- * For example, it's not possible to distinguish between the boolean <jk>false</jk> and the string <js>"false"</js>.
- * The same is true of numbers. Also, whitespace in strings or strings containing single quotes may get lost if using
- * the {@link UonPartParser} to process them.
+ * <h5 class='section'>See Also:</h5>
+ * <ul>
+ * <li class='link'>{@doc juneau-marshall.OpenApiDetails.Parsers}
+ * </ul>
*/
-public class SimpleUonPartSerializer extends UonPartSerializer {
+public class OpenApiParser extends UonParser {
//-------------------------------------------------------------------------------------------------------------------
// Predefined instances
//-------------------------------------------------------------------------------------------------------------------
- /** Reusable instance of {@link SimpleUonPartSerializer}, all default settings. */
- public static final SimpleUonPartSerializer DEFAULT = new SimpleUonPartSerializer(PropertyStore.DEFAULT);
+ /** Reusable instance of {@link OpenApiParser}. */
+ public static final OpenApiParser DEFAULT = new OpenApiParser(PropertyStore.DEFAULT);
+
//-------------------------------------------------------------------------------------------------------------------
// Instance
@@ -45,46 +41,56 @@ public class SimpleUonPartSerializer extends UonPartSerializer {
/**
* Constructor.
*
+ * @param ps The property store containing all the settings for this object.
+ */
+ public OpenApiParser(PropertyStore ps) {
+ this(ps, "text/openapi");
+ }
+
+ /**
+ * Constructor.
+ *
* @param ps
* The property store containing all the settings for this object.
+ * @param consumes
+ * The list of media types that this parser consumes (e.g. <js>"application/json"</js>, <js>"*​/json"</js>).
*/
- public SimpleUonPartSerializer(PropertyStore ps) {
- super(
- ps.builder()
- .set(UON_paramFormat, ParamFormat.PLAINTEXT)
- .build()
- );
+ public OpenApiParser(PropertyStore ps, String...consumes) {
+ super(ps, consumes);
}
@Override /* Context */
- public SimpleUonPartSerializerBuilder builder() {
- return new SimpleUonPartSerializerBuilder(getPropertyStore());
+ public OpenApiParserBuilder builder() {
+ return new OpenApiParserBuilder(getPropertyStore());
}
/**
- * Instantiates a new clean-slate {@link SimpleUonPartSerializerBuilder} object.
+ * Instantiates a new clean-slate {@link OpenApiParserBuilder} object.
+ *
+ * <p>
+ * This is equivalent to simply calling <code><jk>new</jk> UonPartParserBuilder()</code>.
*
* <p>
* Note that this method creates a builder initialized to all default settings, whereas {@link #builder()} copies
* the settings of the object called on.
*
- * @return A new {@link UonPartSerializerBuilder} object.
+ * @return A new {@link OpenApiParserBuilder} object.
*/
- public static SimpleUonPartSerializerBuilder create() {
- return new SimpleUonPartSerializerBuilder();
+ public static OpenApiParserBuilder create() {
+ return new OpenApiParserBuilder();
}
-
- //-----------------------------------------------------------------------------------------------------------------
+
+ //-------------------------------------------------------------------------------------------------------------------
// Entry point methods
- //-----------------------------------------------------------------------------------------------------------------
+ //-------------------------------------------------------------------------------------------------------------------
@Override
- public SimpleUonPartSerializerSession createSession(SerializerSessionArgs args) {
- return new SimpleUonPartSerializerSession(this, args);
+ public OpenApiParserSession createSession() {
+ return new OpenApiParserSession(this, ParserSessionArgs.DEFAULT);
}
@Override
- public SimpleUonPartSerializerSession createSession() {
- return new SimpleUonPartSerializerSession(this, SerializerSessionArgs.DEFAULT);
+ public OpenApiParserSession createPartSession(ParserSessionArgs args) {
+ return new OpenApiParserSession(this, args);
}
}
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/UonPartParserBuilder.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/oapi/OpenApiParserBuilder.java
similarity index 64%
rename from juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/UonPartParserBuilder.java
rename to juneau-core/juneau-marshall/src/main/java/org/apache/juneau/oapi/OpenApiParserBuilder.java
index ba21dc2..1509508 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/UonPartParserBuilder.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/oapi/OpenApiParserBuilder.java
@@ -10,9 +10,7 @@
// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
// * specific language governing permissions and limitations under the License. *
// ***************************************************************************************************************************
-package org.apache.juneau.httppart;
-
-import static org.apache.juneau.uon.UonParser.*;
+package org.apache.juneau.oapi;
import java.util.*;
@@ -22,14 +20,14 @@ import org.apache.juneau.parser.*;
import org.apache.juneau.uon.*;
/**
- * Builder class for building instances of {@link UonPartParser}.
+ * Builder class for building instances of {@link OpenApiParser}.
*/
-public class UonPartParserBuilder extends UonParserBuilder {
+public class OpenApiParserBuilder extends UonParserBuilder {
/**
* Constructor, default settings.
*/
- public UonPartParserBuilder() {
+ public OpenApiParserBuilder() {
super();
}
@@ -38,13 +36,13 @@ public class UonPartParserBuilder extends UonParserBuilder {
*
* @param ps The initial configuration settings for this builder.
*/
- public UonPartParserBuilder(PropertyStore ps) {
+ public OpenApiParserBuilder(PropertyStore ps) {
super(ps);
}
@Override /* ContextBuilder */
- public UonPartParser build() {
- return build(UonPartParser.class);
+ public OpenApiParser build() {
+ return build(OpenApiParser.class);
}
@@ -53,426 +51,426 @@ public class UonPartParserBuilder extends UonParserBuilder {
//--------------------------------------------------------------------------------
@Override /* UonParserBuilder */
- public UonPartParserBuilder decoding(boolean value) {
- return set(UON_decoding, value);
+ public OpenApiParserBuilder decoding(boolean value) {
+ return set(UonParser.UON_decoding, value);
}
@Override /* ParserBuilder */
- public UonPartParserBuilder fileCharset(String value) {
+ public OpenApiParserBuilder fileCharset(String value) {
super.fileCharset(value);
return this;
}
@Override /* ParserBuilder */
- public UonPartParserBuilder inputStreamCharset(String value) {
+ public OpenApiParserBuilder inputStreamCharset(String value) {
super.inputStreamCharset(value);
return this;
}
@Override /* ParserBuilder */
- public UonPartParserBuilder listener(Class<? extends ParserListener> value) {
+ public OpenApiParserBuilder listener(Class<? extends ParserListener> value) {
super.listener(value);
return this;
}
@Override /* ParserBuilder */
- public UonPartParserBuilder strict(boolean value) {
+ public OpenApiParserBuilder strict(boolean value) {
super.strict(value);
return this;
}
@Override /* ParserBuilder */
- public UonPartParserBuilder strict() {
+ public OpenApiParserBuilder strict() {
super.strict();
return this;
}
@Override /* ParserBuilder */
- public UonPartParserBuilder trimStrings(boolean value) {
+ public OpenApiParserBuilder trimStrings(boolean value) {
super.trimStrings(value);
return this;
}
@Override /* ParserBuilder */
- public UonPartParserBuilder trimStrings() {
+ public OpenApiParserBuilder trimStrings() {
super.trimStrings();
return this;
}
@Override /* BeanContextBuilder */
- public UonPartParserBuilder beanClassVisibility(Visibility value) {
+ public OpenApiParserBuilder beanClassVisibility(Visibility value) {
super.beanClassVisibility(value);
return this;
}
@Override /* BeanContextBuilder */
- public UonPartParserBuilder beanConstructorVisibility(Visibility value) {
+ public OpenApiParserBuilder beanConstructorVisibility(Visibility value) {
super.beanConstructorVisibility(value);
return this;
}
@Override /* BeanContextBuilder */
- public UonPartParserBuilder beanDictionary(boolean append, Object...values) {
+ public OpenApiParserBuilder beanDictionary(boolean append, Object...values) {
super.beanDictionary(append, values);
return this;
}
@Override /* BeanContextBuilder */
- public UonPartParserBuilder beanDictionary(Class<?>...values) {
+ public OpenApiParserBuilder beanDictionary(Class<?>...values) {
super.beanDictionary(values);
return this;
}
@Override /* BeanContextBuilder */
- public UonPartParserBuilder beanDictionary(Object...values) {
+ public OpenApiParserBuilder beanDictionary(Object...values) {
super.beanDictionary(values);
return this;
}
@Override /* BeanContextBuilder */
- public UonPartParserBuilder beanDictionaryRemove(Object...values) {
+ public OpenApiParserBuilder beanDictionaryRemove(Object...values) {
super.beanDictionaryRemove(values);
return this;
}
@Override /* BeanContextBuilder */
- public UonPartParserBuilder beanFieldVisibility(Visibility value) {
+ public OpenApiParserBuilder beanFieldVisibility(Visibility value) {
super.beanFieldVisibility(value);
return this;
}
@Override /* BeanContextBuilder */
- public UonPartParserBuilder beanFilters(boolean append, Object...values) {
+ public OpenApiParserBuilder beanFilters(boolean append, Object...values) {
super.beanFilters(append, values);
return this;
}
@Override /* BeanContextBuilder */
- public UonPartParserBuilder beanFilters(Class<?>...values) {
+ public OpenApiParserBuilder beanFilters(Class<?>...values) {
super.beanFilters(values);
return this;
}
@Override /* BeanContextBuilder */
- public UonPartParserBuilder beanFilters(Object...values) {
+ public OpenApiParserBuilder beanFilters(Object...values) {
super.beanFilters(values);
return this;
}
@Override /* BeanContextBuilder */
- public UonPartParserBuilder beanFiltersRemove(Object...values) {
+ public OpenApiParserBuilder beanFiltersRemove(Object...values) {
super.beanFiltersRemove(values);
return this;
}
@Override /* BeanContextBuilder */
- public UonPartParserBuilder beanMapPutReturnsOldValue(boolean value) {
+ public OpenApiParserBuilder beanMapPutReturnsOldValue(boolean value) {
super.beanMapPutReturnsOldValue(value);
return this;
}
@Override /* BeanContextBuilder */
- public UonPartParserBuilder beanMapPutReturnsOldValue() {
+ public OpenApiParserBuilder beanMapPutReturnsOldValue() {
super.beanMapPutReturnsOldValue();
return this;
}
@Override /* BeanContextBuilder */
- public UonPartParserBuilder beanMethodVisibility(Visibility value) {
+ public OpenApiParserBuilder beanMethodVisibility(Visibility value) {
super.beanMethodVisibility(value);
return this;
}
@Override /* BeanContextBuilder */
- public UonPartParserBuilder beansRequireDefaultConstructor(boolean value) {
+ public OpenApiParserBuilder beansRequireDefaultConstructor(boolean value) {
super.beansRequireDefaultConstructor(value);
return this;
}
@Override /* BeanContextBuilder */
- public UonPartParserBuilder beansRequireDefaultConstructor() {
+ public OpenApiParserBuilder beansRequireDefaultConstructor() {
super.beansRequireDefaultConstructor();
return this;
}
@Override /* BeanContextBuilder */
- public UonPartParserBuilder beansRequireSerializable(boolean value) {
+ public OpenApiParserBuilder beansRequireSerializable(boolean value) {
super.beansRequireSerializable(value);
return this;
}
@Override /* BeanContextBuilder */
- public UonPartParserBuilder beansRequireSerializable() {
+ public OpenApiParserBuilder beansRequireSerializable() {
super.beansRequireSerializable();
return this;
}
@Override /* BeanContextBuilder */
- public UonPartParserBuilder beansRequireSettersForGetters(boolean value) {
+ public OpenApiParserBuilder beansRequireSettersForGetters(boolean value) {
super.beansRequireSettersForGetters(value);
return this;
}
@Override /* BeanContextBuilder */
- public UonPartParserBuilder beansRequireSettersForGetters() {
+ public OpenApiParserBuilder beansRequireSettersForGetters() {
super.beansRequireSettersForGetters();
return this;
}
@Override /* BeanContextBuilder */
- public UonPartParserBuilder beansRequireSomeProperties(boolean value) {
+ public OpenApiParserBuilder beansRequireSomeProperties(boolean value) {
super.beansRequireSomeProperties(value);
return this;
}
@Override /* BeanContextBuilder */
- public UonPartParserBuilder beanTypePropertyName(String value) {
+ public OpenApiParserBuilder beanTypePropertyName(String value) {
super.beanTypePropertyName(value);
return this;
}
@Override /* BeanContextBuilder */
- public UonPartParserBuilder debug() {
+ public OpenApiParserBuilder debug() {
super.debug();
return this;
}
@Override /* BeanContextBuilder */
- public <T> UonPartParserBuilder example(Class<T> c, T o) {
+ public <T> OpenApiParserBuilder example(Class<T> c, T o) {
super.example(c, o);
return this;
}
@Override /* BeanContextBuilder */
- public UonPartParserBuilder ignoreInvocationExceptionsOnGetters(boolean value) {
+ public OpenApiParserBuilder ignoreInvocationExceptionsOnGetters(boolean value) {
super.ignoreInvocationExceptionsOnGetters(value);
return this;
}
@Override /* BeanContextBuilder */
- public UonPartParserBuilder ignoreInvocationExceptionsOnGetters() {
+ public OpenApiParserBuilder ignoreInvocationExceptionsOnGetters() {
super.ignoreInvocationExceptionsOnGetters();
return this;
}
@Override /* BeanContextBuilder */
- public UonPartParserBuilder ignoreInvocationExceptionsOnSetters(boolean value) {
+ public OpenApiParserBuilder ignoreInvocationExceptionsOnSetters(boolean value) {
super.ignoreInvocationExceptionsOnSetters(value);
return this;
}
@Override /* BeanContextBuilder */
- public UonPartParserBuilder ignoreInvocationExceptionsOnSetters() {
+ public OpenApiParserBuilder ignoreInvocationExceptionsOnSetters() {
super.ignoreInvocationExceptionsOnSetters();
return this;
}
@Override /* BeanContextBuilder */
- public UonPartParserBuilder ignorePropertiesWithoutSetters(boolean value) {
+ public OpenApiParserBuilder ignorePropertiesWithoutSetters(boolean value) {
super.ignorePropertiesWithoutSetters(value);
return this;
}
@Override /* BeanContextBuilder */
- public UonPartParserBuilder ignoreUnknownBeanProperties(boolean value) {
+ public OpenApiParserBuilder ignoreUnknownBeanProperties(boolean value) {
super.ignoreUnknownBeanProperties(value);
return this;
}
@Override /* BeanContextBuilder */
- public UonPartParserBuilder ignoreUnknownBeanProperties() {
+ public OpenApiParserBuilder ignoreUnknownBeanProperties() {
super.ignoreUnknownBeanProperties();
return this;
}
@Override /* BeanContextBuilder */
- public UonPartParserBuilder ignoreUnknownNullBeanProperties(boolean value) {
+ public OpenApiParserBuilder ignoreUnknownNullBeanProperties(boolean value) {
super.ignoreUnknownNullBeanProperties(value);
return this;
}
@Override /* BeanContextBuilder */
- public <T> UonPartParserBuilder implClass(Class<T> interfaceClass, Class<? extends T> implClass) {
+ public <T> OpenApiParserBuilder implClass(Class<T> interfaceClass, Class<? extends T> implClass) {
super.implClass(interfaceClass, implClass);
return this;
}
@Override /* BeanContextBuilder */
- public UonPartParserBuilder implClasses(Map<String,Class<?>> values) {
+ public OpenApiParserBuilder implClasses(Map<String,Class<?>> values) {
super.implClasses(values);
return this;
}
@Override /* BeanContextBuilder */
- public UonPartParserBuilder locale(Locale value) {
+ public OpenApiParserBuilder locale(Locale value) {
super.locale(value);
return this;
}
@Override /* BeanContextBuilder */
- public UonPartParserBuilder mediaType(MediaType value) {
+ public OpenApiParserBuilder mediaType(MediaType value) {
super.mediaType(value);
return this;
}
@Override /* BeanContextBuilder */
- public UonPartParserBuilder notBeanClasses(boolean append, Object...values) {
+ public OpenApiParserBuilder notBeanClasses(boolean append, Object...values) {
super.notBeanClasses(append, values);
return this;
}
@Override /* BeanContextBuilder */
- public UonPartParserBuilder notBeanClasses(Class<?>...values) {
+ public OpenApiParserBuilder notBeanClasses(Class<?>...values) {
super.notBeanClasses(values);
return this;
}
@Override /* BeanContextBuilder */
- public UonPartParserBuilder notBeanClasses(Object...values) {
+ public OpenApiParserBuilder notBeanClasses(Object...values) {
super.notBeanClasses(values);
return this;
}
@Override /* BeanContextBuilder */
- public UonPartParserBuilder notBeanClassesRemove(Object...values) {
+ public OpenApiParserBuilder notBeanClassesRemove(Object...values) {
super.notBeanClassesRemove(values);
return this;
}
@Override /* BeanContextBuilder */
- public UonPartParserBuilder notBeanPackages(boolean append, Object...values) {
+ public OpenApiParserBuilder notBeanPackages(boolean append, Object...values) {
super.notBeanPackages(append, values);
return this;
}
@Override /* BeanContextBuilder */
- public UonPartParserBuilder notBeanPackages(Object...values) {
+ public OpenApiParserBuilder notBeanPackages(Object...values) {
super.notBeanPackages(values);
return this;
}
@Override /* BeanContextBuilder */
- public UonPartParserBuilder notBeanPackages(String...values) {
+ public OpenApiParserBuilder notBeanPackages(String...values) {
super.notBeanPackages(values);
return this;
}
@Override /* BeanContextBuilder */
- public UonPartParserBuilder notBeanPackagesRemove(Object...values) {
+ public OpenApiParserBuilder notBeanPackagesRemove(Object...values) {
super.notBeanPackagesRemove(values);
return this;
}
@Override /* BeanContextBuilder */
- public UonPartParserBuilder pojoSwaps(boolean append, Object...values) {
+ public OpenApiParserBuilder pojoSwaps(boolean append, Object...values) {
super.pojoSwaps(append, values);
return this;
}
@Override /* BeanContextBuilder */
- public UonPartParserBuilder pojoSwaps(Class<?>...values) {
+ public OpenApiParserBuilder pojoSwaps(Class<?>...values) {
super.pojoSwaps(values);
return this;
}
@Override /* BeanContextBuilder */
- public UonPartParserBuilder pojoSwaps(Object...values) {
+ public OpenApiParserBuilder pojoSwaps(Object...values) {
super.pojoSwaps(values);
return this;
}
@Override /* BeanContextBuilder */
- public UonPartParserBuilder pojoSwapsRemove(Object...values) {
+ public OpenApiParserBuilder pojoSwapsRemove(Object...values) {
super.pojoSwapsRemove(values);
return this;
}
@Override /* BeanContextBuilder */
- public UonPartParserBuilder sortProperties(boolean value) {
+ public OpenApiParserBuilder sortProperties(boolean value) {
super.sortProperties(value);
return this;
}
@Override /* BeanContextBuilder */
- public UonPartParserBuilder sortProperties() {
+ public OpenApiParserBuilder sortProperties() {
super.sortProperties();
return this;
}
@Override /* BeanContextBuilder */
- public UonPartParserBuilder timeZone(TimeZone value) {
+ public OpenApiParserBuilder timeZone(TimeZone value) {
super.timeZone(value);
return this;
}
@Override /* BeanContextBuilder */
- public UonPartParserBuilder useEnumNames() {
+ public OpenApiParserBuilder useEnumNames() {
super.useEnumNames();
return this;
}
@Override /* BeanContextBuilder */
- public UonPartParserBuilder useInterfaceProxies(boolean value) {
+ public OpenApiParserBuilder useInterfaceProxies(boolean value) {
super.useInterfaceProxies(value);
return this;
}
@Override /* BeanContextBuilder */
- public UonPartParserBuilder useJavaBeanIntrospector(boolean value) {
+ public OpenApiParserBuilder useJavaBeanIntrospector(boolean value) {
super.useJavaBeanIntrospector(value);
return this;
}
@Override /* BeanContextBuilder */
- public UonPartParserBuilder useJavaBeanIntrospector() {
+ public OpenApiParserBuilder useJavaBeanIntrospector() {
super.useJavaBeanIntrospector();
return this;
}
@Override /* ContextBuilder */
- public UonPartParserBuilder set(String name, Object value) {
+ public OpenApiParserBuilder set(String name, Object value) {
super.set(name, value);
return this;
}
@Override /* ContextBuilder */
- public UonPartParserBuilder set(boolean append, String name, Object value) {
+ public OpenApiParserBuilder set(boolean append, String name, Object value) {
super.set(append, name, value);
return this;
}
@Override /* ContextBuilder */
- public UonPartParserBuilder set(Map<String,Object> properties) {
+ public OpenApiParserBuilder set(Map<String,Object> properties) {
super.set(properties);
return this;
}
@Override /* ContextBuilder */
- public UonPartParserBuilder add(Map<String,Object> properties) {
+ public OpenApiParserBuilder add(Map<String,Object> properties) {
super.add(properties);
return this;
}
@Override /* ContextBuilder */
- public UonPartParserBuilder addTo(String name, Object value) {
+ public OpenApiParserBuilder addTo(String name, Object value) {
super.addTo(name, value);
return this;
}
@Override /* ContextBuilder */
- public UonPartParserBuilder addTo(String name, String key, Object value) {
+ public OpenApiParserBuilder addTo(String name, String key, Object value) {
super.addTo(name, key, value);
return this;
}
@Override /* ContextBuilder */
- public UonPartParserBuilder removeFrom(String name, Object value) {
+ public OpenApiParserBuilder removeFrom(String name, Object value) {
super.removeFrom(name, value);
return this;
}
@Override /* ContextBuilder */
- public UonPartParserBuilder apply(PropertyStore copyFrom) {
+ public OpenApiParserBuilder apply(PropertyStore copyFrom) {
super.apply(copyFrom);
return this;
}
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/OpenApiPartParserSession.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/oapi/OpenApiParserSession.java
similarity index 93%
rename from juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/OpenApiPartParserSession.java
rename to juneau-core/juneau-marshall/src/main/java/org/apache/juneau/oapi/OpenApiParserSession.java
index 2f1b23c..418d388 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/OpenApiPartParserSession.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/oapi/OpenApiParserSession.java
@@ -10,7 +10,7 @@
// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
// * specific language governing permissions and limitations under the License. *
// ***************************************************************************************************************************
-package org.apache.juneau.httppart;
+package org.apache.juneau.oapi;
import static org.apache.juneau.internal.StringUtils.*;
import static org.apache.juneau.httppart.HttpPartSchema.Type.*;
@@ -20,17 +20,19 @@ import static org.apache.juneau.httppart.HttpPartSchema.CollectionFormat.*;
import java.util.*;
import org.apache.juneau.*;
+import org.apache.juneau.httppart.*;
import org.apache.juneau.internal.*;
import org.apache.juneau.parser.*;
+import org.apache.juneau.uon.*;
/**
- * Session object that lives for the duration of a single use of {@link OpenApiPartParser}.
+ * Session object that lives for the duration of a single use of {@link OpenApiParser}.
*
* <p>
* This class is NOT thread safe.
* It is typically discarded after one-time use although it can be reused within the same thread.
*/
-public class OpenApiPartParserSession extends UonPartParserSession {
+public class OpenApiParserSession extends UonParserSession {
// Cache these for faster lookup
private static final BeanContext BC = BeanContext.DEFAULT;
@@ -48,7 +50,7 @@ public class OpenApiPartParserSession extends UonPartParserSession {
// Instance
//-------------------------------------------------------------------------------------------------------------------
- private final OpenApiPartParser ctx;
+ private final OpenApiParser ctx;
/**
* Create a new session using properties specified in the context.
@@ -59,7 +61,7 @@ public class OpenApiPartParserSession extends UonPartParserSession {
* @param args
* Runtime session arguments.
*/
- protected OpenApiPartParserSession(OpenApiPartParser ctx, ParserSessionArgs args) {
+ protected OpenApiParserSession(OpenApiParser ctx, ParserSessionArgs args) {
super(ctx, args);
this.ctx = ctx;
}
@@ -67,7 +69,7 @@ public class OpenApiPartParserSession extends UonPartParserSession {
@Override /* HttpPartParser */
public <T> T parse(HttpPartType partType, HttpPartSchema schema, String in, ClassMeta<T> type) throws ParseException, SchemaValidationException {
- schema = ObjectUtils.firstNonNull(schema, ctx.getSchema(), DEFAULT_SCHEMA);
+ schema = ObjectUtils.firstNonNull(schema, getSchema(), DEFAULT_SCHEMA);
T t = parseInner(partType, schema, in, type);
if (t == null && type.isPrimitive())
t = type.getPrimitiveDefault();
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/UonPartSerializer.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/oapi/OpenApiSerializer.java
similarity index 56%
rename from juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/UonPartSerializer.java
rename to juneau-core/juneau-marshall/src/main/java/org/apache/juneau/oapi/OpenApiSerializer.java
index 46bb24a..dde42fd 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/UonPartSerializer.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/oapi/OpenApiSerializer.java
@@ -10,27 +10,30 @@
// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
// * specific language governing permissions and limitations under the License. *
// ***************************************************************************************************************************
-package org.apache.juneau.httppart;
+package org.apache.juneau.oapi;
import org.apache.juneau.*;
+import org.apache.juneau.httppart.*;
import org.apache.juneau.serializer.*;
import org.apache.juneau.uon.*;
/**
* Serializes POJOs to values suitable for transmission as HTTP headers, query/form-data parameters, and path variables.
*
- * <p>
- * This serializer uses UON notation for all parts by default. This allows for arbitrary POJOs to be losslessly
- * serialized as any of the specified HTTP types.
+ * <h5 class='section'>See Also:</h5>
+ * <ul>
+ * <li class='link'>{@doc juneau-marshall.OpenApiDetails.Serializers}
+ * </ul>
*/
-public class UonPartSerializer extends UonSerializer implements HttpPartSerializer {
+public class OpenApiSerializer extends UonSerializer {
//-------------------------------------------------------------------------------------------------------------------
// Predefined instances
//-------------------------------------------------------------------------------------------------------------------
- /** Reusable instance of {@link UonPartSerializer}, all default settings. */
- public static final UonPartSerializer DEFAULT = new UonPartSerializer(PropertyStore.DEFAULT);
+ /** Reusable instance of {@link OpenApiSerializer}, all default settings. */
+ public static final OpenApiSerializer DEFAULT = new OpenApiSerializer(PropertyStore.DEFAULT);
+
//-------------------------------------------------------------------------------------------------------------------
// Instance
@@ -41,54 +44,96 @@ public class UonPartSerializer extends UonSerializer implements HttpPartSerializ
*
* @param ps
* The property store containing all the settings for this object.
+ * @param produces
+ * The media type that this serializer produces.
+ * @param accept
+ * The accept media types that the serializer can handle.
+ * <p>
+ * Can contain meta-characters per the <code>media-type</code> specification of {@doc RFC2616.section14.1}
+ * <p>
+ * If empty, then assumes the only media type supported is <code>produces</code>.
+ * <p>
+ * For example, if this serializer produces <js>"application/json"</js> but should handle media types of
+ * <js>"application/json"</js> and <js>"text/json"</js>, then the arguments should be:
+ * <p class='bcode w800'>
+ * <jk>super</jk>(ps, <js>"application/json"</js>, <js>"application/json,text/json"</js>);
+ * </p>
+ * <br>...or...
+ * <p class='bcode w800'>
+ * <jk>super</jk>(ps, <js>"application/json"</js>, <js>"*​/json"</js>);
+ * </p>
+ * <p>
+ * The accept value can also contain q-values.
*/
- public UonPartSerializer(PropertyStore ps) {
+ public OpenApiSerializer(PropertyStore ps, String produces, String accept) {
super(
ps.builder()
.set(UON_encoding, false)
- .build()
+ .build(),
+ produces,
+ accept
);
}
+ /**
+ * Constructor.
+ *
+ * @param ps
+ * The property store containing all the settings for this object.
+ */
+ public OpenApiSerializer(PropertyStore ps) {
+ this(ps, "text/openapi", null);
+ }
+
@Override /* Context */
- public UonPartSerializerBuilder builder() {
- return new UonPartSerializerBuilder(getPropertyStore());
+ public OpenApiSerializerBuilder builder() {
+ return new OpenApiSerializerBuilder(getPropertyStore());
}
/**
- * Instantiates a new clean-slate {@link UonPartSerializerBuilder} object.
+ * Instantiates a new clean-slate {@link OpenApiSerializerBuilder} object.
*
* <p>
* Note that this method creates a builder initialized to all default settings, whereas {@link #builder()} copies
* the settings of the object called on.
*
- * @return A new {@link UonPartSerializerBuilder} object.
+ * @return A new {@link OpenApiSerializerBuilder} object.
*/
- public static UonPartSerializerBuilder create() {
- return new UonPartSerializerBuilder();
+ public static OpenApiSerializerBuilder create() {
+ return new OpenApiSerializerBuilder();
}
//-----------------------------------------------------------------------------------------------------------------
// Entry point methods
//-----------------------------------------------------------------------------------------------------------------
+ @Override /* Context */
+ public OpenApiSerializerSession createSession() {
+ return createSession(null);
+ }
+
+ @Override /* Serializer */
+ public OpenApiSerializerSession createSession(SerializerSessionArgs args) {
+ return new OpenApiSerializerSession(this, args);
+ }
+
@Override /* HttpPartSerializer */
- public UonPartSerializerSession createSession(SerializerSessionArgs args) {
- return new UonPartSerializerSession(this, args);
+ public OpenApiSerializerSession createPartSession() {
+ return createPartSession(null);
}
@Override /* HttpPartSerializer */
- public UonPartSerializerSession createSession() {
- return new UonPartSerializerSession(this, SerializerSessionArgs.DEFAULT);
+ public OpenApiSerializerSession createPartSession(SerializerSessionArgs args) {
+ return new OpenApiSerializerSession(this, args);
}
@Override /* HttpPartSerializer */
public String serialize(HttpPartType partType, HttpPartSchema schema, Object value) throws SchemaValidationException, SerializeException {
- return createSession().serialize(partType, schema, value);
+ return createPartSession().serialize(partType, schema, value);
}
@Override /* HttpPartSerializer */
public String serialize(HttpPartSchema schema, Object value) throws SchemaValidationException, SerializeException {
- return createSession().serialize(null, schema, value);
+ return createPartSession().serialize(null, schema, value);
}
}
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/UonPartSerializerBuilder.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/oapi/OpenApiSerializerBuilder.java
similarity index 64%
rename from juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/UonPartSerializerBuilder.java
rename to juneau-core/juneau-marshall/src/main/java/org/apache/juneau/oapi/OpenApiSerializerBuilder.java
index e617c30..0f76a9e 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/UonPartSerializerBuilder.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/oapi/OpenApiSerializerBuilder.java
@@ -10,7 +10,7 @@
// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
// * specific language governing permissions and limitations under the License. *
// ***************************************************************************************************************************
-package org.apache.juneau.httppart;
+package org.apache.juneau.oapi;
import java.util.*;
@@ -20,14 +20,14 @@ import org.apache.juneau.serializer.*;
import org.apache.juneau.uon.*;
/**
- * Builder class for building instances of {@link UonPartSerializer}.
+ * Builder class for building instances of {@link OpenApiSerializer}.
*/
-public class UonPartSerializerBuilder extends UonSerializerBuilder {
+public class OpenApiSerializerBuilder extends UonSerializerBuilder {
/**
* Constructor, default settings.
*/
- public UonPartSerializerBuilder() {
+ public OpenApiSerializerBuilder() {
super();
}
@@ -36,13 +36,13 @@ public class UonPartSerializerBuilder extends UonSerializerBuilder {
*
* @param ps The initial configuration settings for this builder.
*/
- public UonPartSerializerBuilder(PropertyStore ps) {
+ public OpenApiSerializerBuilder(PropertyStore ps) {
super(ps);
}
@Override /* ContextBuilder */
- public UonPartSerializer build() {
- return build(UonPartSerializer.class);
+ public OpenApiSerializer build() {
+ return build(OpenApiSerializer.class);
}
@@ -51,564 +51,564 @@ public class UonPartSerializerBuilder extends UonSerializerBuilder {
//--------------------------------------------------------------------------------
@Override /* SerializerBuilder */
- public UonPartSerializerBuilder addBeanTypes(boolean value) {
+ public OpenApiSerializerBuilder addBeanTypes(boolean value) {
super.addBeanTypes(value);
return this;
}
@Override /* SerializerBuilder */
- public UonPartSerializerBuilder addBeanTypes() {
+ public OpenApiSerializerBuilder addBeanTypes() {
super.addBeanTypes();
return this;
}
@Override /* SerializerBuilder */
- public UonPartSerializerBuilder addRootType(boolean value) {
+ public OpenApiSerializerBuilder addRootType(boolean value) {
super.addRootType(value);
return this;
}
@Override /* SerializerBuilder */
- public UonPartSerializerBuilder addRootType() {
+ public OpenApiSerializerBuilder addRootType() {
super.addRootType();
return this;
}
@Override /* SerializerBuilder */
- public UonPartSerializerBuilder detectRecursions(boolean value) {
+ public OpenApiSerializerBuilder detectRecursions(boolean value) {
super.detectRecursions(value);
return this;
}
@Override /* SerializerBuilder */
- public UonPartSerializerBuilder detectRecursions() {
+ public OpenApiSerializerBuilder detectRecursions() {
super.detectRecursions();
return this;
}
@Override /* SerializerBuilder */
- public UonPartSerializerBuilder ignoreRecursions(boolean value) {
+ public OpenApiSerializerBuilder ignoreRecursions(boolean value) {
super.ignoreRecursions(value);
return this;
}
@Override /* SerializerBuilder */
- public UonPartSerializerBuilder ignoreRecursions() {
+ public OpenApiSerializerBuilder ignoreRecursions() {
super.ignoreRecursions();
return this;
}
@Override /* SerializerBuilder */
- public UonPartSerializerBuilder initialDepth(int value) {
+ public OpenApiSerializerBuilder initialDepth(int value) {
super.initialDepth(value);
return this;
}
@Override /* SerializerBuilder */
- public UonPartSerializerBuilder listener(Class<? extends SerializerListener> value) {
+ public OpenApiSerializerBuilder listener(Class<? extends SerializerListener> value) {
super.listener(value);
return this;
}
@Override /* SerializerBuilder */
- public UonPartSerializerBuilder maxDepth(int value) {
+ public OpenApiSerializerBuilder maxDepth(int value) {
super.maxDepth(value);
return this;
}
@Override /* SerializerBuilder */
- public UonPartSerializerBuilder maxIndent(int value) {
+ public OpenApiSerializerBuilder maxIndent(int value) {
super.maxIndent(value);
return this;
}
@Override /* SerializerBuilder */
- public UonPartSerializerBuilder quoteChar(char value) {
+ public OpenApiSerializerBuilder quoteChar(char value) {
super.quoteChar(value);
return this;
}
@Override /* SerializerBuilder */
- public UonPartSerializerBuilder sortCollections(boolean value) {
+ public OpenApiSerializerBuilder sortCollections(boolean value) {
super.sortCollections(value);
return this;
}
@Override /* SerializerBuilder */
- public UonPartSerializerBuilder sortCollections() {
+ public OpenApiSerializerBuilder sortCollections() {
super.sortCollections();
return this;
}
@Override /* SerializerBuilder */
- public UonPartSerializerBuilder sortMaps(boolean value) {
+ public OpenApiSerializerBuilder sortMaps(boolean value) {
super.sortMaps(value);
return this;
}
@Override /* SerializerBuilder */
- public UonPartSerializerBuilder sortMaps() {
+ public OpenApiSerializerBuilder sortMaps() {
super.sortMaps();
return this;
}
@Override /* SerializerBuilder */
- public UonPartSerializerBuilder sq() {
+ public OpenApiSerializerBuilder sq() {
super.sq();
return this;
}
@Override /* SerializerBuilder */
- public UonPartSerializerBuilder trimEmptyCollections(boolean value) {
+ public OpenApiSerializerBuilder trimEmptyCollections(boolean value) {
super.trimEmptyCollections(value);
return this;
}
@Override /* SerializerBuilder */
- public UonPartSerializerBuilder trimEmptyCollections() {
+ public OpenApiSerializerBuilder trimEmptyCollections() {
super.trimEmptyCollections();
return this;
}
@Override /* SerializerBuilder */
- public UonPartSerializerBuilder trimEmptyMaps(boolean value) {
+ public OpenApiSerializerBuilder trimEmptyMaps(boolean value) {
super.trimEmptyMaps(value);
return this;
}
@Override /* SerializerBuilder */
- public UonPartSerializerBuilder trimEmptyMaps() {
+ public OpenApiSerializerBuilder trimEmptyMaps() {
super.trimEmptyMaps();
return this;
}
@Override /* SerializerBuilder */
- public UonPartSerializerBuilder trimNullProperties(boolean value) {
+ public OpenApiSerializerBuilder trimNullProperties(boolean value) {
super.trimNullProperties(value);
return this;
}
@Override /* SerializerBuilder */
- public UonPartSerializerBuilder trimStrings(boolean value) {
+ public OpenApiSerializerBuilder trimStrings(boolean value) {
super.trimStrings(value);
return this;
}
@Override /* SerializerBuilder */
- public UonPartSerializerBuilder trimStrings() {
+ public OpenApiSerializerBuilder trimStrings() {
super.trimStrings();
return this;
}
@Override /* SerializerBuilder */
- public UonPartSerializerBuilder uriContext(UriContext value) {
+ public OpenApiSerializerBuilder uriContext(UriContext value) {
super.uriContext(value);
return this;
}
@Override /* SerializerBuilder */
- public UonPartSerializerBuilder uriRelativity(UriRelativity value) {
+ public OpenApiSerializerBuilder uriRelativity(UriRelativity value) {
super.uriRelativity(value);
return this;
}
@Override /* SerializerBuilder */
- public UonPartSerializerBuilder uriResolution(UriResolution value) {
+ public OpenApiSerializerBuilder uriResolution(UriResolution value) {
super.uriResolution(value);
return this;
}
@Override /* SerializerBuilder */
- public UonPartSerializerBuilder useWhitespace(boolean value) {
+ public OpenApiSerializerBuilder useWhitespace(boolean value) {
super.useWhitespace(value);
return this;
}
@Override /* SerializerBuilder */
- public UonPartSerializerBuilder useWhitespace() {
+ public OpenApiSerializerBuilder useWhitespace() {
super.useWhitespace();
return this;
}
@Override /* SerializerBuilder */
- public UonPartSerializerBuilder ws() {
+ public OpenApiSerializerBuilder ws() {
super.ws();
return this;
}
@Override /* BeanContextBuilder */
- public UonPartSerializerBuilder beanClassVisibility(Visibility value) {
+ public OpenApiSerializerBuilder beanClassVisibility(Visibility value) {
super.beanClassVisibility(value);
return this;
}
@Override /* BeanContextBuilder */
- public UonPartSerializerBuilder beanConstructorVisibility(Visibility value) {
+ public OpenApiSerializerBuilder beanConstructorVisibility(Visibility value) {
super.beanConstructorVisibility(value);
return this;
}
@Override /* BeanContextBuilder */
- public UonPartSerializerBuilder beanDictionary(boolean append, Object...values) {
+ public OpenApiSerializerBuilder beanDictionary(boolean append, Object...values) {
super.beanDictionary(append, values);
return this;
}
@Override /* BeanContextBuilder */
- public UonPartSerializerBuilder beanDictionary(Class<?>...values) {
+ public OpenApiSerializerBuilder beanDictionary(Class<?>...values) {
super.beanDictionary(values);
return this;
}
@Override /* BeanContextBuilder */
- public UonPartSerializerBuilder beanDictionary(Object...values) {
+ public OpenApiSerializerBuilder beanDictionary(Object...values) {
super.beanDictionary(values);
return this;
}
@Override /* BeanContextBuilder */
- public UonPartSerializerBuilder beanDictionaryRemove(Object...values) {
+ public OpenApiSerializerBuilder beanDictionaryRemove(Object...values) {
super.beanDictionaryRemove(values);
return this;
}
@Override /* BeanContextBuilder */
- public UonPartSerializerBuilder beanFieldVisibility(Visibility value) {
+ public OpenApiSerializerBuilder beanFieldVisibility(Visibility value) {
super.beanFieldVisibility(value);
return this;
}
@Override /* BeanContextBuilder */
- public UonPartSerializerBuilder beanFilters(boolean append, Object...values) {
+ public OpenApiSerializerBuilder beanFilters(boolean append, Object...values) {
super.beanFilters(append, values);
return this;
}
@Override /* BeanContextBuilder */
- public UonPartSerializerBuilder beanFilters(Class<?>...values) {
+ public OpenApiSerializerBuilder beanFilters(Class<?>...values) {
super.beanFilters(values);
return this;
}
@Override /* BeanContextBuilder */
- public UonPartSerializerBuilder beanFilters(Object...values) {
+ public OpenApiSerializerBuilder beanFilters(Object...values) {
super.beanFilters(values);
return this;
}
@Override /* BeanContextBuilder */
- public UonPartSerializerBuilder beanFiltersRemove(Object...values) {
+ public OpenApiSerializerBuilder beanFiltersRemove(Object...values) {
super.beanFiltersRemove(values);
return this;
}
@Override /* BeanContextBuilder */
- public UonPartSerializerBuilder beanMapPutReturnsOldValue(boolean value) {
+ public OpenApiSerializerBuilder beanMapPutReturnsOldValue(boolean value) {
super.beanMapPutReturnsOldValue(value);
return this;
}
@Override /* BeanContextBuilder */
- public UonPartSerializerBuilder beanMapPutReturnsOldValue() {
+ public OpenApiSerializerBuilder beanMapPutReturnsOldValue() {
super.beanMapPutReturnsOldValue();
return this;
}
@Override /* BeanContextBuilder */
- public UonPartSerializerBuilder beanMethodVisibility(Visibility value) {
+ public OpenApiSerializerBuilder beanMethodVisibility(Visibility value) {
super.beanMethodVisibility(value);
return this;
}
@Override /* BeanContextBuilder */
- public UonPartSerializerBuilder beansRequireDefaultConstructor(boolean value) {
+ public OpenApiSerializerBuilder beansRequireDefaultConstructor(boolean value) {
super.beansRequireDefaultConstructor(value);
return this;
}
@Override /* BeanContextBuilder */
- public UonPartSerializerBuilder beansRequireDefaultConstructor() {
+ public OpenApiSerializerBuilder beansRequireDefaultConstructor() {
super.beansRequireDefaultConstructor();
return this;
}
@Override /* BeanContextBuilder */
- public UonPartSerializerBuilder beansRequireSerializable(boolean value) {
+ public OpenApiSerializerBuilder beansRequireSerializable(boolean value) {
super.beansRequireSerializable(value);
return this;
}
@Override /* BeanContextBuilder */
- public UonPartSerializerBuilder beansRequireSerializable() {
+ public OpenApiSerializerBuilder beansRequireSerializable() {
super.beansRequireSerializable();
return this;
}
@Override /* BeanContextBuilder */
- public UonPartSerializerBuilder beansRequireSettersForGetters(boolean value) {
+ public OpenApiSerializerBuilder beansRequireSettersForGetters(boolean value) {
super.beansRequireSettersForGetters(value);
return this;
}
@Override /* BeanContextBuilder */
- public UonPartSerializerBuilder beansRequireSettersForGetters() {
+ public OpenApiSerializerBuilder beansRequireSettersForGetters() {
super.beansRequireSettersForGetters();
return this;
}
@Override /* BeanContextBuilder */
- public UonPartSerializerBuilder beansRequireSomeProperties(boolean value) {
+ public OpenApiSerializerBuilder beansRequireSomeProperties(boolean value) {
super.beansRequireSomeProperties(value);
return this;
}
@Override /* BeanContextBuilder */
- public UonPartSerializerBuilder beanTypePropertyName(String value) {
+ public OpenApiSerializerBuilder beanTypePropertyName(String value) {
super.beanTypePropertyName(value);
return this;
}
@Override /* BeanContextBuilder */
- public UonPartSerializerBuilder debug() {
+ public OpenApiSerializerBuilder debug() {
super.debug();
return this;
}
@Override /* BeanContextBuilder */
- public <T> UonPartSerializerBuilder example(Class<T> c, T o) {
+ public <T> OpenApiSerializerBuilder example(Class<T> c, T o) {
super.example(c, o);
return this;
}
@Override /* BeanContextBuilder */
- public UonPartSerializerBuilder ignoreInvocationExceptionsOnGetters(boolean value) {
+ public OpenApiSerializerBuilder ignoreInvocationExceptionsOnGetters(boolean value) {
super.ignoreInvocationExceptionsOnGetters(value);
return this;
}
@Override /* BeanContextBuilder */
- public UonPartSerializerBuilder ignoreInvocationExceptionsOnGetters() {
+ public OpenApiSerializerBuilder ignoreInvocationExceptionsOnGetters() {
super.ignoreInvocationExceptionsOnGetters();
return this;
}
@Override /* BeanContextBuilder */
- public UonPartSerializerBuilder ignoreInvocationExceptionsOnSetters(boolean value) {
+ public OpenApiSerializerBuilder ignoreInvocationExceptionsOnSetters(boolean value) {
super.ignoreInvocationExceptionsOnSetters(value);
return this;
}
@Override /* BeanContextBuilder */
- public UonPartSerializerBuilder ignoreInvocationExceptionsOnSetters() {
+ public OpenApiSerializerBuilder ignoreInvocationExceptionsOnSetters() {
super.ignoreInvocationExceptionsOnSetters();
return this;
}
@Override /* BeanContextBuilder */
- public UonPartSerializerBuilder ignorePropertiesWithoutSetters(boolean value) {
+ public OpenApiSerializerBuilder ignorePropertiesWithoutSetters(boolean value) {
super.ignorePropertiesWithoutSetters(value);
return this;
}
@Override /* BeanContextBuilder */
- public UonPartSerializerBuilder ignoreUnknownBeanProperties(boolean value) {
+ public OpenApiSerializerBuilder ignoreUnknownBeanProperties(boolean value) {
super.ignoreUnknownBeanProperties(value);
return this;
}
@Override /* BeanContextBuilder */
- public UonPartSerializerBuilder ignoreUnknownBeanProperties() {
+ public OpenApiSerializerBuilder ignoreUnknownBeanProperties() {
super.ignoreUnknownBeanProperties();
return this;
}
@Override /* BeanContextBuilder */
- public UonPartSerializerBuilder ignoreUnknownNullBeanProperties(boolean value) {
+ public OpenApiSerializerBuilder ignoreUnknownNullBeanProperties(boolean value) {
super.ignoreUnknownNullBeanProperties(value);
return this;
}
@Override /* BeanContextBuilder */
- public <T> UonPartSerializerBuilder implClass(Class<T> interfaceClass, Class<? extends T> implClass) {
+ public <T> OpenApiSerializerBuilder implClass(Class<T> interfaceClass, Class<? extends T> implClass) {
super.implClass(interfaceClass, implClass);
return this;
}
@Override /* BeanContextBuilder */
- public UonPartSerializerBuilder implClasses(Map<String,Class<?>> values) {
+ public OpenApiSerializerBuilder implClasses(Map<String,Class<?>> values) {
super.implClasses(values);
return this;
}
@Override /* BeanContextBuilder */
- public UonPartSerializerBuilder locale(Locale value) {
+ public OpenApiSerializerBuilder locale(Locale value) {
super.locale(value);
return this;
}
@Override /* BeanContextBuilder */
- public UonPartSerializerBuilder mediaType(MediaType value) {
+ public OpenApiSerializerBuilder mediaType(MediaType value) {
super.mediaType(value);
return this;
}
@Override /* BeanContextBuilder */
- public UonPartSerializerBuilder notBeanClasses(boolean append, Object...values) {
+ public OpenApiSerializerBuilder notBeanClasses(boolean append, Object...values) {
super.notBeanClasses(append, values);
return this;
}
@Override /* BeanContextBuilder */
- public UonPartSerializerBuilder notBeanClasses(Class<?>...values) {
+ public OpenApiSerializerBuilder notBeanClasses(Class<?>...values) {
super.notBeanClasses(values);
return this;
}
@Override /* BeanContextBuilder */
- public UonPartSerializerBuilder notBeanClasses(Object...values) {
+ public OpenApiSerializerBuilder notBeanClasses(Object...values) {
super.notBeanClasses(values);
return this;
}
@Override /* BeanContextBuilder */
- public UonPartSerializerBuilder notBeanClassesRemove(Object...values) {
+ public OpenApiSerializerBuilder notBeanClassesRemove(Object...values) {
super.notBeanClassesRemove(values);
return this;
}
@Override /* BeanContextBuilder */
- public UonPartSerializerBuilder notBeanPackages(boolean append, Object...values) {
+ public OpenApiSerializerBuilder notBeanPackages(boolean append, Object...values) {
super.notBeanPackages(append, values);
return this;
}
@Override /* BeanContextBuilder */
- public UonPartSerializerBuilder notBeanPackages(Object...values) {
+ public OpenApiSerializerBuilder notBeanPackages(Object...values) {
super.notBeanPackages(values);
return this;
}
@Override /* BeanContextBuilder */
- public UonPartSerializerBuilder notBeanPackages(String...values) {
+ public OpenApiSerializerBuilder notBeanPackages(String...values) {
super.notBeanPackages(values);
return this;
}
@Override /* BeanContextBuilder */
- public UonPartSerializerBuilder notBeanPackagesRemove(Object...values) {
+ public OpenApiSerializerBuilder notBeanPackagesRemove(Object...values) {
super.notBeanPackagesRemove(values);
return this;
}
@Override /* BeanContextBuilder */
- public UonPartSerializerBuilder pojoSwaps(boolean append, Object...values) {
+ public OpenApiSerializerBuilder pojoSwaps(boolean append, Object...values) {
super.pojoSwaps(append, values);
return this;
}
@Override /* BeanContextBuilder */
- public UonPartSerializerBuilder pojoSwaps(Class<?>...values) {
+ public OpenApiSerializerBuilder pojoSwaps(Class<?>...values) {
super.pojoSwaps(values);
return this;
}
@Override /* BeanContextBuilder */
- public UonPartSerializerBuilder pojoSwaps(Object...values) {
+ public OpenApiSerializerBuilder pojoSwaps(Object...values) {
super.pojoSwaps(values);
return this;
}
@Override /* BeanContextBuilder */
- public UonPartSerializerBuilder pojoSwapsRemove(Object...values) {
+ public OpenApiSerializerBuilder pojoSwapsRemove(Object...values) {
super.pojoSwapsRemove(values);
return this;
}
@Override /* BeanContextBuilder */
- public UonPartSerializerBuilder sortProperties(boolean value) {
+ public OpenApiSerializerBuilder sortProperties(boolean value) {
super.sortProperties(value);
return this;
}
@Override /* BeanContextBuilder */
- public UonPartSerializerBuilder sortProperties() {
+ public OpenApiSerializerBuilder sortProperties() {
super.sortProperties();
return this;
}
@Override /* BeanContextBuilder */
- public UonPartSerializerBuilder timeZone(TimeZone value) {
+ public OpenApiSerializerBuilder timeZone(TimeZone value) {
super.timeZone(value);
return this;
}
@Override /* BeanContextBuilder */
- public UonPartSerializerBuilder useEnumNames() {
+ public OpenApiSerializerBuilder useEnumNames() {
super.useEnumNames();
return this;
}
@Override /* BeanContextBuilder */
- public UonPartSerializerBuilder useInterfaceProxies(boolean value) {
+ public OpenApiSerializerBuilder useInterfaceProxies(boolean value) {
super.useInterfaceProxies(value);
return this;
}
@Override /* BeanContextBuilder */
- public UonPartSerializerBuilder useJavaBeanIntrospector(boolean value) {
+ public OpenApiSerializerBuilder useJavaBeanIntrospector(boolean value) {
super.useJavaBeanIntrospector(value);
return this;
}
@Override /* BeanContextBuilder */
- public UonPartSerializerBuilder useJavaBeanIntrospector() {
+ public OpenApiSerializerBuilder useJavaBeanIntrospector() {
super.useJavaBeanIntrospector();
return this;
}
@Override /* ContextBuilder */
- public UonSerializerBuilder set(String name, Object value) {
+ public OpenApiSerializerBuilder set(String name, Object value) {
super.set(name, value);
return this;
}
@Override /* ContextBuilder */
- public UonPartSerializerBuilder set(boolean append, String name, Object value) {
+ public OpenApiSerializerBuilder set(boolean append, String name, Object value) {
super.set(append, name, value);
return this;
}
@Override /* ContextBuilder */
- public UonPartSerializerBuilder set(Map<String,Object> properties) {
+ public OpenApiSerializerBuilder set(Map<String,Object> properties) {
super.set(properties);
return this;
}
@Override /* ContextBuilder */
- public UonPartSerializerBuilder add(Map<String,Object> properties) {
+ public OpenApiSerializerBuilder add(Map<String,Object> properties) {
super.add(properties);
return this;
}
@Override /* ContextBuilder */
- public UonPartSerializerBuilder addTo(String name, Object value) {
+ public OpenApiSerializerBuilder addTo(String name, Object value) {
super.addTo(name, value);
return this;
}
@Override /* ContextBuilder */
- public UonPartSerializerBuilder addTo(String name, String key, Object value) {
+ public OpenApiSerializerBuilder addTo(String name, String key, Object value) {
super.addTo(name, key, value);
return this;
}
@Override /* ContextBuilder */
- public UonPartSerializerBuilder removeFrom(String name, Object value) {
+ public OpenApiSerializerBuilder removeFrom(String name, Object value) {
super.removeFrom(name, value);
return this;
}
@Override /* ContextBuilder */
- public UonPartSerializerBuilder apply(PropertyStore copyFrom) {
+ public OpenApiSerializerBuilder apply(PropertyStore copyFrom) {
super.apply(copyFrom);
return this;
}
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/OpenApiPartSerializerSession.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/oapi/OpenApiSerializerSession.java
similarity index 83%
rename from juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/OpenApiPartSerializerSession.java
rename to juneau-core/juneau-marshall/src/main/java/org/apache/juneau/oapi/OpenApiSerializerSession.java
index 690ab8a..768266b 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/OpenApiPartSerializerSession.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/oapi/OpenApiSerializerSession.java
@@ -10,7 +10,7 @@
// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
// * specific language governing permissions and limitations under the License. *
// ***************************************************************************************************************************
-package org.apache.juneau.httppart;
+package org.apache.juneau.oapi;
import static org.apache.juneau.httppart.HttpPartSchema.CollectionFormat.*;
import static org.apache.juneau.httppart.HttpPartSchema.Format.*;
@@ -21,45 +21,19 @@ import java.lang.reflect.*;
import java.util.*;
import org.apache.juneau.*;
+import org.apache.juneau.httppart.*;
import org.apache.juneau.internal.*;
import org.apache.juneau.serializer.*;
+import org.apache.juneau.uon.*;
/**
- * Session object that lives for the duration of a single use of {@link OpenApiPartSerializer}.
+ * Session object that lives for the duration of a single use of {@link OpenApiSerializer}.
*
* <p>
* This class is NOT thread safe.
* It is typically discarded after one-time use although it can be reused within the same thread.
*/
-public class OpenApiPartSerializerSession extends UonPartSerializerSession {
-
- //-------------------------------------------------------------------------------------------------------------------
- // Configurable properties
- //-------------------------------------------------------------------------------------------------------------------
-
- private static final String PREFIX = "OpenApiPartSerializer.";
-
- /**
- * Configuration property: OpenAPI schema description.
- *
- * <h5 class='section'>Property:</h5>
- * <ul>
- * <li><b>Name:</b> <js>"OpenApiPartSerializer.schema"</js>
- * <li><b>Data type:</b> <code>HttpPartSchema</code>
- * <li><b>Default:</b> <jk>false</jk>
- * <li><b>Session property:</b> <jk>false</jk>
- * <li><b>Methods:</b>
- * <ul>
- * <li class='jm'>{@link OpenApiPartSerializerBuilder#schema(HttpPartSchema)}
- * </ul>
- * </ul>
- *
- * <h5 class='section'>Description:</h5>
- * <p>
- * Defines the OpenAPI schema for this part serializer.
- */
- public static final String OAPI_schema = PREFIX + "schema.o";
-
+public class OpenApiSerializerSession extends UonSerializerSession {
//-------------------------------------------------------------------------------------------------------------------
// Predefined instances
@@ -82,7 +56,7 @@ public class OpenApiPartSerializerSession extends UonPartSerializerSession {
// Instance
//-------------------------------------------------------------------------------------------------------------------
- private final OpenApiPartSerializer ctx;
+ private final OpenApiSerializer ctx;
/**
* Create a new session using properties specified in the context.
@@ -93,8 +67,8 @@ public class OpenApiPartSerializerSession extends UonPartSerializerSession {
* @param args
* Runtime session arguments.
*/
- protected OpenApiPartSerializerSession(OpenApiPartSerializer ctx, SerializerSessionArgs args) {
- super(ctx, args);
+ protected OpenApiSerializerSession(OpenApiSerializer ctx, SerializerSessionArgs args) {
+ super(ctx, false, args);
this.ctx = ctx;
}
@@ -102,18 +76,12 @@ public class OpenApiPartSerializerSession extends UonPartSerializerSession {
// Entry point methods
//--------------------------------------------------------------------------------
- /**
- * Convenience method for serializing a part.
- *
- * @param schema
- * Schema information about the part.
- * <br>May be <jk>null</jk>.
- * <br>Not all part serializers use the schema information.
- * @param value The value being serialized.
- * @return The serialized value.
- * @throws SerializeException If a problem occurred while trying to serialize the input.
- * @throws SchemaValidationException If the input or resulting HTTP part object fails schema validation.
- */
+ @Override /* Serializer */
+ protected void doSerialize(SerializerPipe out, Object o) throws Exception {
+ out.getWriter().write(serialize(HttpPartType.BODY, getSchema(), o));
+ }
+
+ @Override /* PartSerializer */
public String serialize(HttpPartSchema schema, Object value) throws SerializeException, SchemaValidationException {
return serialize(null, schema, value);
}
@@ -121,7 +89,7 @@ public class OpenApiPartSerializerSession extends UonPartSerializerSession {
@Override /* PartSerializer */
public String serialize(HttpPartType partType, HttpPartSchema schema, Object value) throws SerializeException, SchemaValidationException {
- schema = ObjectUtils.firstNonNull(schema, ctx.getSchema(), DEFAULT_SCHEMA);
+ schema = ObjectUtils.firstNonNull(schema, DEFAULT_SCHEMA);
ClassMeta<?> type = getClassMetaForObject(value);
if (type == null)
type = object();
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/parser/ParserSessionArgs.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/parser/ParserSessionArgs.java
index d70e362..75f76ca 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/parser/ParserSessionArgs.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/parser/ParserSessionArgs.java
@@ -17,6 +17,7 @@ import java.util.*;
import org.apache.juneau.*;
import org.apache.juneau.http.*;
+import org.apache.juneau.httppart.*;
/**
* Runtime arguments common to all parser sessions.
@@ -55,14 +56,17 @@ public final class ParserSessionArgs extends BeanSessionArgs {
* @param mediaType
* The session media type (e.g. <js>"application/json"</js>).
* <br>Can be <jk>null</jk>.
+ * @param schema
+ * The part schema for the serialized part.
+ * <br>Can be <jk>null</jk>.
* @param debug
* Enable debug mode for this session.
* <br>Can be <jk>null</jk> to use the debug setting on the bean context..
* @param outer
* The outer object for instantiating top-level non-static inner classes.
*/
- public ParserSessionArgs(ObjectMap properties, Method javaMethod, Locale locale, TimeZone timeZone, MediaType mediaType, Boolean debug, Object outer) {
- super(properties, locale, timeZone, mediaType, debug);
+ public ParserSessionArgs(ObjectMap properties, Method javaMethod, Locale locale, TimeZone timeZone, MediaType mediaType, HttpPartSchema schema, Boolean debug, Object outer) {
+ super(properties, locale, timeZone, mediaType, schema, debug);
this.javaMethod = javaMethod;
this.outer = outer;
}
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/serializer/SerializerSessionArgs.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/serializer/SerializerSessionArgs.java
index 7226e80..ae60142 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/serializer/SerializerSessionArgs.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/serializer/SerializerSessionArgs.java
@@ -17,6 +17,7 @@ import java.util.*;
import org.apache.juneau.*;
import org.apache.juneau.http.*;
+import org.apache.juneau.httppart.*;
/**
* Runtime arguments common to all serializer sessions.
@@ -59,6 +60,9 @@ public final class SerializerSessionArgs extends BeanSessionArgs {
* @param mediaType
* The session media type (e.g. <js>"application/json"</js>).
* <br>Can be <jk>null</jk>.
+ * @param schema
+ * The part schema for the serialized part.
+ * <br>Can be <jk>null</jk>.
* @param debug
* Enable debug mode for this session.
* <br>Can be <jk>null</jk> to use the debug setting on the bean context..
@@ -68,8 +72,8 @@ public final class SerializerSessionArgs extends BeanSessionArgs {
* @param useWhitespace
* Override the use-whitespace flag on the serializer.
*/
- public SerializerSessionArgs(ObjectMap properties, Method javaMethod, Locale locale, TimeZone timeZone, MediaType mediaType, Boolean debug, UriContext uriContext, Boolean useWhitespace) {
- super(properties, locale, timeZone, mediaType, debug);
+ public SerializerSessionArgs(ObjectMap properties, Method javaMethod, Locale locale, TimeZone timeZone, MediaType mediaType, HttpPartSchema schema, Boolean debug, UriContext uriContext, Boolean useWhitespace) {
+ super(properties, locale, timeZone, mediaType, schema, debug);
this.javaMethod = javaMethod;
this.uriContext = uriContext;
this.useWhitespace = useWhitespace;
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/uon/UonParser.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/uon/UonParser.java
index 61acf2e..c32f996 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/uon/UonParser.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/uon/UonParser.java
@@ -12,7 +12,10 @@
// ***************************************************************************************************************************
package org.apache.juneau.uon;
+import java.lang.reflect.*;
+
import org.apache.juneau.*;
+import org.apache.juneau.httppart.*;
import org.apache.juneau.parser.*;
import org.apache.juneau.urlencoding.*;
@@ -27,7 +30,7 @@ import org.apache.juneau.urlencoding.*;
*
* This parser uses a state machine, which makes it very fast and efficient.
*/
-public class UonParser extends ReaderParser {
+public class UonParser extends ReaderParser implements HttpPartParser {
//-------------------------------------------------------------------------------------------------------------------
// Configurable properties
@@ -208,11 +211,50 @@ public class UonParser extends ReaderParser {
return new UonParserSession(this, createDefaultSessionArgs(), false);
}
+ //-----------------------------------------------------------------------------------------------------------------
+ // Entry point methods
+ //-----------------------------------------------------------------------------------------------------------------
+
@Override /* Parser */
public UonParserSession createSession(ParserSessionArgs args) {
return new UonParserSession(this, args);
}
+ @Override /* HttpPartParser */
+ public UonParserSession createSession() {
+ return createSession(null);
+ }
+
+ @Override /* HttpPartParser */
+ public UonParserSession createPartSession(ParserSessionArgs args) {
+ return new UonParserSession(this, args);
+ }
+
+ @Override /* HttpPartParser */
+ public UonParserSession createPartSession() {
+ return createPartSession(null);
+ }
+
+ @Override /* HttpPartParser */
+ public <T> T parse(HttpPartType partType, HttpPartSchema schema, String in, Class<T> toType) throws ParseException, SchemaValidationException {
+ return createPartSession().parse(partType, schema, in, toType);
+ }
+
+ @Override /* HttpPartParser */
+ public <T> T parse(HttpPartType partType, HttpPartSchema schema, String in, Type toType, Type...toTypeArgs) throws ParseException, SchemaValidationException {
+ return createPartSession().parse(partType, schema, in, toType, toTypeArgs);
+ }
+
+ @Override /* HttpPartParser */
+ public <T> T parse(HttpPartSchema schema, String in, Class<T> toType) throws ParseException, SchemaValidationException {
+ return createPartSession().parse(null, schema, in, toType);
+ }
+
+ @Override /* HttpPartParser */
+ public <T> T parse(HttpPartSchema schema, String in, Type toType, Type...toTypeArgs) throws ParseException, SchemaValidationException {
+ return createPartSession().parse(null, schema, in, toType, toTypeArgs);
+ }
+
//-----------------------------------------------------------------------------------------------------------------
// Properties
//-----------------------------------------------------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/uon/UonParserSession.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/uon/UonParserSession.java
index ecc6bf9..71528b6 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/uon/UonParserSession.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/uon/UonParserSession.java
@@ -20,6 +20,7 @@ import java.lang.reflect.*;
import java.util.*;
import org.apache.juneau.*;
+import org.apache.juneau.httppart.*;
import org.apache.juneau.internal.*;
import org.apache.juneau.parser.*;
import org.apache.juneau.transform.*;
@@ -32,7 +33,7 @@ import org.apache.juneau.transform.*;
* It is typically discarded after one-time use although it can be reused against multiple inputs.
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
-public class UonParserSession extends ReaderParserSession {
+public class UonParserSession extends ReaderParserSession implements HttpPartParserSession {
// Characters that need to be preceded with an escape character.
private static final AsciiSet escapedChars = AsciiSet.create("~'\u0001\u0002");
@@ -113,6 +114,56 @@ public class UonParserSession extends ReaderParserSession {
}
}
+ @Override /* HttpPartParser */
+ public <T> T parse(HttpPartType partType, HttpPartSchema schema, String in, ClassMeta<T> toType) throws ParseException, SchemaValidationException {
+ if (in == null)
+ return null;
+ if (toType.isString() && in.length() > 0) {
+ // Shortcut - If we're returning a string and the value doesn't start with "'" or is "null", then
+ // just return the string since it's a plain value.
+ // This allows us to bypass the creation of a UonParserSession object.
+ char x = firstNonWhitespaceChar(in);
+ if (x != '\'' && x != 'n' && in.indexOf('~') == -1)
+ return (T)in;
+ if (x == 'n' && "null".equals(in))
+ return null;
+ }
+ try (ParserPipe pipe = createPipe(in)) {
+ try (UonReader r = getUonReader(pipe, false)) {
+ return parseAnything(toType, r, null, true, null);
+ }
+ } catch (ParseException e) {
+ throw e;
+ } catch (Exception e) {
+ throw new ParseException(e);
+ }
+ }
+
+ @Override /* HttpPartParserSession */
+ public <T> T parse(HttpPartType partType, HttpPartSchema schema, String in, Class<T> toType) throws ParseException, SchemaValidationException {
+ return parse(null, schema, in, getClassMeta(toType));
+ }
+
+ @Override /* HttpPartParserSession */
+ public <T> T parse(HttpPartType partType, HttpPartSchema schema, String in, Type toType, Type...toTypeArgs) throws ParseException, SchemaValidationException {
+ return (T)parse(null, schema, in, getClassMeta(toType, toTypeArgs));
+ }
+
+ @Override /* HttpPartParserSession */
+ public <T> T parse(HttpPartSchema schema, String in, Class<T> toType) throws ParseException, SchemaValidationException {
+ return parse(null, schema, in, getClassMeta(toType));
+ }
+
+ @Override /* HttpPartParserSession */
+ public <T> T parse(HttpPartSchema schema, String in, ClassMeta<T> toType) throws ParseException, SchemaValidationException {
+ return parse(null, schema, in, toType);
+ }
+
+ @Override /* HttpPartParserSession */
+ public <T> T parse(HttpPartSchema schema, String in, Type toType, Type...toTypeArgs) throws ParseException, SchemaValidationException {
+ return (T)parse(null, schema, in, getClassMeta(toType, toTypeArgs));
+ }
+
/**
* Workhorse method.
*
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/uon/UonSerializer.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/uon/UonSerializer.java
index d2c6534..db51d55 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/uon/UonSerializer.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/uon/UonSerializer.java
@@ -13,6 +13,7 @@
package org.apache.juneau.uon;
import org.apache.juneau.*;
+import org.apache.juneau.httppart.*;
import org.apache.juneau.serializer.*;
import org.apache.juneau.urlencoding.*;
@@ -113,7 +114,7 @@ import org.apache.juneau.urlencoding.*;
* String s = UonSerializer.<jsf>DEFAULT</jsf>.serialize(s);
* </p>
*/
-public class UonSerializer extends WriterSerializer {
+public class UonSerializer extends WriterSerializer implements HttpPartSerializer {
//-------------------------------------------------------------------------------------------------------------------
// Configurable properties
@@ -384,6 +385,26 @@ public class UonSerializer extends WriterSerializer {
return new UonSerializerSession(this, null, args);
}
+ @Override /* HttpPartSerializer */
+ public UonSerializerSession createPartSession(SerializerSessionArgs args) {
+ return new UonSerializerSession(this, null, args);
+ }
+
+ @Override /* HttpPartSerializer */
+ public UonSerializerSession createPartSession() {
+ return createPartSession(null);
+ }
+
+ @Override /* HttpPartSerializer */
+ public String serialize(HttpPartType partType, HttpPartSchema schema, Object value) throws SchemaValidationException, SerializeException {
+ return createPartSession().serialize(partType, schema, value);
+ }
+
+ @Override /* HttpPartSerializer */
+ public String serialize(HttpPartSchema schema, Object value) throws SchemaValidationException, SerializeException {
+ return createPartSession().serialize(null, schema, value);
+ }
+
//-----------------------------------------------------------------------------------------------------------------
// Properties
//-----------------------------------------------------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/uon/UonSerializerSession.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/uon/UonSerializerSession.java
index 542883f..6211598 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/uon/UonSerializerSession.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/uon/UonSerializerSession.java
@@ -12,9 +12,11 @@
// ***************************************************************************************************************************
package org.apache.juneau.uon;
+import java.io.*;
import java.util.*;
import org.apache.juneau.*;
+import org.apache.juneau.httppart.*;
import org.apache.juneau.internal.*;
import org.apache.juneau.serializer.*;
import org.apache.juneau.transform.*;
@@ -26,7 +28,7 @@ import org.apache.juneau.transform.*;
* This class is NOT thread safe.
* It is typically discarded after one-time use although it can be reused within the same thread.
*/
-public class UonSerializerSession extends WriterSerializerSession {
+public class UonSerializerSession extends WriterSerializerSession implements HttpPartSerializerSession {
private final UonSerializer ctx;
private final boolean plainTextParams;
@@ -52,7 +54,7 @@ public class UonSerializerSession extends WriterSerializerSession {
public ObjectMap asMap() {
return super.asMap()
.append("UonSerializerSession", new ObjectMap()
- );
+ );
}
/**
@@ -71,6 +73,10 @@ public class UonSerializerSession extends WriterSerializerSession {
return w;
}
+ private final UonWriter getUonWriter(Writer out) throws Exception {
+ return new UonWriter(this, out, isUseWhitespace(), getMaxIndent(), isEncodeChars(), isTrimStrings(), plainTextParams, getUriResolver());
+ }
+
@Override /* Serializer */
protected void doSerialize(SerializerPipe out, Object o) throws Exception {
serializeAnything(getUonWriter(out), o, getExpectedRootType(o), "root", null);
@@ -261,6 +267,33 @@ public class UonSerializerSession extends WriterSerializerSession {
return out;
}
+ @Override /* HttpPartSerializer */
+ public String serialize(HttpPartType type, HttpPartSchema schema, Object value) throws SerializeException, SchemaValidationException {
+ try {
+ // Shortcut for simple types.
+ ClassMeta<?> cm = getClassMetaForObject(value);
+ if (cm != null) {
+ if (cm.isNumber() || cm.isBoolean())
+ return ClassUtils.toString(value);
+ if (cm.isString()) {
+ String s = ClassUtils.toString(value);
+ if (s.isEmpty() || ! UonUtils.needsQuotes(s))
+ return s;
+ }
+ }
+ StringWriter w = new StringWriter();
+ serializeAnything(getUonWriter(w), value, getExpectedRootType(value), "root", null);
+ return w.toString();
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ @Override /* HttpPartSerializer */
+ public String serialize(HttpPartSchema schema, Object value) throws SerializeException, SchemaValidationException {
+ return serialize(null, schema, value);
+ }
+
//-----------------------------------------------------------------------------------------------------------------
// Properties
//-----------------------------------------------------------------------------------------------------------------
diff --git a/juneau-doc/src/main/resources/ReleaseNotes/7.2.0.html b/juneau-doc/src/main/resources/ReleaseNotes/7.2.0.html
index 2efd032..d4ca7ce 100644
--- a/juneau-doc/src/main/resources/ReleaseNotes/7.2.0.html
+++ b/juneau-doc/src/main/resources/ReleaseNotes/7.2.0.html
@@ -459,6 +459,19 @@
<li class='jf'>{@link oajr.RestContext#REST_uriResolution REST_uriResolution}
</ul>
</ul>
+ <li>
+ New convenience annotations for specifying default <code>Accept</code> and <code>Content-Type</code> headers:
+ <ul class='doctree'>
+ <li class='jc'>{@link oajr.annotation.RestResource}
+ <ul>
+ <li class='jf'>{@link oajr.annotation.RestResource#defaultAccept defaultAccept}
+ <li class='jf'>{@link oajr.annotation.RestResource#defaultContentType defaultContentType}
+ </ul>
+ <li class='jc'>{@link oajr.annotation.RestMethod}
+ <ul>
+ <li class='jf'>{@link oajr.annotation.RestMethod#defaultAccept defaultAccept}
+ <li class='jf'>{@link oajr.annotation.RestMethod#defaultContentType defaultContentType}
+ </ul>
</ul>
<h5 class='topic w800'>juneau-rest-client</h5>
diff --git a/juneau-microservice/juneau-microservice-test/src/test/java/org/apache/juneau/rest/test/client/RequestBeanProxyTest.java b/juneau-microservice/juneau-microservice-test/src/test/java/org/apache/juneau/rest/test/client/RequestBeanProxyTest.java
index e59972e..d5938e8 100644
--- a/juneau-microservice/juneau-microservice-test/src/test/java/org/apache/juneau/rest/test/client/RequestBeanProxyTest.java
+++ b/juneau-microservice/juneau-microservice-test/src/test/java/org/apache/juneau/rest/test/client/RequestBeanProxyTest.java
@@ -28,6 +28,7 @@ import org.apache.juneau.rest.client.*;
import org.apache.juneau.rest.client.remote.*;
import org.apache.juneau.rest.mock.*;
import org.apache.juneau.serializer.*;
+import org.apache.juneau.uon.*;
import org.apache.juneau.urlencoding.*;
import org.apache.juneau.utils.*;
import org.junit.*;
@@ -84,7 +85,7 @@ public class RequestBeanProxyTest {
}
static A01_RemoteResource a01a = RestClient.create().mockHttpConnection(a).build().getRemoteResource(A01_RemoteResource.class, null);
- static A01_RemoteResource a01b = RestClient.create().partSerializer(UonPartSerializer.class).mockHttpConnection(a).build().getRemoteResource(A01_RemoteResource.class, null);
+ static A01_RemoteResource a01b = RestClient.create().partSerializer(UonSerializer.class).mockHttpConnection(a).build().getRemoteResource(A01_RemoteResource.class, null);
@Test
public void a01a_query_simpleVals_plainText() throws Exception {
@@ -133,7 +134,7 @@ public class RequestBeanProxyTest {
}
static A02_RemoteResource a02a = RestClient.create().mockHttpConnection(a).build().getRemoteResource(A02_RemoteResource.class, null);
- static A02_RemoteResource a02b = RestClient.create().partSerializer(UonPartSerializer.class).mockHttpConnection(a).build().getRemoteResource(A02_RemoteResource.class, null);
+ static A02_RemoteResource a02b = RestClient.create().partSerializer(UonSerializer.class).mockHttpConnection(a).build().getRemoteResource(A02_RemoteResource.class, null);
@Test
public void a02a_query_maps_plainText() throws Exception {
@@ -185,7 +186,7 @@ public class RequestBeanProxyTest {
}
static A03_RemoteResource a03a = RestClient.create().mockHttpConnection(a).build().getRemoteResource(A03_RemoteResource.class, null);
- static A03_RemoteResource a03b = RestClient.create().partSerializer(UonPartSerializer.class).mockHttpConnection(a).build().getRemoteResource(A03_RemoteResource.class, null);
+ static A03_RemoteResource a03b = RestClient.create().partSerializer(UonSerializer.class).mockHttpConnection(a).build().getRemoteResource(A03_RemoteResource.class, null);
@Test
public void a03a_query_nameValuePairs_plainText() throws Exception {
@@ -307,7 +308,7 @@ public class RequestBeanProxyTest {
}
static A06_RemoteResource a06a = RestClient.create().mockHttpConnection(a).build().getRemoteResource(A06_RemoteResource.class, null);
- static A06_RemoteResource a06b = RestClient.create().partSerializer(UonPartSerializer.class).mockHttpConnection(a).build().getRemoteResource(A06_RemoteResource.class, null);
+ static A06_RemoteResource a06b = RestClient.create().partSerializer(UonSerializer.class).mockHttpConnection(a).build().getRemoteResource(A06_RemoteResource.class, null);
@Test
public void a06a_query_collections_plainText() throws Exception {
@@ -384,7 +385,7 @@ public class RequestBeanProxyTest {
}
static C01_RemoteResource c01a = RestClient.create().mockHttpConnection(c).build().getRemoteResource(C01_RemoteResource.class, null);
- static C01_RemoteResource c01b = RestClient.create().partSerializer(UonPartSerializer.class).mockHttpConnection(c).build().getRemoteResource(C01_RemoteResource.class, null);
+ static C01_RemoteResource c01b = RestClient.create().partSerializer(UonSerializer.class).mockHttpConnection(c).build().getRemoteResource(C01_RemoteResource.class, null);
@Test
public void c01a_formData_simpleVals_plainText() throws Exception {
@@ -436,7 +437,7 @@ public class RequestBeanProxyTest {
}
static C02_RemoteResource c02a = RestClient.create().mockHttpConnection(c).build().getRemoteResource(C02_RemoteResource.class, null);
- static C02_RemoteResource c02b = RestClient.create().partSerializer(UonPartSerializer.class).mockHttpConnection(c).build().getRemoteResource(C02_RemoteResource.class, null);
+ static C02_RemoteResource c02b = RestClient.create().partSerializer(UonSerializer.class).mockHttpConnection(c).build().getRemoteResource(C02_RemoteResource.class, null);
@Test
public void c02a_formData_maps_plainText() throws Exception {
@@ -488,7 +489,7 @@ public class RequestBeanProxyTest {
}
static C03_RemoteResource c03a = RestClient.create().mockHttpConnection(c).build().getRemoteResource(C03_RemoteResource.class, null);
- static C03_RemoteResource c03b = RestClient.create().partSerializer(UonPartSerializer.class).mockHttpConnection(c).build().getRemoteResource(C03_RemoteResource.class, null);
+ static C03_RemoteResource c03b = RestClient.create().partSerializer(UonSerializer.class).mockHttpConnection(c).build().getRemoteResource(C03_RemoteResource.class, null);
@Test
public void c03a_formData_nameValuePairs_plainText() throws Exception {
@@ -610,7 +611,7 @@ public class RequestBeanProxyTest {
}
static C06_RemoteResource c06a = RestClient.create().mockHttpConnection(c).build().getRemoteResource(C06_RemoteResource.class, null);
- static C06_RemoteResource c06b = RestClient.create().partSerializer(UonPartSerializer.class).mockHttpConnection(c).build().getRemoteResource(C06_RemoteResource.class, null);
+ static C06_RemoteResource c06b = RestClient.create().partSerializer(UonSerializer.class).mockHttpConnection(c).build().getRemoteResource(C06_RemoteResource.class, null);
@Test
public void c06a_formData_collections_plainText() throws Exception {
@@ -688,7 +689,7 @@ public class RequestBeanProxyTest {
}
static E01_RemoteResource e01a = RestClient.create().mockHttpConnection(e).build().getRemoteResource(E01_RemoteResource.class, null);
- static E01_RemoteResource e01b = RestClient.create().partSerializer(UonPartSerializer.class).mockHttpConnection(e).build().getRemoteResource(E01_RemoteResource.class, null);
+ static E01_RemoteResource e01b = RestClient.create().partSerializer(UonSerializer.class).mockHttpConnection(e).build().getRemoteResource(E01_RemoteResource.class, null);
@Test
public void e01a_headerSimpleValsPlainText() throws Exception {
@@ -740,7 +741,7 @@ public class RequestBeanProxyTest {
}
static E02_RemoteResource e02a = RestClient.create().mockHttpConnection(e).build().getRemoteResource(E02_RemoteResource.class, null);
- static E02_RemoteResource e02b = RestClient.create().partSerializer(UonPartSerializer.class).mockHttpConnection(e).build().getRemoteResource(E02_RemoteResource.class, null);
+ static E02_RemoteResource e02b = RestClient.create().partSerializer(UonSerializer.class).mockHttpConnection(e).build().getRemoteResource(E02_RemoteResource.class, null);
@Test
public void e02a_header_maps_plainText() throws Exception {
@@ -773,26 +774,26 @@ public class RequestBeanProxyTest {
}
public static class E03_Bean {
- @Header
+ @Header(allowEmptyValue=true)
public NameValuePairs getA() {
return new NameValuePairs().append("a1","v1").append("a2", 123).append("a3", null).append("a4", "");
}
- @Header("*")
+ @Header(value="*",allowEmptyValue=true)
public NameValuePairs getB() {
return new NameValuePairs().append("b1","true").append("b2", "123").append("b3", "null");
}
- @Header(name="*")
+ @Header(name="*",allowEmptyValue=true)
public NameValuePairs getC() {
return new NameValuePairs().append("c1","v1").append("c2", 123).append("c3", null).append("c4", "");
}
- @Header("*")
+ @Header(value="*",allowEmptyValue=true)
public NameValuePairs getD() {
return null;
}
}
static E03_RemoteResource e03a = RestClient.create().mockHttpConnection(e).build().getRemoteResource(E03_RemoteResource.class, null);
- static E03_RemoteResource e03b = RestClient.create().partSerializer(UonPartSerializer.class).mockHttpConnection(e).build().getRemoteResource(E03_RemoteResource.class, null);
+ static E03_RemoteResource e03b = RestClient.create().partSerializer(UonSerializer.class).mockHttpConnection(e).build().getRemoteResource(E03_RemoteResource.class, null);
@Test
public void e03a_header_nameValuePairs_plainText() throws Exception {
@@ -802,12 +803,12 @@ public class RequestBeanProxyTest {
@Test
public void e03b_header_nameValuePairs_uon() throws Exception {
String r = e03b.normal(new E03_Bean());
- assertEquals("{a1:'v1',a2:'123',a4:'',b1:'true',b2:'123',b3:'null',c1:'v1',c2:'123',c4:''}", r);
+ assertEquals("{a1:'v1',a2:'\\'123\\'',a4:'',b1:'\\'true\\'',b2:'\\'123\\'',b3:'\\'null\\'',c1:'v1',c2:'\\'123\\'',c4:''}", r);
}
@Test
public void e03c_header_nameValuePairs_x() throws Exception {
String r = e03b.serialized(new E03_Bean());
- assertEquals("{a1:'v1',a2:'123',a4:'',b1:'true',b2:'123',b3:'null',c1:'v1',c2:'123',c4:''}", r);
+ assertEquals("{a1:'xv1x',a2:'x123x',a4:'xx',b1:'xtruex',b2:'x123x',b3:'xnullx',c1:'xv1x',c2:'x123x',c4:'xx'}", r);
}
//=================================================================================================================
@@ -864,7 +865,7 @@ public class RequestBeanProxyTest {
}
static E04_RemoteResource e04a = RestClient.create().mockHttpConnection(e).build().getRemoteResource(E04_RemoteResource.class, null);
- static E04_RemoteResource e04b = RestClient.create().partSerializer(UonPartSerializer.class).mockHttpConnection(e).build().getRemoteResource(E04_RemoteResource.class, null);
+ static E04_RemoteResource e04b = RestClient.create().partSerializer(UonSerializer.class).mockHttpConnection(e).build().getRemoteResource(E04_RemoteResource.class, null);
@Test
public void e04a_header_collections_plainText() throws Exception {
@@ -941,7 +942,7 @@ public class RequestBeanProxyTest {
}
static G01_RemoteResource g01a = RestClient.create().mockHttpConnection(g).build().getRemoteResource(G01_RemoteResource.class, null);
- static G01_RemoteResource g01b = RestClient.create().partSerializer(UonPartSerializer.class).mockHttpConnection(g).build().getRemoteResource(G01_RemoteResource.class, null);
+ static G01_RemoteResource g01b = RestClient.create().partSerializer(UonSerializer.class).mockHttpConnection(g).build().getRemoteResource(G01_RemoteResource.class, null);
@Test
public void g01a_pathSimpleValsPlainText() throws Exception {
@@ -993,7 +994,7 @@ public class RequestBeanProxyTest {
}
static G02_RemoteResource g02a = RestClient.create().mockHttpConnection(g).build().getRemoteResource(G02_RemoteResource.class, null);
- static G02_RemoteResource g02b = RestClient.create().partSerializer(UonPartSerializer.class).mockHttpConnection(g).build().getRemoteResource(G02_RemoteResource.class, null);
+ static G02_RemoteResource g02b = RestClient.create().partSerializer(UonSerializer.class).mockHttpConnection(g).build().getRemoteResource(G02_RemoteResource.class, null);
@Test
public void g02a_path_maps_plainText() throws Exception {
@@ -1045,7 +1046,7 @@ public class RequestBeanProxyTest {
}
static G03_RemoteResource g03a = RestClient.create().mockHttpConnection(g).build().getRemoteResource(G03_RemoteResource.class, null);
- static G03_RemoteResource g03b = RestClient.create().partSerializer(UonPartSerializer.class).mockHttpConnection(g).build().getRemoteResource(G03_RemoteResource.class, null);
+ static G03_RemoteResource g03b = RestClient.create().partSerializer(UonSerializer.class).mockHttpConnection(g).build().getRemoteResource(G03_RemoteResource.class, null);
@Test
public void g03a_path_nameValuePairs_plainText() throws Exception {
@@ -1117,7 +1118,7 @@ public class RequestBeanProxyTest {
}
static G04_RemoteResource g04a = RestClient.create().mockHttpConnection(g).build().getRemoteResource(G04_RemoteResource.class, null);
- static G04_RemoteResource g04b = RestClient.create().partSerializer(UonPartSerializer.class).mockHttpConnection(g).build().getRemoteResource(G04_RemoteResource.class, null);
+ static G04_RemoteResource g04b = RestClient.create().partSerializer(UonSerializer.class).mockHttpConnection(g).build().getRemoteResource(G04_RemoteResource.class, null);
@Test
public void g04a_path_collections_plainText() throws Exception {
@@ -1139,10 +1140,10 @@ public class RequestBeanProxyTest {
// Support classes
//=================================================================================================================
- public static class XSerializer implements HttpPartSerializer {
+ public static class XSerializer extends BaseHttpPartSerializer {
@Override
- public HttpPartSerializerSession createSession(SerializerSessionArgs args) {
- return new HttpPartSerializerSession() {
+ public HttpPartSerializerSession createPartSession(SerializerSessionArgs args) {
+ return new BaseHttpPartSerializerSession() {
@Override
public String serialize(HttpPartType partType, HttpPartSchema schema, Object value) throws SerializeException, SchemaValidationException {
if (value == null)
@@ -1158,19 +1159,19 @@ public class RequestBeanProxyTest {
@Override
public String serialize(HttpPartType partType, HttpPartSchema schema, Object value) throws SchemaValidationException, SerializeException {
- return createSession(null).serialize(partType, schema, value);
+ return createPartSession().serialize(partType, schema, value);
}
@Override
public String serialize(HttpPartSchema schema, Object value) throws SchemaValidationException, SerializeException {
- return createSession(null).serialize(null, schema, value);
+ return createPartSession().serialize(null, schema, value);
}
}
- public static class ListSerializer implements HttpPartSerializer {
+ public static class ListSerializer extends BaseHttpPartSerializer {
@Override
- public HttpPartSerializerSession createSession(SerializerSessionArgs args) {
- return new HttpPartSerializerSession() {
+ public HttpPartSerializerSession createPartSession(SerializerSessionArgs args) {
+ return new BaseHttpPartSerializerSession() {
@Override
public String serialize(HttpPartType partType, HttpPartSchema schema, Object value) throws SerializeException, SchemaValidationException {
if (value == null)
@@ -1186,12 +1187,12 @@ public class RequestBeanProxyTest {
@Override
public String serialize(HttpPartType partType, HttpPartSchema schema, Object value) throws SchemaValidationException, SerializeException {
- return createSession(null).serialize(partType, schema, value);
+ return createPartSession().serialize(partType, schema, value);
}
@Override
public String serialize(HttpPartSchema schema, Object value) throws SchemaValidationException, SerializeException {
- return createSession(null).serialize(null, schema, value);
+ return createPartSession().serialize(null, schema, value);
}
}
}
diff --git a/juneau-microservice/juneau-microservice-test/src/test/java/org/apache/juneau/rest/test/client/ThirdPartyProxyTest.java b/juneau-microservice/juneau-microservice-test/src/test/java/org/apache/juneau/rest/test/client/ThirdPartyProxyTest.java
index 53dc18e..aa607ee 100644
--- a/juneau-microservice/juneau-microservice-test/src/test/java/org/apache/juneau/rest/test/client/ThirdPartyProxyTest.java
+++ b/juneau-microservice/juneau-microservice-test/src/test/java/org/apache/juneau/rest/test/client/ThirdPartyProxyTest.java
@@ -65,7 +65,7 @@ public class ThirdPartyProxyTest extends RestTestcase {
public ThirdPartyProxyTest(String label, Serializer serializer, Parser parser) {
proxy = getCached(label, ThirdPartyProxy.class);
if (proxy == null) {
- this.proxy = getClient(label, serializer, parser).builder().partSerializer(UonPartSerializer.DEFAULT.builder().addBeanTypes().addRootType().build()).build().getRemoteResource(ThirdPartyProxy.class, null, serializer, parser);
+ this.proxy = getClient(label, serializer, parser).builder().partSerializer(UonSerializer.DEFAULT.builder().addBeanTypes().addRootType().build()).build().getRemoteResource(ThirdPartyProxy.class, null, serializer, parser);
cache(label, proxy);
}
}
@@ -1691,7 +1691,7 @@ public class ThirdPartyProxyTest extends RestTestcase {
@RemoteMethod(method="GET", path="/nameValuePairsHeader")
String nameValuePairsHeader(
- @Header("*") NameValuePairs a
+ @Header(value="*", allowEmptyValue=true) NameValuePairs a
);
//--------------------------------------------------------------------------------
@@ -2604,10 +2604,10 @@ public class ThirdPartyProxyTest extends RestTestcase {
}
}
- public static class DummyPartSerializer implements HttpPartSerializer {
+ public static class DummyPartSerializer extends BaseHttpPartSerializer {
@Override
- public HttpPartSerializerSession createSession(SerializerSessionArgs args) {
- return new HttpPartSerializerSession() {
+ public HttpPartSerializerSession createPartSession(SerializerSessionArgs args) {
+ return new BaseHttpPartSerializerSession() {
@Override
public String serialize(HttpPartType partType, HttpPartSchema schema, Object value) throws SerializeException, SchemaValidationException {
return "dummy-"+value;
@@ -2617,12 +2617,12 @@ public class ThirdPartyProxyTest extends RestTestcase {
@Override
public String serialize(HttpPartType partType, HttpPartSchema schema, Object value) throws SchemaValidationException, SerializeException {
- return createSession(null).serialize(partType, schema, value);
+ return createPartSession().serialize(partType, schema, value);
}
@Override
public String serialize(HttpPartSchema schema, Object value) throws SchemaValidationException, SerializeException {
- return createSession(null).serialize(null, schema, value);
+ return createPartSession().serialize(null, schema, value);
}
}
}
diff --git a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/NameValuePairs.java b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/NameValuePairs.java
index 4f3d118..f2324ab 100644
--- a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/NameValuePairs.java
+++ b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/NameValuePairs.java
@@ -20,6 +20,7 @@ import org.apache.http.*;
import org.apache.http.client.entity.*;
import org.apache.http.message.*;
import org.apache.juneau.httppart.*;
+import org.apache.juneau.oapi.*;
import org.apache.juneau.urlencoding.*;
/**
@@ -82,7 +83,7 @@ public final class NameValuePairs extends LinkedList<NameValuePair> {
* The schema object that defines the format of the output.
* <br>If <jk>null</jk>, defaults to the schema defined on the parser.
* <br>If that's also <jk>null</jk>, defaults to {@link HttpPartSchema#DEFAULT}.
- * <br>Ignored if the serializer parser is not a subclass of {@link OpenApiPartSerializer}.
+ * <br>Only used if serializer is schema-aware (e.g. {@link OpenApiSerializer}).
* @return This object (for method chaining).
*/
public NameValuePairs append(String name, Object value, HttpPartSerializer serializer, HttpPartSchema schema) {
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 37c1c0e..1746def 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
@@ -42,6 +42,7 @@ import org.apache.juneau.http.*;
import org.apache.juneau.httppart.*;
import org.apache.juneau.httppart.bean.*;
import org.apache.juneau.internal.*;
+import org.apache.juneau.oapi.*;
import org.apache.juneau.parser.*;
import org.apache.juneau.parser.ParseException;
import org.apache.juneau.serializer.*;
@@ -101,6 +102,7 @@ public final class RestCall extends BeanSession implements Closeable {
private Parser parser;
private HttpPartSerializer partSerializer;
private HttpPartParser partParser;
+ private HttpPartSchema requestBodySchema, responseBodySchema;
private URIBuilder uriBuilder;
private NameValuePairs formData;
@@ -210,7 +212,7 @@ public final class RestCall extends BeanSession implements Closeable {
* The schema object that defines the format of the output.
* <br>If <jk>null</jk>, defaults to the schema defined on the serializer.
* <br>If that's also <jk>null</jk>, defaults to {@link HttpPartSchema#DEFAULT}.
- * <br>Ignored if the part serializer is not a subclass of {@link OpenApiPartSerializer}.
+ * <br>Only used if serializer is schema-aware (e.g. {@link OpenApiSerializer}).
* @return This object (for method chaining).
* @throws RestCallException
*/
@@ -221,7 +223,7 @@ public final class RestCall extends BeanSession implements Closeable {
if (! isMulti) {
if (value != null && ! (ObjectUtils.isEmpty(value) && skipIfEmpty))
try {
- uriBuilder.addParameter(name, serializer.createSession(null).serialize(QUERY, schema, value));
+ uriBuilder.addParameter(name, serializer.createPartSession().serialize(QUERY, schema, value));
} catch (SchemaValidationException e) {
throw new RestCallException(e, "Validation error on request query parameter ''{0}''=''{1}''", name, value);
} catch (SerializeException e) {
@@ -331,7 +333,7 @@ public final class RestCall extends BeanSession implements Closeable {
* The schema object that defines the format of the output.
* <br>If <jk>null</jk>, defaults to the schema defined on the serializer.
* <br>If that's also <jk>null</jk>, defaults to {@link HttpPartSchema#DEFAULT}.
- * <br>Ignored if the part serializer is not a subclass of {@link OpenApiPartSerializer}.
+ * <br>Only used if serializer is schema-aware (e.g. {@link OpenApiSerializer}).
* @return This object (for method chaining).
* @throws RestCallException
*/
@@ -446,7 +448,7 @@ public final class RestCall extends BeanSession implements Closeable {
* The schema object that defines the format of the output.
* <br>If <jk>null</jk>, defaults to the schema defined on the serializer.
* <br>If that's also <jk>null</jk>, defaults to {@link HttpPartSchema#DEFAULT}.
- * <br>Ignored if the part serializer is not a subclass of {@link OpenApiPartSerializer}.
+ * <br>Only used if serializer is schema-aware (e.g. {@link OpenApiSerializer}).
* @return This object (for method chaining).
* @throws RestCallException If variable could not be found in path.
*/
@@ -462,9 +464,9 @@ public final class RestCall extends BeanSession implements Closeable {
try {
String p = null;
if (name.equals("/*"))
- p = path.replaceAll("\\/\\*$", serializer.createSession(null).serialize(PATH, schema, value));
+ p = path.replaceAll("\\/\\*$", serializer.createPartSession().serialize(PATH, schema, value));
else
- p = path.replace(var, serializer.createSession(null).serialize(PATH, schema, value));
+ p = path.replace(var, serializer.createPartSession().serialize(PATH, schema, value));
uriBuilder.setPath(p);
} catch (SchemaValidationException e) {
throw new RestCallException(e, "Validation error on request path parameter ''{0}''=''{1}''", name, value);
@@ -521,6 +523,38 @@ public final class RestCall extends BeanSession implements Closeable {
}
/**
+ * Specifies the part schema for the request body.
+ *
+ * <p>
+ * This is only useful for schema-aware serializers such as {@link OpenApiSerializer}.
+ *
+ * @param value
+ * The new part schema for the request body.
+ * <br>Can be <jk>null</jk>.
+ * @return This object (for method chaining).
+ */
+ public RestCall requestBodySchema(HttpPartSchema value) {
+ this.requestBodySchema = value;
+ return this;
+ }
+
+ /**
+ * Specifies the part schema for the response body.
+ *
+ * <p>
+ * This is only useful for schema-aware parsers such as {@link OpenApiParser}.
+ *
+ * @param value
+ * The new part schema for the response body.
+ * <br>Can be <jk>null</jk>.
+ * @return This object (for method chaining).
+ */
+ public RestCall responseBodySchema(HttpPartSchema value) {
+ this.responseBodySchema = value;
+ return this;
+ }
+
+ /**
* Sets the input for this REST call.
*
* @param input
@@ -543,37 +577,9 @@ public final class RestCall extends BeanSession implements Closeable {
* @throws RestCallException If a retry was attempted, but the entity was not repeatable.
*/
public RestCall body(Object input) throws RestCallException {
- return body(input, null, null);
- }
-
- /**
- * Same as {@link #body(Object)} but allows you to specify a part serializer to use to serialize the body.
- *
- * @param input
- * The input to be sent to the REST resource (only valid for PUT and POST) requests. <br>
- * @param partSerializer
- * The part serializer to use to serialize the body of the request.
- * <br>If <jk>null</jk>, will use normal serializer.
- * @param schema
- * The schema information about the part being serialized.
- * @return This object (for method chaining).
- * @throws RestCallException
- */
- public RestCall body(Object input, HttpPartSerializer partSerializer, HttpPartSchema schema) throws RestCallException {
- try {
- if (schema != null && schema.isUsePartSerializer())
- partSerializer = this.partSerializer;
- if (partSerializer != null)
- this.input = new StringEntity(partSerializer.serialize(BODY, schema, input), TEXT_PLAIN);
- else
- this.input = input;
- this.hasInput = true;
- this.formData = null;
- } catch (SchemaValidationException e) {
- throw new RestCallException(e, "Validation error on request body.");
- } catch (Exception e) {
- throw new RestCallException(e, "Serialization error on request body.");
- }
+ this.input = input;
+ this.hasInput = true;
+ this.formData = null;
return this;
}
@@ -624,7 +630,7 @@ public final class RestCall extends BeanSession implements Closeable {
* The schema object that defines the format of the output.
* <br>If <jk>null</jk>, defaults to the schema defined on the serializer.
* <br>If that's also <jk>null</jk>, defaults to {@link HttpPartSchema#DEFAULT}.
- * <br>Ignored if the part serializer is not a subclass of {@link OpenApiPartSerializer}.
+ * <br>Only used if serializer is schema-aware (e.g. {@link OpenApiSerializer}).
* @return This object (for method chaining).
* @throws RestCallException
*/
@@ -635,7 +641,7 @@ public final class RestCall extends BeanSession implements Closeable {
if (! isMulti) {
if (value != null && ! (ObjectUtils.isEmpty(value) && skipIfEmpty))
try {
- request.setHeader(name, serializer.createSession(null).serialize(HEADER, schema, value));
+ request.setHeader(name, serializer.createPartSession().serialize(HEADER, schema, value));
} catch (SchemaValidationException e) {
throw new RestCallException(e, "Validation error on request header parameter ''{0}''=''{1}''", name, value);
} catch (SerializeException e) {
@@ -643,7 +649,7 @@ public final class RestCall extends BeanSession implements Closeable {
}
} else if (value instanceof NameValuePairs) {
for (NameValuePair p : (NameValuePairs)value)
- header(p.getName(), p.getValue(), skipIfEmpty, SimpleUonPartSerializer.DEFAULT, schema);
+ header(p.getName(), p.getValue(), skipIfEmpty, serializer, schema);
} else if (value instanceof Map) {
for (Map.Entry<String,Object> p : ((Map<String,Object>) value).entrySet())
header(p.getKey(), p.getValue(), skipIfEmpty, serializer, schema);
@@ -1573,7 +1579,7 @@ public final class RestCall extends BeanSession implements Closeable {
else if (input instanceof InputStream)
entity = new InputStreamEntity((InputStream)input, getRequestContentType(ContentType.APPLICATION_OCTET_STREAM));
else if (serializer != null)
- entity = new RestRequestEntity(input, serializer);
+ entity = new RestRequestEntity(input, serializer, requestBodySchema);
else if (partSerializer != null)
entity = new StringEntity(partSerializer.serialize(null, input), getRequestContentType(TEXT_PLAIN));
else
@@ -1979,7 +1985,7 @@ public final class RestCall extends BeanSession implements Closeable {
BeanContext bc = parser;
if (bc == null)
bc = BeanContext.DEFAULT;
- return getResponseInner(null, null, bc.getClassMeta(type));
+ return getResponseInner(bc.getClassMeta(type));
}
/**
@@ -2070,19 +2076,13 @@ public final class RestCall extends BeanSession implements Closeable {
BeanContext bc = parser;
if (bc == null)
bc = BeanContext.DEFAULT;
- return (T)getResponseInner(null, null, bc.getClassMeta(type, args));
+ return (T)getResponseInner(bc.getClassMeta(type, args));
}
/**
* Same as {@link #getResponse(Type, Type...)} but allows you to specify a part parser to use for parsing the response.
*
* @param <T> The class type of the object to create.
- * @param partParser
- * The part parser.
- * <br>Can be <jk>null</jk>.
- * @param schema
- * The schema information about the body of the response.
- * <br>Can be <jk>null</jk>.
* @param type
* The object type to create.
* <br>Can be any of the following: {@link ClassMeta}, {@link Class}, {@link ParameterizedType}, {@link GenericArrayType}
@@ -2096,11 +2096,11 @@ public final class RestCall extends BeanSession implements Closeable {
* @throws IOException If a connection error occurred.
* @see BeanSession#getClassMeta(Class) for argument syntax for maps and collections.
*/
- public <T> T getResponseBody(HttpPartParser partParser, HttpPartSchema schema, Type type, Type...args) throws IOException, ParseException {
+ public <T> T getResponseBody(Type type, Type...args) throws IOException, ParseException {
BeanContext bc = parser;
if (bc == null)
bc = BeanContext.DEFAULT;
- return (T)getResponseInner(partParser, schema, bc.getClassMeta(type, args));
+ return (T)getResponseInner(bc.getClassMeta(type, args));
}
/**
@@ -2164,14 +2164,11 @@ public final class RestCall extends BeanSession implements Closeable {
return getResponsePojoRest(ObjectMap.class);
}
- <T> T getResponseInner(HttpPartParser partParser, HttpPartSchema schema, ClassMeta<T> type) throws IOException, ParseException {
+ <T> T getResponseInner(ClassMeta<T> type) throws IOException, ParseException {
try {
if (response == null)
connect();
- if (partParser == null)
- partParser = this.partParser;
-
Class<?> ic = type.getInnerClass();
if (ic.equals(HttpResponse.class))
@@ -2183,22 +2180,19 @@ public final class RestCall extends BeanSession implements Closeable {
connect();
Header h = response.getFirstHeader("Content-Type");
- MediaType mt = MediaType.forString(h == null ? null : h.getValue());
+ String ct = firstNonEmpty(h == null ? null : h.getValue(), "text/plain");
- boolean usePartParser = isEmpty(mt)
- || mt.toString().equals("text/plain")
- || (schema != null && partParser != null && schema.isUsePartParser());
+ MediaType mt = MediaType.forString(ct);
- if (usePartParser) {
+ if (parser == null || (mt.toString().equals("text/plain") && ! parser.canHandle(ct))) {
if (type.hasStringTransform())
return type.getStringTransform().transform(getResponseAsString());
- if (partParser != null)
- return partParser.createSession(null).parse(BODY, schema, getResponseAsString(), type);
}
if (parser != null) {
try (Closeable in = parser.isReaderParser() ? getReader() : getInputStream()) {
- return parser.parse(in, type);
+ ParserSessionArgs pArgs = new ParserSessionArgs(this.getProperties(), null, response.getLocale(), null, mt, responseBodySchema, false, null);
+ return parser.createSession(pArgs).parse(in, type);
}
}
@@ -2241,6 +2235,7 @@ public final class RestCall extends BeanSession implements Closeable {
try {
Class<T> c = (Class<T>)rbm.getClassMeta().getInnerClass();
final RestClient rc = this.client;
+ final HttpPartParser p = ObjectUtils.firstNonNull(partParser, rc.getPartParser());
return (T)Proxy.newProxyInstance(
c.getClassLoader(),
new Class[] { c },
@@ -2249,13 +2244,15 @@ public final class RestCall extends BeanSession implements Closeable {
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
ResponseBeanPropertyMeta pm = rbm.getProperty(method.getName());
if (pm != null) {
- HttpPartParser pp = pm.getParser(rc.getPartParser());
+ HttpPartParser pp = pm.getParser(p);
HttpPartSchema schema = pm.getSchema();
String name = pm.getPartName();
ClassMeta<?> type = rc.getClassMeta(method.getGenericReturnType());
HttpPartType pt = pm.getPartType();
- if (pt == RESPONSE_BODY)
- return getResponseBody(pp, schema, type);
+ if (pt == RESPONSE_BODY) {
+ responseBodySchema(schema);
+ return getResponseBody(type);
+ }
if (pt == RESPONSE_HEADER)
return getResponseHeader(pp, schema, name, type);
if (pt == RESPONSE_STATUS)
diff --git a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestClient.java b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestClient.java
index 348fa96..cf85604 100644
--- a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestClient.java
+++ b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestClient.java
@@ -33,6 +33,7 @@ import org.apache.juneau.httppart.*;
import org.apache.juneau.httppart.bean.*;
import org.apache.juneau.internal.*;
import org.apache.juneau.json.*;
+import org.apache.juneau.oapi.*;
import org.apache.juneau.parser.*;
import org.apache.juneau.remote.*;
import org.apache.juneau.rest.client.remote.*;
@@ -238,7 +239,7 @@ public class RestClient extends BeanContext implements Closeable {
* <ul>
* <li><b>Name:</b> <js>"RestClient.partParser.o"</js>
* <li><b>Data type:</b> <code>Class<? <jk>implements</jk> HttpPartParser></code> or {@link HttpPartParser}.
- * <li><b>Default:</b> {@link OpenApiPartParser};
+ * <li><b>Default:</b> {@link OpenApiParser};
* <li><b>Methods:</b>
* <ul>
* <li class='jm'>{@link RestClientBuilder#partParser(Class)}
@@ -259,7 +260,7 @@ public class RestClient extends BeanContext implements Closeable {
* <ul>
* <li><b>Name:</b> <js>"RestClient.partSerializer.o"</js>
* <li><b>Data type:</b> <code>Class<? <jk>implements</jk> HttpPartSerializer></code> or {@link HttpPartSerializer}.
- * <li><b>Default:</b> {@link OpenApiPartSerializer};
+ * <li><b>Default:</b> {@link OpenApiSerializer};
* <li><b>Methods:</b>
* <ul>
* <li class='jm'>{@link RestClientBuilder#partSerializer(Class)}
@@ -519,8 +520,8 @@ public class RestClient extends BeanContext implements Closeable {
}
this.urlEncodingSerializer = new SerializerBuilder(ps).build(UrlEncodingSerializer.class);
- this.partSerializer = getInstanceProperty(RESTCLIENT_partSerializer, HttpPartSerializer.class, OpenApiPartSerializer.class, true, ps);
- this.partParser = getInstanceProperty(RESTCLIENT_partParser, HttpPartParser.class, OpenApiPartParser.class, true, ps);
+ this.partSerializer = getInstanceProperty(RESTCLIENT_partSerializer, HttpPartSerializer.class, OpenApiSerializer.class, true, ps);
+ this.partParser = getInstanceProperty(RESTCLIENT_partParser, HttpPartParser.class, OpenApiParser.class, true, ps);
this.executorService = getInstanceProperty(RESTCLIENT_executorService, ExecutorService.class, null);
RestCallInterceptor[] rci = getInstanceArrayProperty(RESTCLIENT_interceptors, RestCallInterceptor.class, new RestCallInterceptor[0]);
@@ -749,7 +750,7 @@ public class RestClient extends BeanContext implements Closeable {
*/
public RestCall doFormPost(Object url, Object o) throws RestCallException {
return doCall("POST", url, true)
- .body(o instanceof HttpEntity ? o : new RestRequestEntity(o, urlEncodingSerializer));
+ .body(o instanceof HttpEntity ? o : new RestRequestEntity(o, urlEncodingSerializer, null));
}
/**
@@ -1065,7 +1066,7 @@ public class RestClient extends BeanContext implements Closeable {
RemoteMethodArg ba = rmm.getBodyArg();
if (ba != null)
- rc.body(args[ba.getIndex()], ba.getSerializer(null), ba.getSchema());
+ rc.requestBodySchema(ba.getSchema()).body(args[ba.getIndex()]);
if (rmm.getRequestArgs().length > 0) {
for (RemoteMethodBeanArg rmba : rmm.getRequestArgs()) {
@@ -1087,7 +1088,7 @@ public class RestClient extends BeanContext implements Closeable {
else if (pt == HEADER)
rc.header(pn, val, sie, ps, schema);
else if (pt == HttpPartType.BODY)
- rc.body(val, p.getSerializer(s), schema);
+ rc.requestBodySchema(schema).body(val);
}
}
}
@@ -1115,7 +1116,7 @@ public class RestClient extends BeanContext implements Closeable {
return returnCode < 400;
throw new RestCallException("Invalid return type on method annotated with @RemoteMethod(returns=HTTP_STATUS). Only integer and booleans types are valid.");
} else {
- Object v = rc.getResponseBody(rmr.getParser(), rmr.getSchema(), method.getGenericReturnType());
+ Object v = rc.responseBodySchema(rmr.getSchema()).getResponseBody(method.getGenericReturnType());
if (v == null && method.getReturnType().isPrimitive())
v = ClassUtils.getPrimitiveDefault(method.getReturnType());
return v;
diff --git a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestClientBuilder.java b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestClientBuilder.java
index abf6892..4d6b8cd 100644
--- a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestClientBuilder.java
+++ b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestClientBuilder.java
@@ -53,6 +53,7 @@ import org.apache.juneau.httppart.*;
import org.apache.juneau.internal.*;
import org.apache.juneau.json.*;
import org.apache.juneau.msgpack.*;
+import org.apache.juneau.oapi.*;
import org.apache.juneau.parser.*;
import org.apache.juneau.plaintext.*;
import org.apache.juneau.rest.client.mock.*;
@@ -215,6 +216,17 @@ public class RestClientBuilder extends BeanContextBuilder {
return serializer(UrlEncodingSerializer.class).parser(UrlEncodingParser.class);
}
+ /**
+ * Convenience method for specifying URL-Encoding as the transmission media type.
+ *
+ * <p>
+ * Identical to calling <code>serializer(OpenApiSerializer.<jk>class</jk>).parser(OpenApiParser.<jk>class</jk>)</code>.
+ *
+ * @return This object (for method chaining).
+ */
+ public RestClientBuilder openapi() {
+ return serializer(OpenApiSerializer.class).parser(OpenApiParser.class);
+ }
/**
* Creates an instance of an {@link HttpClient} to be used to handle all HTTP communications with the target server.
@@ -1134,7 +1146,7 @@ public class RestClientBuilder extends BeanContextBuilder {
*
* @param value
* The new value for this setting.
- * <br>The default value is {@link OpenApiPartParser}.
+ * <br>The default value is {@link OpenApiParser}.
* @return This object (for method chaining).
*/
public RestClientBuilder partParser(Class<? extends HttpPartParser> value) {
@@ -1154,7 +1166,7 @@ public class RestClientBuilder extends BeanContextBuilder {
*
* @param value
* The new value for this setting.
- * <br>The default value is {@link OpenApiPartParser}.
+ * <br>The default value is {@link OpenApiParser}.
* @return This object (for method chaining).
*/
public RestClientBuilder partParser(HttpPartParser value) {
@@ -1174,7 +1186,7 @@ public class RestClientBuilder extends BeanContextBuilder {
*
* @param value
* The new value for this setting.
- * <br>The default value is {@link OpenApiPartSerializer}.
+ * <br>The default value is {@link OpenApiSerializer}.
* @return This object (for method chaining).
*/
public RestClientBuilder partSerializer(Class<? extends HttpPartSerializer> value) {
@@ -1194,7 +1206,7 @@ public class RestClientBuilder extends BeanContextBuilder {
*
* @param value
* The new value for this setting.
- * <br>The default value is {@link OpenApiPartSerializer}.
+ * <br>The default value is {@link OpenApiSerializer}.
* @return This object (for method chaining).
*/
public RestClientBuilder partSerializer(HttpPartSerializer value) {
diff --git a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestRequestEntity.java b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestRequestEntity.java
index 46adfaf..b89a609 100644
--- a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestRequestEntity.java
+++ b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestRequestEntity.java
@@ -18,6 +18,7 @@ import java.io.*;
import org.apache.http.entity.*;
import org.apache.http.message.*;
+import org.apache.juneau.httppart.*;
import org.apache.juneau.internal.*;
import org.apache.juneau.serializer.*;
import org.apache.juneau.utils.*;
@@ -28,6 +29,7 @@ import org.apache.juneau.utils.*;
public final class RestRequestEntity extends BasicHttpEntity {
final Object output;
final Serializer serializer;
+ final HttpPartSchema schema;
byte[] outputBytes;
/**
@@ -35,10 +37,12 @@ public final class RestRequestEntity extends BasicHttpEntity {
*
* @param input The POJO to serialize. Can also be a {@link Reader} or {@link InputStream}.
* @param serializer The serializer to use to serialize this response.
+ * @param schema The optional schema information about the serialized part.
*/
- public RestRequestEntity(Object input, Serializer serializer) {
+ public RestRequestEntity(Object input, Serializer serializer, HttpPartSchema schema) {
this.output = input;
this.serializer = serializer;
+ this.schema = schema;
if (serializer != null && serializer.getResponseContentType() != null)
setContentType(new BasicHeader("Content-Type", serializer.getResponseContentType().toString()));
}
@@ -58,7 +62,8 @@ public final class RestRequestEntity extends BasicHttpEntity {
// If no serializer specified, just close the stream.
os.close();
} else {
- SerializerSession session = serializer.createSession();
+ SerializerSessionArgs sArgs = new SerializerSessionArgs(null, null, null, null, null, schema, false, null, null);
+ SerializerSession session = serializer.createSession(sArgs);
try (Closeable c = session.isWriterSerializer() ? new OutputStreamWriter(os, UTF8) : os) {
session.serialize(output, c);
}
diff --git a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/SerializedNameValuePair.java b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/SerializedNameValuePair.java
index 747305b..6c920d9 100644
--- a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/SerializedNameValuePair.java
+++ b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/SerializedNameValuePair.java
@@ -15,6 +15,7 @@ package org.apache.juneau.rest.client;
import org.apache.http.*;
import org.apache.juneau.*;
import org.apache.juneau.httppart.*;
+import org.apache.juneau.oapi.*;
import org.apache.juneau.serializer.*;
import org.apache.juneau.urlencoding.*;
@@ -47,7 +48,7 @@ public final class SerializedNameValuePair implements NameValuePair {
* The schema object that defines the format of the output.
* <br>If <jk>null</jk>, defaults to the schema defined on the serializer.
* <br>If that's also <jk>null</jk>, defaults to {@link HttpPartSchema#DEFAULT}.
- * <br>Ignored if the part serializer is not a subclass of {@link OpenApiPartSerializer}.
+ * <br>Only used if serializer is schema-aware (e.g. {@link OpenApiSerializer}).
*/
public SerializedNameValuePair(String name, Object value, HttpPartSerializer serializer, HttpPartSchema schema) {
this.name = name;
@@ -64,7 +65,7 @@ public final class SerializedNameValuePair implements NameValuePair {
@Override /* NameValuePair */
public String getValue() {
try {
- return serializer.createSession(null).serialize(HttpPartType.FORMDATA, schema, value);
+ return serializer.createPartSession().serialize(HttpPartType.FORMDATA, schema, value);
} catch (SchemaValidationException e) {
throw new FormattedRuntimeException(e, "Validation error on request form-data parameter ''{0}''=''{1}''", name, value);
} catch (SerializeException e) {
diff --git a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/remote/RemoteMethodArg.java b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/remote/RemoteMethodArg.java
index 2cc95ea..d71d703 100644
--- a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/remote/RemoteMethodArg.java
+++ b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/remote/RemoteMethodArg.java
@@ -49,8 +49,6 @@ public final class RemoteMethodArg {
private static HttpPartSerializer createSerializer(HttpPartType partType, HttpPartSchema schema) {
if (schema == null)
return null;
- if (partType == BODY && ! schema.isUsePartSerializer())
- return null;
return newInstance(HttpPartSerializer.class, schema.getSerializer());
}
diff --git a/juneau-rest/juneau-rest-client/src/test/java/org/apache/juneau/rest/client/remote/BodyAnnotationTest.java b/juneau-rest/juneau-rest-client/src/test/java/org/apache/juneau/rest/client/remote/BodyAnnotationTest.java
index e659721..ff5dbe8 100644
--- a/juneau-rest/juneau-rest-client/src/test/java/org/apache/juneau/rest/client/remote/BodyAnnotationTest.java
+++ b/juneau-rest/juneau-rest-client/src/test/java/org/apache/juneau/rest/client/remote/BodyAnnotationTest.java
@@ -23,7 +23,10 @@ import org.apache.http.entity.*;
import org.apache.juneau.*;
import org.apache.juneau.http.annotation.*;
import org.apache.juneau.http.annotation.Header;
+import org.apache.juneau.internal.*;
import org.apache.juneau.json.*;
+import org.apache.juneau.marshall.*;
+import org.apache.juneau.oapi.*;
import org.apache.juneau.rest.annotation.*;
import org.apache.juneau.rest.client.*;
import org.apache.juneau.rest.mock.*;
@@ -109,9 +112,9 @@ public class BodyAnnotationTest {
}
@RestMethod
- public Object postA10(@Body Reader b, @Header("Content-Type") String ct) {
+ public String postA10(@Body Reader b, @Header("Content-Type") String ct) throws IOException {
assertEquals("application/x-www-form-urlencoded", ct);
- return b;
+ return IOUtils.read(b);
}
}
private static MockRest a = MockRest.create(A.class);
@@ -170,20 +173,20 @@ public class BodyAnnotationTest {
}
@Test
public void a07_Reader() throws Exception {
- Object o = a01.postA07(new StringReader("xxx"));
+ Object o = a01.postA07(new StringReader("'xxx'"));
assertObjectEquals("'xxx'", o);
assertClass(String.class, o);
}
@Test
public void a08_InputStream() throws Exception {
@SuppressWarnings("resource")
- Object o = a01.postA08(new StringInputStream("xxx"));
+ Object o = a01.postA08(new StringInputStream("'xxx'"));
assertObjectEquals("'xxx'", o);
assertClass(String.class, o);
}
@Test
public void a09_HttpEntity() throws Exception {
- Object o = a01.postA09(new StringEntity("xxx"));
+ Object o = a01.postA09(new StringEntity("'xxx'"));
assertObjectEquals("'xxx'", o);
assertClass(String.class, o);
}
@@ -198,46 +201,42 @@ public class BodyAnnotationTest {
// Basic tests - OpenAPI
//=================================================================================================================
- @RestResource(parsers=JsonParser.class)
+ @RestResource(serializers=OpenApiSerializer.class,parsers=OpenApiParser.class,defaultAccept="text/openapi")
public static class B {
@RestMethod
public Object postB01(@Body int b, @Header("Content-Type") String ct) {
- assertEquals("text/plain", ct);
+ assertEquals("text/openapi", ct);
return b;
}
@RestMethod
public Object postB02(@Body float b, @Header("Content-Type") String ct) {
- assertEquals("text/plain", ct);
+ assertEquals("text/openapi", ct);
return b;
}
@RestMethod
- @Response(schema=@Schema(type="object"))
- public Object postB03(@Body(schema=@Schema(type="object")) Bean b, @Header("Content-Type") String ct) {
- assertEquals("text/plain", ct);
- return b;
+ public String postB03(@Body Bean b, @Header("Content-Type") String ct) {
+ assertEquals("text/openapi", ct);
+ return SimpleJson.DEFAULT.toString(b);
}
@RestMethod
- @Response(schema=@Schema(type="array",items=@Items(type="object")))
- public Object postB04(@Body(schema=@Schema(type="array",items=@Items(type="object"))) Bean[] b, @Header("Content-Type") String ct) {
- assertEquals("text/plain", ct);
- return b;
+ public Object postB04(@Body Bean[] b, @Header("Content-Type") String ct) {
+ assertEquals("text/openapi", ct);
+ return SimpleJson.DEFAULT.toString(b);
}
@RestMethod
- @Response(schema=@Schema(type="array",items=@Items(type="object")))
- public Object postB05(@Body(schema=@Schema(type="array",items=@Items(type="object"))) List<Bean> b, @Header("Content-Type") String ct) {
- assertEquals("text/plain", ct);
- return b;
+ public Object postB05(@Body List<Bean> b, @Header("Content-Type") String ct) {
+ assertEquals("text/openapi", ct);
+ return SimpleJson.DEFAULT.toString(b);
}
@RestMethod
- @Response(schema=@Schema(type="object",format="uon"))
- public Object postB06(@Body(schema=@Schema(type="object",format="uon")) Map<String,Bean> b, @Header("Content-Type") String ct) {
- assertEquals("text/plain", ct);
- return b;
+ public Object postB06(@Body Map<String,Bean> b, @Header("Content-Type") String ct) {
+ assertEquals("text/openapi", ct);
+ return SimpleJson.DEFAULT.toString(b);
}
@RestMethod
@@ -270,17 +269,17 @@ public class BodyAnnotationTest {
public static interface B01 {
String postB01(@Body int b);
String postB02(@Body float b);
- String postB03(@Body(schema=@Schema(type="object")) Bean b);
- String postB04(@Body(schema=@Schema(type="array",items=@Items(type="object"))) Bean[] b);
- String postB05(@Body(schema=@Schema(type="array",items=@Items(type="object"))) List<Bean> b);
- String postB06(@Body(schema=@Schema(type="object",format="uon")) Map<String,Bean> b);
+ String postB03(@Body Bean b);
+ String postB04(@Body Bean[] b);
+ String postB05(@Body List<Bean> b);
+ String postB06(@Body Map<String,Bean> b);
String postB07(@Body Reader b);
String postB08(@Body InputStream b);
String postB09(@Body HttpEntity b);
String postB10(@Body NameValuePairs b);
}
- private static B01 b01 = RestClient.create().mockHttpConnection(b).build().getRemoteResource(B01.class);
+ private static B01 b01 = RestClient.create().openapi().mockHttpConnection(b).build().getRemoteResource(B01.class);
@Test
public void b01_int() throws Exception {
@@ -295,22 +294,22 @@ public class BodyAnnotationTest {
@Test
public void b03_Bean() throws Exception {
String o = b01.postB03(Bean.create());
- assertEquals("(f=1)", o);
+ assertEquals("{f:1}", o);
}
@Test
public void b04_BeanArray() throws Exception {
String o = b01.postB04(new Bean[]{Bean.create()});
- assertEquals("(f=1)", o);
+ assertEquals("[{f:1}]", o);
}
@Test
public void b05_ListOfBeans() throws Exception {
String o = b01.postB05(AList.create(Bean.create()));
- assertEquals("(f=1)", o);
+ assertEquals("[{f:1}]", o);
}
@Test
public void b06_MapOfBeans() throws Exception {
String o = b01.postB06(AMap.create("k1",Bean.create()));
- assertEquals("(k1=(f=1))", o);
+ assertEquals("{k1:{f:1}}", o);
}
@Test
public void b07_Reader() throws Exception {
@@ -397,10 +396,10 @@ public class BodyAnnotationTest {
public static interface C01 {
String postC01(@Body int b);
String postC02(@Body float b);
- String postC03(@Body(schema=@Schema(type="object")) Bean b);
- String postC04(@Body(schema=@Schema(type="array",items=@Items(type="object"))) Bean[] b);
- String postC05(@Body(schema=@Schema(type="array",items=@Items(type="object"))) List<Bean> b);
- String postC06(@Body(schema=@Schema(type="object",format="uon")) Map<String,Bean> b);
+ String postC03(@Body Bean b);
+ String postC04(@Body Bean[] b);
+ String postC05(@Body List<Bean> b);
+ String postC06(@Body Map<String,Bean> b);
String postC07(@Body Reader b);
String postC08(@Body InputStream b);
String postC09(@Body HttpEntity b);
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 bbe45e9..08146eb 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
@@ -20,6 +20,7 @@ import org.apache.http.*;
import org.apache.juneau.http.annotation.*;
import org.apache.juneau.internal.*;
import org.apache.juneau.json.*;
+import org.apache.juneau.oapi.*;
import org.apache.juneau.rest.annotation.*;
import org.apache.juneau.rest.client.*;
import org.apache.juneau.rest.mock.*;
@@ -176,12 +177,12 @@ public class RemoteMethodAnnotationTest {
// Return types, part serialization
//=================================================================================================================
- @RestResource(serializers=SimpleJsonSerializer.class, parsers=JsonParser.class)
+ @RestResource(serializers=OpenApiSerializer.class, parsers=OpenApiParser.class, defaultAccept="text/openapi")
public static class D {
@RestMethod(name="POST")
- @Response(usePartSerializer=true)
- public String d01(@Body(usePartParser=true) String body) {
+ @Response
+ public String d01(@Body String body) {
return body;
}
}
@@ -192,17 +193,17 @@ public class RemoteMethodAnnotationTest {
public static interface D01 {
@RemoteMethod(method="POST",path="d01")
- @Response(usePartParser=true)
- public String d01a(@Body(usePartSerializer=true) String foo);
+ @Response
+ public String d01a(@Body String foo);
@RemoteMethod(method="POST",path="d01")
- public HttpResponse d01b(@Body(usePartSerializer=true) String foo);
+ public HttpResponse d01b(@Body String foo);
@RemoteMethod(method="POST",path="d01")
- public Reader d01c(@Body(usePartSerializer=true) String foo);
+ public Reader d01c(@Body String foo);
@RemoteMethod(method="POST",path="d01")
- public InputStream d01d(@Body(usePartSerializer=true) String foo);
+ public InputStream d01d(@Body String foo);
}
@Test
diff --git a/juneau-rest/juneau-rest-server-jaxrs/src/main/java/org/apache/juneau/rest/jaxrs/BaseProvider.java b/juneau-rest/juneau-rest-server-jaxrs/src/main/java/org/apache/juneau/rest/jaxrs/BaseProvider.java
index ce52f5f..87182da 100644
--- a/juneau-rest/juneau-rest-server-jaxrs/src/main/java/org/apache/juneau/rest/jaxrs/BaseProvider.java
+++ b/juneau-rest/juneau-rest-server-jaxrs/src/main/java/org/apache/juneau/rest/jaxrs/BaseProvider.java
@@ -121,7 +121,7 @@ public class BaseProvider implements MessageBodyReader<Object>, MessageBodyWrite
Locale locale = getLocale(headers);
TimeZone timeZone = getTimeZone(headers);
- SerializerSession session = s.createSession(new SerializerSessionArgs(mp, null, locale, timeZone, sm.getMediaType(), null, null, null));
+ SerializerSession session = s.createSession(new SerializerSessionArgs(mp, null, locale, timeZone, sm.getMediaType(), null, null, null, null));
// Leave this open in case an error occurs.
Closeable c = s.isWriterSerializer() ? new OutputStreamWriter(os, UTF8) : os;
@@ -149,7 +149,7 @@ public class BaseProvider implements MessageBodyReader<Object>, MessageBodyWrite
mp.put("mediaType", mediaType.toString());
Locale locale = getLocale(headers);
TimeZone timeZone = getTimeZone(headers);
- ParserSession session = p.createSession(new ParserSessionArgs(mp, null, locale, timeZone, pm.getMediaType(), null, null));
+ ParserSession session = p.createSession(new ParserSessionArgs(mp, null, locale, timeZone, pm.getMediaType(), null, null, null));
Object in2 = session.isReaderParser() ? new InputStreamReader(in, UTF8) : in;
return session.parse(in2, p.getClassMeta(gType));
} catch (ParseException e) {
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/BasicRestConfig.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/BasicRestConfig.java
index b650528..6d874d7 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/BasicRestConfig.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/BasicRestConfig.java
@@ -17,6 +17,7 @@ import static org.apache.juneau.serializer.Serializer.*;
import org.apache.juneau.html.*;
import org.apache.juneau.json.*;
import org.apache.juneau.msgpack.*;
+import org.apache.juneau.oapi.*;
import org.apache.juneau.plaintext.*;
import org.apache.juneau.rest.annotation.*;
import org.apache.juneau.soap.*;
@@ -46,6 +47,7 @@ import org.apache.juneau.xmlschema.*;
XmlSchemaDocSerializer.class,
UonSerializer.class,
UrlEncodingSerializer.class,
+ OpenApiSerializer.class,
MsgPackSerializer.class,
SoapXmlSerializer.class,
PlainTextSerializer.class
@@ -59,6 +61,7 @@ import org.apache.juneau.xmlschema.*;
HtmlParser.class,
UonParser.class,
UrlEncodingParser.class,
+ OpenApiParser.class,
MsgPackParser.class,
PlainTextParser.class
},
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RequestBody.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RequestBody.java
index cfeecd4..c32f53d 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RequestBody.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RequestBody.java
@@ -14,7 +14,6 @@ package org.apache.juneau.rest;
import static org.apache.juneau.internal.IOUtils.*;
import static org.apache.juneau.internal.StringUtils.*;
-import static org.apache.juneau.httppart.HttpPartType.*;
import java.io.*;
import java.lang.reflect.*;
@@ -52,7 +51,7 @@ public class RequestBody {
private int contentLength = 0;
private MediaType mediaType;
private Parser parser;
- private HttpPartParser partParser;
+ private HttpPartSchema schema;
RequestBody(RestRequest req) {
this.req = req;
@@ -68,8 +67,8 @@ public class RequestBody {
return this;
}
- RequestBody partParser(HttpPartParser partParser) {
- this.partParser = partParser;
+ RequestBody schema(HttpPartSchema schema) {
+ this.schema = schema;
return this;
}
@@ -178,7 +177,7 @@ public class RequestBody {
* @throws InternalServerError Thrown if an {@link IOException} occurs.
*/
public <T> T asType(Class<T> type) throws BadRequest, UnsupportedMediaType, InternalServerError {
- return getInner(null, null, getClassMeta(type));
+ return getInner(getClassMeta(type));
}
/**
@@ -226,34 +225,7 @@ public class RequestBody {
* @throws InternalServerError Thrown if an {@link IOException} occurs.
*/
public <T> T asType(Type type, Type...args) throws BadRequest, UnsupportedMediaType, InternalServerError {
- return getInner(null, null, this.<T>getClassMeta(type, args));
- }
-
- /**
- * Same as {@link #asType(Type, Type...)} but allows you to specify a part parser and schema.
- *
- * @param partParser
- * The part-parser to use for parsing the body as a string value if none of the existing parsers match the media type.
- * <br>Can be <jk>null</jk>.
- * @param schema
- * The schema object that defines the format of the input.
- * <br>If <jk>null</jk>, defaults to the schema defined on the parser.
- * <br>If that's also <jk>null</jk>, defaults to {@link HttpPartSchema#DEFAULT}.
- * @param type
- * The type of object to create.
- * <br>Can be any of the following: {@link ClassMeta}, {@link Class}, {@link ParameterizedType}, {@link GenericArrayType}
- * @param args
- * The type arguments of the class if it's a collection or map.
- * <br>Can be any of the following: {@link ClassMeta}, {@link Class}, {@link ParameterizedType}, {@link GenericArrayType}
- * <br>Ignored if the main type is not a map or collection.
- * @param <T> The class type to instantiate.
- * @return The input parsed to a POJO.
- * @throws BadRequest Thrown if input could not be parsed or fails schema validation.
- * @throws UnsupportedMediaType Thrown if the Content-Type header value is not supported by one of the parsers.
- * @throws InternalServerError Thrown if an {@link IOException} occurs.
- */
- public <T> T asType(HttpPartParser partParser, HttpPartSchema schema, Type type, Type...args) throws BadRequest, UnsupportedMediaType, InternalServerError {
- return getInner(partParser, schema, this.<T>getClassMeta(type, args));
+ return getInner(this.<T>getClassMeta(type, args));
}
/**
@@ -426,9 +398,9 @@ public class RequestBody {
return null;
}
- private <T> T getInner(HttpPartParser partParser, HttpPartSchema schema, ClassMeta<T> cm) throws BadRequest, UnsupportedMediaType, InternalServerError {
+ private <T> T getInner(ClassMeta<T> cm) throws BadRequest, UnsupportedMediaType, InternalServerError {
try {
- return parse(partParser, schema, cm);
+ return parse(cm);
} catch (UnsupportedMediaType e) {
throw e;
} catch (SchemaValidationException e) {
@@ -443,7 +415,7 @@ public class RequestBody {
}
/* Workhorse method */
- private <T> T parse(HttpPartParser partParser, HttpPartSchema schema, ClassMeta<T> cm) throws SchemaValidationException, ParseException, UnsupportedMediaType, IOException {
+ private <T> T parse(ClassMeta<T> cm) throws SchemaValidationException, ParseException, UnsupportedMediaType, IOException {
if (cm.isReader())
return (T)getReader();
@@ -462,7 +434,8 @@ public class RequestBody {
Parser p = pm.getParser();
MediaType mediaType = pm.getMediaType();
req.getProperties().append("mediaType", mediaType).append("characterEncoding", req.getCharacterEncoding());
- ParserSession session = p.createSession(new ParserSessionArgs(req.getProperties(), req.getJavaMethod(), locale, timeZone, mediaType, req.isDebug() ? true : null, req.getContext().getResource()));
+ ParserSessionArgs pArgs = new ParserSessionArgs(req.getProperties(), req.getJavaMethod(), locale, timeZone, mediaType, schema, req.isDebug() ? true : null, req.getContext().getResource());
+ ParserSession session = p.createSession(pArgs);
try (Closeable in = session.isReaderParser() ? getUnbufferedReader() : getInputStream()) {
T o = session.parse(in, cm);
if (schema != null)
@@ -477,18 +450,10 @@ public class RequestBody {
if (cm.hasInputStreamTransform())
return cm.getInputStreamTransform().transform(getInputStream());
- if (partParser == null)
- partParser = this.partParser;
-
MediaType mt = getMediaType();
- if (isEmpty(mt) || mt.toString().startsWith("text/plain")) {
- if (partParser != null) {
- String in = asString();
- return partParser.createSession(req.getParserSessionArgs()).parse(BODY, schema, isEmpty(in) ? null : in, cm);
- }
- if (cm.hasStringTransform())
- return cm.getStringTransform().transform(asString());
- }
+
+ if ((isEmpty(mt) || mt.toString().startsWith("text/plain")) && cm.hasStringTransform())
+ return cm.getStringTransform().transform(asString());
throw new UnsupportedMediaType(
"Unsupported media-type in request header ''Content-Type'': ''{0}''\n\tSupported media-types: {1}",
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RequestFormData.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RequestFormData.java
index 82750d3..2e78c7b 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RequestFormData.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RequestFormData.java
@@ -25,6 +25,7 @@ import org.apache.juneau.http.annotation.*;
import org.apache.juneau.httppart.*;
import org.apache.juneau.internal.*;
import org.apache.juneau.json.*;
+import org.apache.juneau.oapi.*;
import org.apache.juneau.parser.*;
import org.apache.juneau.rest.exception.*;
@@ -256,7 +257,7 @@ public class RequestFormData extends LinkedHashMap<String,String[]> {
* The schema object that defines the format of the input.
* <br>If <jk>null</jk>, defaults to the schema defined on the parser.
* <br>If that's also <jk>null</jk>, defaults to {@link HttpPartSchema#DEFAULT}.
- * <br>Ignored if the part parser is not a subclass of {@link OpenApiPartParser}.
+ * <br>Only used if parser is schema-aware (e.g. {@link OpenApiParser}).
* @param name The parameter name.
* @param type The class type to convert the parameter value to.
* @param <T> The class type to convert the parameter value to.
@@ -293,7 +294,7 @@ public class RequestFormData extends LinkedHashMap<String,String[]> {
* The schema object that defines the format of the input.
* <br>If <jk>null</jk>, defaults to the schema defined on the parser.
* <br>If that's also <jk>null</jk>, defaults to {@link HttpPartSchema#DEFAULT}.
- * <br>Ignored if the part parser is not a subclass of {@link OpenApiPartParser}.
+ * <br>Only used if parser is schema-aware (e.g. {@link OpenApiParser}).
* @param name The parameter name.
* @param def The default value if the parameter was not specified or is <jk>null</jk>.
* @param type The class type to convert the parameter value to.
@@ -336,7 +337,7 @@ public class RequestFormData extends LinkedHashMap<String,String[]> {
* The schema object that defines the format of the input.
* <br>If <jk>null</jk>, defaults to the schema defined on the parser.
* <br>If that's also <jk>null</jk>, defaults to {@link HttpPartSchema#DEFAULT}.
- * <br>Ignored if the part parser is not a subclass of {@link OpenApiPartParser}.
+ * <br>Only used if parser is schema-aware (e.g. {@link OpenApiParser}).
* @param name The parameter name.
* @param type The class type to convert the parameter value to.
* @return The parameter value converted to the specified class type.
@@ -407,7 +408,7 @@ public class RequestFormData extends LinkedHashMap<String,String[]> {
* The schema object that defines the format of the input.
* <br>If <jk>null</jk>, defaults to the schema defined on the parser.
* <br>If that's also <jk>null</jk>, defaults to {@link HttpPartSchema#DEFAULT}.
- * <br>Ignored if the part parser is not a subclass of {@link OpenApiPartParser}.
+ * <br>Only used if parser is schema-aware (e.g. {@link OpenApiParser}).
* @param name The parameter name.
* @param type
* The type of object to create.
@@ -455,7 +456,7 @@ public class RequestFormData extends LinkedHashMap<String,String[]> {
* The schema object that defines the format of the input.
* <br>If <jk>null</jk>, defaults to the schema defined on the parser.
* <br>If that's also <jk>null</jk>, defaults to {@link HttpPartSchema#DEFAULT}.
- * <br>Ignored if the part parser is not a subclass of {@link OpenApiPartParser}.
+ * <br>Only used if parser is schema-aware (e.g. {@link OpenApiParser}).
* @param name The parameter name.
* @param type
* The type of object to create.
@@ -507,7 +508,7 @@ public class RequestFormData extends LinkedHashMap<String,String[]> {
* The schema object that defines the format of the input.
* <br>If <jk>null</jk>, defaults to the schema defined on the parser.
* <br>If that's also <jk>null</jk>, defaults to {@link HttpPartSchema#DEFAULT}.
- * <br>Ignored if the part parser is not a subclass of {@link OpenApiPartParser}.
+ * <br>Only used if parser is schema-aware (e.g. {@link OpenApiParser}).
* @param name The parameter name.
* @param type
* The type of object to create.
@@ -584,7 +585,7 @@ public class RequestFormData extends LinkedHashMap<String,String[]> {
private <T> T parse(HttpPartParser parser, HttpPartSchema schema, String val, ClassMeta<T> c) throws SchemaValidationException, ParseException {
if (parser == null)
parser = this.parser;
- return parser.createSession(req.getParserSessionArgs()).parse(HttpPartType.FORMDATA, schema, val, c);
+ return parser.createPartSession(req.getParserSessionArgs()).parse(HttpPartType.FORMDATA, schema, val, c);
}
/**
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RequestHeaders.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RequestHeaders.java
index f4bbb42..65fe729 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RequestHeaders.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RequestHeaders.java
@@ -24,6 +24,7 @@ import org.apache.juneau.http.Date;
import org.apache.juneau.httppart.*;
import org.apache.juneau.internal.*;
import org.apache.juneau.json.*;
+import org.apache.juneau.oapi.*;
import org.apache.juneau.parser.*;
import org.apache.juneau.rest.exception.*;
@@ -263,7 +264,7 @@ public class RequestHeaders extends TreeMap<String,String[]> {
* The schema object that defines the format of the input.
* <br>If <jk>null</jk>, defaults to the schema defined on the parser.
* <br>If that's also <jk>null</jk>, defaults to {@link HttpPartSchema#DEFAULT}.
- * <br>Ignored if the part parser is not a subclass of {@link OpenApiPartParser}.
+ * <br>Only used if parser is schema-aware (e.g. {@link OpenApiParser}).
* @param name The HTTP header name.
* @param type The class type to convert the header value to.
* @param <T> The class type to convert the header value to.
@@ -300,7 +301,7 @@ public class RequestHeaders extends TreeMap<String,String[]> {
* The schema object that defines the format of the input.
* <br>If <jk>null</jk>, defaults to the schema defined on the parser.
* <br>If that's also <jk>null</jk>, defaults to {@link HttpPartSchema#DEFAULT}.
- * <br>Ignored if the part parser is not a subclass of {@link OpenApiPartParser}.
+ * <br>Only used if parser is schema-aware (e.g. {@link OpenApiParser}).
* @param name The HTTP header name.
* @param def The default value if the header was not specified or is <jk>null</jk>.
* @param type The class type to convert the header value to.
@@ -367,7 +368,7 @@ public class RequestHeaders extends TreeMap<String,String[]> {
* The schema object that defines the format of the input.
* <br>If <jk>null</jk>, defaults to the schema defined on the parser.
* <br>If that's also <jk>null</jk>, defaults to {@link HttpPartSchema#DEFAULT}.
- * <br>Ignored if the part parser is not a subclass of {@link OpenApiPartParser}.
+ * <br>Only used if parser is schema-aware (e.g. {@link OpenApiParser}).
* @param name
* The HTTP header name.
* @param type
@@ -414,7 +415,7 @@ public class RequestHeaders extends TreeMap<String,String[]> {
private <T> T parse(HttpPartParser parser, HttpPartSchema schema, String val, ClassMeta<T> cm) throws SchemaValidationException, ParseException {
if (parser == null)
parser = this.parser;
- return parser.createSession(req.getParserSessionArgs()).parse(HttpPartType.HEADER, schema, val, cm);
+ return parser.createPartSession(req.getParserSessionArgs()).parse(HttpPartType.HEADER, schema, val, cm);
}
/**
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RequestPath.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RequestPath.java
index 500814a..c3ff2e3 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RequestPath.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RequestPath.java
@@ -19,6 +19,7 @@ import java.util.*;
import org.apache.juneau.*;
import org.apache.juneau.httppart.*;
+import org.apache.juneau.oapi.*;
import org.apache.juneau.parser.*;
import org.apache.juneau.rest.exception.*;
@@ -154,7 +155,7 @@ public class RequestPath extends TreeMap<String,String> {
* The schema object that defines the format of the input.
* <br>If <jk>null</jk>, defaults to the schema defined on the parser.
* <br>If that's also <jk>null</jk>, defaults to {@link HttpPartSchema#DEFAULT}.
- * <br>Ignored if the part parser is not a subclass of {@link OpenApiPartParser}.
+ * <br>Only used if parser is schema-aware (e.g. {@link OpenApiParser}).
* @param name The attribute name.
* @param type The class type to convert the attribute value to.
* @param <T> The class type to convert the attribute value to.
@@ -230,7 +231,7 @@ public class RequestPath extends TreeMap<String,String> {
* The schema object that defines the format of the input.
* <br>If <jk>null</jk>, defaults to the schema defined on the parser.
* <br>If that's also <jk>null</jk>, defaults to {@link HttpPartSchema#DEFAULT}.
- * <br>Ignored if the part parser is not a subclass of {@link OpenApiPartParser}.
+ * <br>Only used if parser is schema-aware (e.g. {@link OpenApiParser}).
* @param name The attribute name.
* @param type
* The type of object to create.
@@ -276,7 +277,7 @@ public class RequestPath extends TreeMap<String,String> {
private <T> T parse(HttpPartParser parser, HttpPartSchema schema, String val, ClassMeta<T> cm) throws SchemaValidationException, ParseException {
if (parser == null)
parser = this.parser;
- return parser.createSession(req.getParserSessionArgs()).parse(HttpPartType.PATH, schema, val, cm);
+ return parser.createPartSession(req.getParserSessionArgs()).parse(HttpPartType.PATH, schema, val, cm);
}
/**
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RequestQuery.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RequestQuery.java
index a59ddb9..c28f540 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RequestQuery.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RequestQuery.java
@@ -24,6 +24,7 @@ import org.apache.juneau.*;
import org.apache.juneau.httppart.*;
import org.apache.juneau.internal.*;
import org.apache.juneau.json.*;
+import org.apache.juneau.oapi.*;
import org.apache.juneau.parser.*;
import org.apache.juneau.rest.exception.*;
import org.apache.juneau.utils.*;
@@ -259,7 +260,7 @@ public final class RequestQuery extends LinkedHashMap<String,String[]> {
* The schema object that defines the format of the input.
* <br>If <jk>null</jk>, defaults to the schema defined on the parser.
* <br>If that's also <jk>null</jk>, defaults to {@link HttpPartSchema#DEFAULT}.
- * <br>Ignored if the part parser is not a subclass of {@link OpenApiPartParser}.
+ * <br>Only used if parser is schema-aware (e.g. {@link OpenApiParser}).
* @param name The parameter name.
* @param type The class type to convert the parameter value to.
* @param <T> The class type to convert the parameter value to.
@@ -296,7 +297,7 @@ public final class RequestQuery extends LinkedHashMap<String,String[]> {
* The schema object that defines the format of the input.
* <br>If <jk>null</jk>, defaults to the schema defined on the parser.
* <br>If that's also <jk>null</jk>, defaults to {@link HttpPartSchema#DEFAULT}.
- * <br>Ignored if the part parser is not a subclass of {@link OpenApiPartParser}.
+ * <br>Only used if parser is schema-aware (e.g. {@link OpenApiParser}).
* @param name The parameter name.
* @param def The default value if the parameter was not specified or is <jk>null</jk>.
* @param type The class type to convert the parameter value to.
@@ -370,7 +371,7 @@ public final class RequestQuery extends LinkedHashMap<String,String[]> {
* The schema object that defines the format of the input.
* <br>If <jk>null</jk>, defaults to the schema defined on the parser.
* <br>If that's also <jk>null</jk>, defaults to {@link HttpPartSchema#DEFAULT}.
- * <br>Ignored if the part parser is not a subclass of {@link OpenApiPartParser}.
+ * <br>Only used if parser is schema-aware (e.g. {@link OpenApiParser}).
* @param name The parameter name.
* @param type
* The type of object to create.
@@ -419,7 +420,7 @@ public final class RequestQuery extends LinkedHashMap<String,String[]> {
* The schema object that defines the format of the input.
* <br>If <jk>null</jk>, defaults to the schema defined on the parser.
* <br>If that's also <jk>null</jk>, defaults to {@link HttpPartSchema#DEFAULT}.
- * <br>Ignored if the part parser is not a subclass of {@link OpenApiPartParser}.
+ * <br>Only used if parser is schema-aware (e.g. {@link OpenApiParser}).
* @param name The parameter name.
* @param type
* The type of object to create.
@@ -490,7 +491,7 @@ public final class RequestQuery extends LinkedHashMap<String,String[]> {
* The schema object that defines the format of the input.
* <br>If <jk>null</jk>, defaults to the schema defined on the parser.
* <br>If that's also <jk>null</jk>, defaults to {@link HttpPartSchema#DEFAULT}.
- * <br>Ignored if the part parser is not a subclass of {@link OpenApiPartParser}.
+ * <br>Only used if parser is schema-aware (e.g. {@link OpenApiParser}).
* @param name The query parameter name.
* @param type
* The type of object to create.
@@ -646,7 +647,7 @@ public final class RequestQuery extends LinkedHashMap<String,String[]> {
private <T> T parse(HttpPartParser parser, HttpPartSchema schema, String val, ClassMeta<T> c) throws SchemaValidationException, ParseException {
if (parser == null)
parser = this.parser;
- return parser.createSession(req.getParserSessionArgs()).parse(HttpPartType.QUERY, schema, val, c);
+ return parser.createPartSession(req.getParserSessionArgs()).parse(HttpPartType.QUERY, schema, val, c);
}
/**
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestContext.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestContext.java
index 4971679..ac65c08 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestContext.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestContext.java
@@ -43,6 +43,7 @@ import org.apache.juneau.internal.*;
import org.apache.juneau.json.*;
import org.apache.juneau.jsonschema.*;
import org.apache.juneau.msgpack.*;
+import org.apache.juneau.oapi.*;
import org.apache.juneau.parser.*;
import org.apache.juneau.plaintext.*;
import org.apache.juneau.remote.*;
@@ -1703,7 +1704,7 @@ public final class RestContext extends BeanContext {
* <ul>
* <li><b>Name:</b> <js>"RestContext.partParser.o"</js>
* <li><b>Data type:</b> <code>{@link HttpPartParser} | Class<? <jk>extends</jk> {@link HttpPartParser}></code>
- * <li><b>Default:</b> {@link OpenApiPartSerializer}
+ * <li><b>Default:</b> {@link OpenApiParser}
* <li><b>Session property:</b> <jk>false</jk>
* <li><b>Annotations:</b>
* <ul>
@@ -1721,7 +1722,7 @@ public final class RestContext extends BeanContext {
* Specifies the {@link HttpPartParser} to use for parsing headers, query/form parameters, and URI parts.
*
* <p>
- * The default value is {@link OpenApiPartParser} which allows for both plain-text and URL-Encoded-Object-Notation values.
+ * The default value is {@link OpenApiParser} which allows for both plain-text and URL-Encoded-Object-Notation values.
* <br>If your parts contain text that can be confused with UON (e.g. <js>"(foo)"</js>), you can switch to
* {@link SimplePartParser} which treats everything as plain text.
*
@@ -1771,7 +1772,7 @@ public final class RestContext extends BeanContext {
* <ul>
* <li><b>Name:</b> <js>"RestContext.partSerializer.o"</js>
* <li><b>Data type:</b> <code>{@link HttpPartSerializer} | Class<? <jk>extends</jk> {@link HttpPartSerializer}></code>
- * <li><b>Default:</b> {@link OpenApiPartSerializer}
+ * <li><b>Default:</b> {@link OpenApiSerializer}
* <li><b>Session property:</b> <jk>false</jk>
* <li><b>Annotations:</b>
* <ul>
@@ -1789,14 +1790,12 @@ public final class RestContext extends BeanContext {
* Specifies the {@link HttpPartSerializer} to use for serializing headers, query/form parameters, and URI parts.
*
* <p>
- * The default value is {@link OpenApiPartSerializer} which serializes based on OpenAPI rules, but defaults to UON notation for beans and maps, and
+ * The default value is {@link OpenApiSerializer} which serializes based on OpenAPI rules, but defaults to UON notation for beans and maps, and
* plain text for everything else.
* <br>Other options include:
* <ul>
* <li class='jc'>{@link SimplePartSerializer} - Always serializes to plain text.
- * <li class='jc'>{@link UonPartSerializer} - Always serializers to UON.
- * <li class='jc'>{@link SimpleUonPartSerializer} - Serializes to UON notation for beans and maps, and
- * plain text for everything else..
+ * <li class='jc'>{@link UonSerializer} - Always serializers to UON.
* </ul>
*
* <h5 class='section'>Example:</h5>
@@ -3151,8 +3150,8 @@ public final class RestContext extends BeanContext {
properties = builder.properties;
serializers = SerializerGroup.create().append(getInstanceArrayProperty(REST_serializers, Serializer.class, new Serializer[0], true, resource, ps)).build();
parsers = ParserGroup.create().append(getInstanceArrayProperty(REST_parsers, Parser.class, new Parser[0], true, resource, ps)).build();
- partSerializer = getInstanceProperty(REST_partSerializer, HttpPartSerializer.class, OpenApiPartSerializer.class, true, resource, ps);
- partParser = getInstanceProperty(REST_partParser, HttpPartParser.class, OpenApiPartParser.class, true, resource, ps);
+ partSerializer = getInstanceProperty(REST_partSerializer, HttpPartSerializer.class, OpenApiSerializer.class, true, resource, ps);
+ partParser = getInstanceProperty(REST_partParser, HttpPartParser.class, OpenApiParser.class, true, resource, ps);
jsonSchemaGenerator = new JsonSchemaGenerator(ps);
encoders = new EncoderGroupBuilder().append(getInstanceArrayProperty(REST_encoders, Encoder.class, new Encoder[0], true, resource, ps)).build();
beanContext = BeanContext.create().apply(ps).build();
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestContextBuilder.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestContextBuilder.java
index 2ce590b..1adaafe 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestContextBuilder.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestContextBuilder.java
@@ -34,6 +34,7 @@ import org.apache.juneau.encoders.*;
import org.apache.juneau.http.*;
import org.apache.juneau.httppart.*;
import org.apache.juneau.internal.*;
+import org.apache.juneau.oapi.*;
import org.apache.juneau.parser.*;
import org.apache.juneau.rest.annotation.*;
import org.apache.juneau.rest.reshandlers.*;
@@ -118,8 +119,8 @@ public class RestContextBuilder extends BeanContextBuilder implements ServletCon
// Default values.
logger(BasicRestLogger.class);
- partSerializer(OpenApiPartSerializer.class);
- partParser(OpenApiPartParser.class);
+ partSerializer(OpenApiSerializer.class);
+ partParser(OpenApiParser.class);
staticFileResponseHeader("Cache-Control", "max-age=86400, public");
encoders(IdentityEncoder.INSTANCE);
@@ -180,6 +181,8 @@ public class RestContextBuilder extends BeanContextBuilder implements ServletCon
if (r.consumes().length > 0)
consumes(false, resolveVars(vr, r.consumes()));
defaultRequestHeaders(resolveVars(vr, r.defaultRequestHeaders()));
+ defaultAccept(vr.resolve(r.defaultAccept()));
+ defaultContentType(vr.resolve(r.defaultContentType()));
defaultResponseHeaders(resolveVars(vr, r.defaultResponseHeaders()));
responseHandlers(r.responseHandlers());
converters(r.converters());
@@ -837,6 +840,34 @@ public class RestContextBuilder extends BeanContextBuilder implements ServletCon
}
/**
+ * Specifies a default <code>Accept</code> header value if not specified on a request.
+ *
+ * @param value
+ * The default value of the <code>Accept</code> header.
+ * <br>Ignored if <jk>null</jk> or empty.
+ * @return This object (for method chaining).
+ */
+ public RestContextBuilder defaultAccept(String value) {
+ if (isNotEmpty(value))
+ defaultRequestHeader("Accept", value);
+ return this;
+ }
+
+ /**
+ * Specifies a default <code>Content-Type</code> header value if not specified on a request.
+ *
+ * @param value
+ * The default value of the <code>Content-Type</code> header.
+ * <br>Ignored if <jk>null</jk> or empty.
+ * @return This object (for method chaining).
+ */
+ public RestContextBuilder defaultContentType(String value) {
+ if (isNotEmpty(value))
+ defaultRequestHeader("Content-Type", value);
+ return this;
+ }
+
+ /**
* Configuration property: Default request headers.
*
* <p>
@@ -1282,7 +1313,7 @@ public class RestContextBuilder extends BeanContextBuilder implements ServletCon
*
* @param value
* The new value for this setting.
- * <br>The default is {@link OpenApiPartParser}.
+ * <br>The default is {@link OpenApiParser}.
* @return This object (for method chaining).
*/
public RestContextBuilder partParser(Class<? extends HttpPartParser> value) {
@@ -1304,7 +1335,7 @@ public class RestContextBuilder extends BeanContextBuilder implements ServletCon
*
* @param value
* The new value for this setting.
- * <br>The default is {@link OpenApiPartParser}.
+ * <br>The default is {@link OpenApiParser}.
* @return This object (for method chaining).
*/
public RestContextBuilder partParser(HttpPartParser value) {
@@ -1324,7 +1355,7 @@ public class RestContextBuilder extends BeanContextBuilder implements ServletCon
*
* @param value
* The new value for this setting.
- * <br>The default is {@link OpenApiPartSerializer}.
+ * <br>The default is {@link OpenApiSerializer}.
* @return This object (for method chaining).
*/
public RestContextBuilder partSerializer(Class<? extends HttpPartSerializer> value) {
@@ -1346,7 +1377,7 @@ public class RestContextBuilder extends BeanContextBuilder implements ServletCon
*
* @param value
* The new value for this setting.
- * <br>The default is {@link OpenApiPartSerializer}.
+ * <br>The default is {@link OpenApiSerializer}.
* @return This object (for method chaining).
*/
public RestContextBuilder partSerializer(HttpPartSerializer value) {
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestJavaMethod.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestJavaMethod.java
index dc9f0e1..034dd05 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestJavaMethod.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestJavaMethod.java
@@ -328,6 +328,14 @@ public class RestJavaMethod implements Comparable<RestJavaMethod> {
defaultRequestHeaders.put(h[0], h[1]);
}
+ String defaultAccept = vr.resolve(m.defaultAccept());
+ if (isNotEmpty(defaultAccept))
+ defaultRequestHeaders.put("Accept", defaultAccept);
+
+ String defaultContentType = vr.resolve(m.defaultContentType());
+ if (isNotEmpty(defaultContentType))
+ defaultRequestHeaders.put("Content-Type", defaultAccept);
+
defaultQuery = new LinkedHashMap<>();
for (String s : m.defaultQuery()) {
String[] h = RestUtils.parseKeyValuePair(vr.resolve(s));
@@ -449,7 +457,7 @@ public class RestJavaMethod implements Comparable<RestJavaMethod> {
ResponseBody a = c.getAnnotation(ResponseBody.class);
if (a != null) {
HttpPartSchema schema = HttpPartSchema.create(a);
- HttpPartSerializer serializer = schema.isUsePartSerializer() ? createPartSerializer(schema.getSerializer(), serializers.getPropertyStore(), partSerializer) : null;
+ HttpPartSerializer serializer = createPartSerializer(schema.getSerializer(), serializers.getPropertyStore(), partSerializer);
pm = new ResponsePartMeta(BODY, schema, serializer);
}
if (pm == null)
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestParamDefaults.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestParamDefaults.java
index 9cb623f..a0d4fc2 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestParamDefaults.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestParamDefaults.java
@@ -210,18 +210,16 @@ class RestParamDefaults {
}
static final class BodyObject extends RestMethodParam {
- private final HttpPartParser partParser;
private final HttpPartSchema schema;
protected BodyObject(Method m, int i, PropertyStore ps) {
super(BODY, m, i);
this.schema = HttpPartSchema.create(Body.class, m, i);
- this.partParser = schema.isUsePartParser() ? createPartParser(schema.getParser(), ps) : null;
}
@Override /* RestMethodParam */
public Object resolve(RestRequest req, RestResponse res) throws Exception {
- return req.getBody().asType(partParser, schema, type);
+ return req.getBody().schema(schema).asType(type);
}
}
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestRequest.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestRequest.java
index 90ee60a..1e582c4 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestRequest.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestRequest.java
@@ -40,6 +40,7 @@ import org.apache.juneau.http.annotation.*;
import org.apache.juneau.httppart.*;
import org.apache.juneau.httppart.bean.*;
import org.apache.juneau.internal.*;
+import org.apache.juneau.oapi.*;
import org.apache.juneau.parser.*;
import org.apache.juneau.remote.*;
import org.apache.juneau.rest.annotation.*;
@@ -181,7 +182,6 @@ public final class RestRequest extends HttpServletRequestWrapper {
this.body
.encoders(rjm.encoders)
.parsers(rjm.parsers)
- .partParser(rjm.partParser)
.headers(headers)
.maxInput(rjm.maxInput);
@@ -563,7 +563,7 @@ public final class RestRequest extends HttpServletRequestWrapper {
public RequestFormData getFormData() throws InternalServerError {
try {
if (formData == null) {
- formData = new RequestFormData(this, restJavaMethod == null ? OpenApiPartParser.DEFAULT : restJavaMethod.partParser);
+ formData = new RequestFormData(this, restJavaMethod == null ? OpenApiParser.DEFAULT : restJavaMethod.partParser);
if (! body.isLoaded()) {
formData.putAll(getParameterMap());
} else {
@@ -1095,7 +1095,7 @@ public final class RestRequest extends HttpServletRequestWrapper {
* @return The part serializer associated with this request.
*/
public HttpPartParser getPartParser() {
- return restJavaMethod == null ? OpenApiPartParser.DEFAULT : restJavaMethod.partParser;
+ return restJavaMethod == null ? OpenApiParser.DEFAULT : restJavaMethod.partParser;
}
/**
@@ -1104,7 +1104,7 @@ public final class RestRequest extends HttpServletRequestWrapper {
* @return The part serializer associated with this request.
*/
public HttpPartSerializer getPartSerializer() {
- return restJavaMethod == null ? OpenApiPartSerializer.DEFAULT : restJavaMethod.partSerializer;
+ return restJavaMethod == null ? OpenApiSerializer.DEFAULT : restJavaMethod.partSerializer;
}
/**
@@ -1493,7 +1493,7 @@ public final class RestRequest extends HttpServletRequestWrapper {
ClassMeta<?> type = getContext().getBeanContext().getClassMeta(method.getGenericReturnType());
HttpPartType pt = pm.getPartType();
if (pt == HttpPartType.BODY)
- return getBody().asType(pm.getParser(null), schema, type);
+ return getBody().schema(schema).asType(type);
if (pt == QUERY)
return getQuery().get(pp, schema, name, type);
if (pt == FORMDATA)
@@ -1547,7 +1547,7 @@ public final class RestRequest extends HttpServletRequestWrapper {
*/
public SerializerSessionArgs getSerializerSessionArgs() {
if (serializerSessionArgs == null)
- serializerSessionArgs = new SerializerSessionArgs(getProperties(), getJavaMethod(), getLocale(), getHeaders().getTimeZone(), null, isDebug() ? true : null, getUriContext(), isPlainText() ? true : null);
+ serializerSessionArgs = new SerializerSessionArgs(getProperties(), getJavaMethod(), getLocale(), getHeaders().getTimeZone(), null, null, isDebug() ? true : null, getUriContext(), isPlainText() ? true : null);
return serializerSessionArgs;
}
@@ -1558,7 +1558,7 @@ public final class RestRequest extends HttpServletRequestWrapper {
*/
public ParserSessionArgs getParserSessionArgs() {
if (parserSessionArgs == null)
- parserSessionArgs = new ParserSessionArgs(getProperties(), getJavaMethod(), getLocale(), getHeaders().getTimeZone(), null, isDebug() ? true : null, getUriContext());
+ parserSessionArgs = new ParserSessionArgs(getProperties(), getJavaMethod(), getLocale(), getHeaders().getTimeZone(), null, null, isDebug() ? true : null, getUriContext());
return parserSessionArgs;
}
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestResponse.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestResponse.java
index 0c2780f..5a80b98 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestResponse.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestResponse.java
@@ -83,7 +83,7 @@ public final class RestResponse extends HttpServletResponseWrapper {
String passThroughHeaders = req.getHeader("x-response-headers");
if (passThroughHeaders != null) {
HttpPartParser p = context.getPartParser();
- ObjectMap m = p.createSession(req.getParserSessionArgs()).parse(HttpPartType.HEADER, null, passThroughHeaders, context.getBeanContext().getClassMeta(ObjectMap.class));
+ ObjectMap m = p.createPartSession(req.getParserSessionArgs()).parse(HttpPartType.HEADER, null, passThroughHeaders, context.getBeanContext().getClassMeta(ObjectMap.class));
for (Map.Entry<String,Object> e : m.entrySet())
setHeader(e.getKey(), e.getValue().toString());
}
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/SwaggerGenerator.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/SwaggerGenerator.java
index 9ed95b3..e70f4e4 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/SwaggerGenerator.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/SwaggerGenerator.java
@@ -385,20 +385,16 @@ final class SwaggerGenerator {
}
if (hasAnnotation(Response.class, m)) {
- boolean usePS = false;
for (Response a : getAnnotationsParentFirst(Response.class, m)) {
for (Integer code : getCodes(a, 200)) {
ObjectMap om = responses.getObjectMap(String.valueOf(code), true);
merge(om, a);
- usePS |= usePartSerializer(a);
}
}
- if (usePS) {
- for (String code : responses.keySet()) {
- ObjectMap om = responses.getObjectMap(code);
- if (! om.containsKey("schema"))
- om.appendSkipEmpty("schema", getSchema(om.getObjectMap("schema", true), m.getGenericReturnType()));
- }
+ for (String code : responses.keySet()) {
+ ObjectMap om = responses.getObjectMap(code);
+ if (! om.containsKey("schema"))
+ om.appendSkipEmpty("schema", getSchema(om.getObjectMap("schema", true), m.getGenericReturnType()));
}
}
@@ -416,22 +412,18 @@ final class SwaggerGenerator {
}
} else if (in == RESPONSE) {
- boolean usePS = false;
for (Response a : getAnnotationsParentFirst(Response.class, mp.method, mp.index)) {
for (Integer code : getCodes(a, 200)) {
ObjectMap response = responses.getObjectMap(String.valueOf(code), true);
merge(response, a);
- usePS |= usePartSerializer(a);
}
}
- if (usePS) {
- Type type = Value.getParameterType(mp.type);
- if (type != null) {
- for (String code : responses.keySet()) {
- ObjectMap om = responses.getObjectMap(code);
- if (! om.containsKey("schema"))
- om.appendSkipEmpty("schema", getSchema(om.getObjectMap("schema", true), type));
- }
+ Type type = Value.getParameterType(mp.type);
+ if (type != null) {
+ for (String code : responses.keySet()) {
+ ObjectMap om = responses.getObjectMap(code);
+ if (! om.containsKey("schema"))
+ om.appendSkipEmpty("schema", getSchema(om.getObjectMap("schema", true), type));
}
}
}
@@ -768,7 +760,7 @@ final class SwaggerGenerator {
if (mt != MediaType.HTML) {
Serializer s2 = sm.getSerializers().getSerializer(mt);
if (s2 != null) {
- SerializerSessionArgs args = new SerializerSessionArgs(null, req.getJavaMethod(), req.getLocale(), null, mt, req.isDebug() ? true : null, req.getUriContext(), true);
+ SerializerSessionArgs args = new SerializerSessionArgs(null, req.getJavaMethod(), req.getLocale(), null, mt, null, req.isDebug() ? true : null, req.getUriContext(), true);
try {
String eVal = s2.createSession(args).serializeToString(example);
examples.put(s2.getPrimaryMediaType().toString(), eVal);
@@ -780,7 +772,7 @@ final class SwaggerGenerator {
}
} else {
String paramName = piri.getString("name");
- String s = sm.partSerializer.createSession(req.getSerializerSessionArgs()).serialize(HttpPartType.valueOf(in.toUpperCase()), null, example);
+ String s = sm.partSerializer.createPartSession(req.getSerializerSessionArgs()).serialize(HttpPartType.valueOf(in.toUpperCase()), null, example);
if ("query".equals(in))
s = "?" + urlEncodeLax(paramName) + "=" + urlEncodeLax(s);
else if ("formData".equals(in))
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestMethod.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestMethod.java
index 433135c..cc26bc9 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestMethod.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestMethod.java
@@ -246,6 +246,17 @@ public @interface RestMethod {
Class<? extends RestConverter>[] converters() default {};
/**
+ * Default <code>Accept</code> header.
+ *
+ * <p>
+ * The default value for the <code>Accept</code> header if not specified on a request.
+ *
+ * <p>
+ * This is a shortcut for using {@link #defaultRequestHeaders()} for just this specific header.
+ */
+ String defaultAccept() default "";
+
+ /**
* Default character encoding.
*
* <p>
@@ -266,6 +277,17 @@ public @interface RestMethod {
String defaultCharset() default "";
/**
+ * Default <code>Content-Type</code> header.
+ *
+ * <p>
+ * The default value for the <code>Content-Type</code> header if not specified on a request.
+ *
+ * <p>
+ * This is a shortcut for using {@link #defaultRequestHeaders()} for just this specific header.
+ */
+ String defaultContentType() default "";
+
+ /**
* Specifies default values for form-data parameters.
*
* <p>
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestResource.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestResource.java
index a19fa2b..bd6a5d3 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestResource.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestResource.java
@@ -235,6 +235,24 @@ public @interface RestResource {
Class<? extends RestConverter>[] converters() default {};
/**
+ * Default <code>Accept</code> header.
+ *
+ * <p>
+ * The default value for the <code>Accept</code> header if not specified on a request.
+ *
+ * <p>
+ * This is a shortcut for using {@link #defaultRequestHeaders()} for just this specific header.
+ *
+ * <h5 class='section'>Notes:</h5>
+ * <ul class='spaced-list'>
+ * <li>
+ * Supports {@doc DefaultRestSvlVariables}
+ * (e.g. <js>"$L{my.localized.variable}"</js>).
+ * </ul>
+ */
+ String defaultAccept() default "";
+
+ /**
* Default character encoding.
*
* <p>
@@ -255,6 +273,24 @@ public @interface RestResource {
String defaultCharset() default "";
/**
+ * Default <code>Content-Type</code> header.
+ *
+ * <p>
+ * The default value for the <code>Content-Type</code> header if not specified on a request.
+ *
+ * <p>
+ * This is a shortcut for using {@link #defaultRequestHeaders()} for just this specific header.
+ *
+ * <h5 class='section'>Notes:</h5>
+ * <ul class='spaced-list'>
+ * <li>
+ * Supports {@doc DefaultRestSvlVariables}
+ * (e.g. <js>"$L{my.localized.variable}"</js>).
+ * </ul>
+ */
+ String defaultContentType() default "";
+
+ /**
* Default request headers.
*
* <p>
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/reshandlers/DefaultHandler.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/reshandlers/DefaultHandler.java
index d5fb9c3..1a39f9f 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/reshandlers/DefaultHandler.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/reshandlers/DefaultHandler.java
@@ -20,7 +20,6 @@ import java.io.*;
import java.lang.reflect.*;
import java.util.*;
-import org.apache.juneau.*;
import org.apache.juneau.http.*;
import org.apache.juneau.httppart.*;
import org.apache.juneau.httppart.bean.*;
@@ -56,6 +55,7 @@ public class DefaultHandler implements ResponseHandler {
SerializerGroup g = res.getSerializers();
String accept = req.getHeaders().getString("Accept", "");
SerializerMatch sm = g.getSerializerMatch(accept);
+ HttpPartSchema schema = null;
Object o = res.getOutput();
@@ -97,8 +97,6 @@ public class DefaultHandler implements ResponseHandler {
}
ResponseBeanPropertyMeta bm = rm.getBodyMethod();
- boolean usePartSerializer = rm.isUsePartSerializer();
- HttpPartSchema schema = rm.getSchema();
if (bm != null) {
Method m = bm.getGetter();
@@ -113,28 +111,12 @@ public class DefaultHandler implements ResponseHandler {
return true;
}
o = m.invoke(o);
- schema = rm.getSchema();
- usePartSerializer |= schema.isUsePartSerializer();
} catch (Exception e) {
throw new InternalServerError(e, "Could not get body.");
}
}
- if (usePartSerializer) {
- if (res.getContentType() == null)
- res.setContentType("text/plain");
- HttpPartSerializer ps = firstNonNull(rm.getPartSerializer(), req.getPartSerializer());
- if (ps != null) {
- try (FinishablePrintWriter w = res.getNegotiatedWriter()) {
- w.append(ps.serialize(BODY, schema, o));
- w.flush();
- w.finish();
- } catch (SchemaValidationException | SerializeException e) {
- throw new InternalServerError(e);
- }
- return true;
- }
- }
+ schema = rm.getSchema();
}
if (sm != null) {
@@ -151,12 +133,11 @@ public class DefaultHandler implements ResponseHandler {
try {
RequestProperties p = res.getProperties();
- if (req.isPlainText()) {
+ if (req.isPlainText())
res.setContentType("text/plain");
- }
p.append("mediaType", mediaType).append("characterEncoding", res.getCharacterEncoding());
- SerializerSession session = s.createSession(new SerializerSessionArgs(p, req.getJavaMethod(), req.getLocale(), req.getHeaders().getTimeZone(), mediaType, req.isDebug() ? true : null, req.getUriContext(), req.isPlainText() ? true : null));
+ SerializerSession session = s.createSession(new SerializerSessionArgs(p, req.getJavaMethod(), req.getLocale(), req.getHeaders().getTimeZone(), mediaType, schema, req.isDebug() ? true : null, req.getUriContext(), req.isPlainText() ? true : null));
for (Map.Entry<String,String> h : session.getResponseHeaders().entrySet())
res.setHeader(h.getKey(), h.getValue());
@@ -185,15 +166,16 @@ public class DefaultHandler implements ResponseHandler {
throw new InternalServerError(e);
}
return true;
-
}
// Non-existent Accept or plain/text can just be serialized as-is.
- if (isEmpty(accept) || accept.startsWith("text/plain")) {
+ if (o != null && (isEmpty(accept) || accept.startsWith("text/plain"))) {
+ String out = null;
+ if (isEmpty(res.getContentType()))
+ res.setContentType("text/plain");
+ out = req.getBeanSession().getClassMetaForObject(o).toString(o);
FinishablePrintWriter w = res.getNegotiatedWriter();
- ClassMeta<?> cm = req.getBeanSession().getClassMetaForObject(o);
- if (cm != null)
- w.append(cm.toString(o));
+ w.append(out);
w.flush();
w.finish();
return true;
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/widget/MenuItemWidget.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/widget/MenuItemWidget.java
index 8699662..bc8ccc6 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/widget/MenuItemWidget.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/widget/MenuItemWidget.java
@@ -184,7 +184,7 @@ public abstract class MenuItemWidget extends Widget {
} else if (o instanceof CharSequence) {
sb.append((CharSequence)o);
} else {
- SerializerSessionArgs args = new SerializerSessionArgs(req.getProperties(), null, req.getLocale(), null, null, req.isDebug() ? true : null, req.getUriContext(), req.isPlainText() ? true : null);
+ SerializerSessionArgs args = new SerializerSessionArgs(req.getProperties(), null, req.getLocale(), null, null, null, req.isDebug() ? true : null, req.getUriContext(), req.isPlainText() ? true : null);
WriterSerializerSession session = HtmlSerializer.DEFAULT.createSession(args);
session.indent = 2;
session.serialize(o, sb);
diff --git a/juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/BasicRestInfoProviderTest.java b/juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/BasicRestInfoProviderTest.java
index 4c63c67..2d005aa 100644
--- a/juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/BasicRestInfoProviderTest.java
+++ b/juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/BasicRestInfoProviderTest.java
@@ -2196,7 +2196,7 @@ public class BasicRestInfoProviderTest {
@RestMethod(name=GET,path="/path/{foo}/responses/100")
public OE01x doFoo() {return null;}
}
- @Response(code=100,usePartSerializer=true)
+ @Response(code=100)
public static class OE01x extends Foo {}
@Test
diff --git a/juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/annotation/BodyAnnotationTest.java b/juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/annotation/BodyAnnotationTest.java
index dfc7dd7..63d9d8e 100644
--- a/juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/annotation/BodyAnnotationTest.java
+++ b/juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/annotation/BodyAnnotationTest.java
@@ -42,7 +42,7 @@ public class BodyAnnotationTest {
// @Body on parameter
//=================================================================================================================
- @RestResource(serializers=SimpleJsonSerializer.class, parsers=JsonParser.class)
+ @RestResource(serializers=SimpleJsonSerializer.class, parsers=JsonParser.class, defaultAccept="text/json")
public static class A {
@RestMethod(name=PUT, path="/String")
public String a01(@Body String b) {
@@ -195,7 +195,7 @@ public class BodyAnnotationTest {
}
@Test
public void a08b_onParameter_Map_noContentType() throws Exception {
- a.put("/Map", "(foo=123)").execute().assertBody("{foo:123}"); // Uses part parser.
+ a.put("/Map", "(foo=123)").execute().assertStatus(415);
}
@Test
public void a09a_onParameter_enum() throws Exception {
@@ -211,7 +211,7 @@ public class BodyAnnotationTest {
}
@Test
public void a11b_onParameter_Bean_noContentType() throws Exception {
- a.put("/Bean", "(f1=a)").execute().assertBody("{f1:'a'}"); // Uses part parser.
+ a.put("/Bean", "(f1=a)").execute().assertStatus(415);
}
@Test
public void a12a_onParameter_InputStream() throws Exception {
@@ -264,7 +264,7 @@ public class BodyAnnotationTest {
// @Body on POJO
//=================================================================================================================
- @RestResource(serializers=SimpleJsonSerializer.class, parsers=JsonParser.class)
+ @RestResource(serializers=SimpleJsonSerializer.class, parsers=JsonParser.class, defaultAccept="application/json")
public static class B {
@RestMethod(name=PUT, path="/StringTransform")
public B01 b01(B01 b) {
@@ -328,7 +328,7 @@ public class BodyAnnotationTest {
}
@Test
public void b02b_onPojo_Bean_noContentType() throws Exception {
- b.put("/Bean", "(f1=a)").execute().assertBody("{f1:'a'}"); // Uses part parser.
+ b.put("/Bean", "(f1=a)").execute().assertStatus(415);
}
@Test
public void b03a_onPojo_BeanList() throws Exception {
@@ -336,7 +336,7 @@ public class BodyAnnotationTest {
}
@Test
public void b03b_onPojo_BeanList_noContentType() throws Exception {
- b.put("/BeanList", "(f1=a)").execute().assertBody("[{f1:'a'}]"); // Uses part parser.
+ b.put("/BeanList", "(f1=a)").execute().assertStatus(415);
}
@Test
public void b04a_onPojo_InputStreamTransform() throws Exception {
@@ -609,7 +609,7 @@ public class BodyAnnotationTest {
// Complex POJOs
//=================================================================================================================
- @RestResource(serializers=SimpleJsonSerializer.class, parsers=JsonParser.class)
+ @RestResource(serializers=SimpleJsonSerializer.class, parsers=JsonParser.class, defaultAccept="application/json")
public static class E {
@RestMethod(name=PUT, path="/B")
public DTOs.B testPojo1(@Body DTOs.B b) {
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 9a58da7..bd9bd43 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
@@ -21,8 +21,8 @@ import org.apache.juneau.*;
import org.apache.juneau.dto.swagger.*;
import org.apache.juneau.http.annotation.*;
import org.apache.juneau.json.*;
+import org.apache.juneau.oapi.*;
import org.apache.juneau.rest.mock.*;
-import org.apache.juneau.rest.testutils.*;
import org.apache.juneau.utils.*;
import org.junit.*;
import org.junit.runners.*;
@@ -85,214 +85,68 @@ public class ResponseAnnotationTest {
// @Response(usePartSerializer)
//-----------------------------------------------------------------------------------------------------------------
- @RestResource(partSerializer=XPartSerializer.class)
+ @RestResource(serializers=OpenApiSerializer.class,defaultAccept="text/openapi")
public static class B {
- @Response(usePartSerializer=true)
+ @Response
@RestMethod
public String b01() {
return "foo";
}
- @Response(usePartSerializer=false)
- @RestMethod
- public String b02() {
- return "foo";
- }
@RestMethod
public B03 b03() {
return new B03();
}
@RestMethod
- public B04 b04() {
- return new B04();
- }
- @RestMethod
public String b05() throws B05 {
throw new B05();
}
@RestMethod
- public String b06() throws B06 {
- throw new B06();
- }
- @RestMethod
- public void b07(@Response(usePartSerializer=true) Value<String> value) {
- value.set("foo");
- }
- @RestMethod
- public void b08(@Response(usePartSerializer=false) Value<String> value) {
+ public void b07(@Response Value<String> value) {
value.set("foo");
}
}
- @Response(usePartSerializer=true)
+ @Response
public static class B03 {
@Override
public String toString() {return "foo";}
}
- @Response(usePartSerializer=false)
- public static class B04 {
- @Override
- public String toString() {return "foo";}
- }
-
- @Response(usePartSerializer=true)
+ @Response
public static class B05 extends Exception {
@Override
public String toString() {return "foo";}
}
- @Response(usePartSerializer=false)
- public static class B06 extends Exception {
- @Override
- public String toString() {return "foo";}
- }
-
static MockRest b = MockRest.create(B.class);
@Test
public void b01_useOnMethod() throws Exception {
- b.get("/b01").execute().assertStatus(200).assertBody("xfoox");
- }
- @Test
- public void b02_dontUseOnMethod() throws Exception {
- b.get("/b02").execute().assertStatus(200).assertBody("foo");
+ b.get("/b01").execute().assertStatus(200).assertBody("foo");
}
@Test
public void b03_useOnClass() throws Exception {
- b.get("/b03").execute().assertStatus(200).assertBody("xfoox");
- }
- @Test
- public void b04_dontUseOnClass() throws Exception {
- b.get("/b04").execute().assertStatus(200).assertBody("foo");
+ b.get("/b03").execute().assertStatus(200).assertBody("foo");
}
@Test
public void b05_useOnThrown() throws Exception {
- b.get("/b05").execute().assertStatus(500).assertBody("xfoox");
- }
- @Test
- public void b06_dontUseOnThrown() throws Exception {
- b.get("/b06").execute().assertStatus(500).assertBodyContains("foo");
+ b.get("/b05").execute().assertStatus(500).assertBody("foo");
}
@Test
public void b07_useOnParameter() throws Exception {
- b.get("/b07").execute().assertStatus(200).assertBody("xfoox");
+ b.get("/b07").execute().assertStatus(200).assertBody("foo");
}
- @Test
- public void b08_dontUseOnParameter() throws Exception {
- b.get("/b08").execute().assertStatus(200).assertBody("foo");
- }
-
- //-----------------------------------------------------------------------------------------------------------------
- // @Response(partSerializer)
- //-----------------------------------------------------------------------------------------------------------------
- @RestResource
- public static class C {
-
- @Response(partSerializer=XPartSerializer.class)
- @RestMethod
- public String c01() {
- return "foo";
- }
- @ResponseBody
- @RestMethod
- public String c02() {
- return "foo";
- }
- @RestMethod
- public C03 c03() {
- return new C03();
- }
- @RestMethod
- public C04 c04() {
- return new C04();
- }
- @RestMethod
- public String c05() throws C05 {
- throw new C05();
- }
- @RestMethod
- public String c06() throws C06 {
- throw new C06();
- }
- @RestMethod
- public void c07(@Response(partSerializer=XPartSerializer.class) Value<String> value) {
- value.set("foo");
- }
- @RestMethod
- public void c08(@Response Value<String> value) {
- value.set("foo");
- }
- }
-
- @Response(partSerializer=XPartSerializer.class)
- public static class C03 {
- @Override
- public String toString() {return "foo";}
- }
-
- @Response
- public static class C04 {
- @Override
- public String toString() {return "foo";}
- }
-
- @Response(partSerializer=XPartSerializer.class)
- public static class C05 extends Exception {
- @Override
- public String toString() {return "foo";}
- }
-
- @Response
- public static class C06 extends Exception {
- @Override
- public String toString() {return "foo";}
- }
-
- static MockRest c = MockRest.create(C.class);
-
- @Test
- public void c01_useOnMethod() throws Exception {
- c.get("/c01").execute().assertStatus(200).assertBody("xfoox");
- }
- @Test
- public void c02_dontUseOnMethod() throws Exception {
- c.get("/c02").execute().assertStatus(200).assertBody("foo");
- }
- @Test
- public void c03_useOnClass() throws Exception {
- c.get("/c03").execute().assertStatus(200).assertBody("xfoox");
- }
- @Test
- public void c04_dontUseOnClass() throws Exception {
- c.get("/c04").execute().assertStatus(200).assertBody("foo");
- }
- @Test
- public void c05_useOnThrown() throws Exception {
- c.get("/c05").execute().assertStatus(500).assertBody("xfoox");
- }
- @Test
- public void c06_dontUseOnThrown() throws Exception {
- c.get("/c06").execute().assertStatus(500).assertBodyContains("foo");
- }
- @Test
- public void c07_useOnParameter() throws Exception {
- c.get("/c07").execute().assertStatus(200).assertBody("xfoox");
- }
- @Test
- public void c08_dontUseOnParameter() throws Exception {
- c.get("/c08").execute().assertStatus(200).assertBody("foo");
- }
//-----------------------------------------------------------------------------------------------------------------
// @Response(partSerializer) with schemas
//-----------------------------------------------------------------------------------------------------------------
- @RestResource
+ @RestResource(serializers=OpenApiSerializer.class,defaultAccept="text/openapi")
public static class D {
- @Response(schema=@Schema(collectionFormat="pipes"),usePartSerializer=true)
+ @Response(schema=@Schema(collectionFormat="pipes"))
@RestMethod
public String[] d01() {
return new String[]{"foo","bar"};
@@ -306,10 +160,10 @@ public class ResponseAnnotationTest {
throw new D03();
}
@RestMethod
- public void d04(@Response(schema=@Schema(collectionFormat="pipes"),usePartSerializer=true) Value<String[]> value) {
+ public void d04(@Response(schema=@Schema(collectionFormat="pipes")) Value<String[]> value) {
value.set(new String[]{"foo","bar"});
}
- @Response(schema=@Schema(type="string",format="byte"),usePartSerializer=true)
+ @Response(schema=@Schema(type="string",format="byte"))
@RestMethod
public byte[] d05() {
return "foo".getBytes();
@@ -323,33 +177,33 @@ public class ResponseAnnotationTest {
throw new D07();
}
@RestMethod
- public void d08(@Response(schema=@Schema(type="string",format="byte"),usePartSerializer=true) Value<byte[]> value) {
+ public void d08(@Response(schema=@Schema(type="string",format="byte")) Value<byte[]> value) {
value.set("foo".getBytes());
}
}
- @Response(schema=@Schema(type="array",collectionFormat="pipes"),usePartSerializer=true)
+ @Response(schema=@Schema(type="array",collectionFormat="pipes"))
public static class D02 {
public String[] toStringArray() {
return new String[]{"foo","bar"};
}
}
- @Response(schema=@Schema(type="array",collectionFormat="pipes"),usePartSerializer=true)
+ @Response(schema=@Schema(type="array",collectionFormat="pipes"))
public static class D03 extends Exception {
public String[] toStringArray() {
return new String[]{"foo","bar"};
}
}
- @Response(schema=@Schema(format="byte"),usePartSerializer=true)
+ @Response(schema=@Schema(format="byte"))
public static class D06 {
public byte[] toBytes() {
return "foo".getBytes();
}
}
- @Response(schema=@Schema(format="byte"),usePartSerializer=true)
+ @Response(schema=@Schema(format="byte"))
public static class D07 extends Exception {
public byte[] toBytes() {
return "foo".getBytes();
@@ -450,7 +304,7 @@ public class ResponseAnnotationTest {
// Basic swagger
//-----------------------------------------------------------------------------------------------------------------
- @RestResource
+ @RestResource(serializers=OpenApiSerializer.class,defaultAccept="text/openapi")
public static class F {
@RestMethod
public void f01(@Response(schema=@Schema(description="f01", collectionFormat="pipes")) Value<List<Integer>> body) {
@@ -562,7 +416,7 @@ public class ResponseAnnotationTest {
@Test
public void g01b_basic_onParameter_swagger() throws Exception {
ResponseInfo ri = sg.getResponseInfo("/g01", "get", 200);
- assertObjectEquals("{description:'OK'}", ri);
+ assertObjectEquals("{description:'OK',schema:{type:'array',items:{type:'integer',format:'int32'}}}", ri);
}
@Test
public void g02a_basic_onType() throws Exception {
@@ -571,7 +425,7 @@ public class ResponseAnnotationTest {
@Test
public void g02b_basic_onParameter_swagger() throws Exception {
ResponseInfo ri = sg.getResponseInfo("/g02", "get", 200);
- assertObjectEquals("{description:'OK'}", ri);
+ assertObjectEquals("{description:'OK',schema:{type:'array',items:{type:'integer',format:'int32'}}}", ri);
}
@Test
public void g03a_basic_onMethod() throws Exception {
@@ -580,7 +434,7 @@ public class ResponseAnnotationTest {
@Test
public void g03b_basic_onParameter_swagger() throws Exception {
ResponseInfo ri = sg.getResponseInfo("/g03", "get", 200);
- assertObjectEquals("{description:'OK'}", ri);
+ assertObjectEquals("{description:'OK',schema:{type:'array',items:{type:'integer',format:'int32'}}}", ri);
}
@Test
public void g04a_basic_onReturnedType() throws Exception {
@@ -589,159 +443,13 @@ public class ResponseAnnotationTest {
@Test
public void g04b_basic_onParameter_swagger() throws Exception {
ResponseInfo ri = sg.getResponseInfo("/g04", "get", 200);
- assertObjectEquals("{description:'OK'}", ri);
+ assertObjectEquals("{description:'OK',schema:{type:'array',items:{type:'integer',format:'int32'}}}", ri);
}
//=================================================================================================================
// PartSerializers
//=================================================================================================================
- //-----------------------------------------------------------------------------------------------------------------
- // @ResponseBody(usePartSerializer), partSerializer on class
- //-----------------------------------------------------------------------------------------------------------------
-
- @RestResource(partSerializer=XPartSerializer.class)
- public static class H {
- @RestMethod
- public void h01(@Response(usePartSerializer=true) Value<List<Integer>> body) {
- body.set(AList.create(1,2));
- }
- @RestMethod
- public void h02(Value<H01> body) {
- body.set(new H01());
- }
- @RestMethod
- @Response(usePartSerializer=true)
- public List<Integer> h03() {
- return AList.create(1,2);
- }
- @RestMethod
- public H01 h04() {
- return new H01();
- }
- }
-
- @Response(usePartSerializer=true)
- public static class H01 extends ArrayList<Integer> {
- public H01() {
- add(1);
- add(2);
- }
- }
-
- static MockRest h = MockRest.create(H.class);
- static Swagger sh = getSwagger(H.class);
-
- @Test
- public void h01a_basic_onParameter() throws Exception {
- h.get("/h01").execute().assertStatus(200).assertBody("x[1, 2]x");
- }
- @Test
- public void h01b_basic_onParameter_swagger() throws Exception {
- ResponseInfo ri = sh.getResponseInfo("/h01", "get", 200);
- assertObjectEquals("{description:'OK',schema:{type:'array',items:{type:'integer',format:'int32'}}}", ri);
- }
- @Test
- public void h02a_basic_onType() throws Exception {
- h.get("/h02").execute().assertStatus(200).assertBody("x[1, 2]x");
- }
- @Test
- public void h02b_basic_onParameter_swagger() throws Exception {
- ResponseInfo ri = sh.getResponseInfo("/h02", "get", 200);
- assertObjectEquals("{description:'OK',schema:{type:'array',items:{type:'integer',format:'int32'}}}", ri);
- }
- @Test
- public void h03a_basic_onMethod() throws Exception {
- h.get("/h03").execute().assertStatus(200).assertBody("x[1, 2]x");
- }
- @Test
- public void h03b_basic_onParameter_swagger() throws Exception {
- ResponseInfo ri = sh.getResponseInfo("/h03", "get", 200);
- assertObjectEquals("{description:'OK',schema:{type:'array',items:{type:'integer',format:'int32'}}}", ri);
- }
- @Test
- public void h04a_basic_onReturnedType() throws Exception {
- h.get("/h04").execute().assertStatus(200).assertBody("x[1, 2]x");
- }
- @Test
- public void h04b_basic_onParameter_swagger() throws Exception {
- ResponseInfo ri = sh.getResponseInfo("/h04", "get", 200);
- assertObjectEquals("{description:'OK',schema:{type:'array',items:{type:'integer',format:'int32'}}}", ri);
- }
-
- //-----------------------------------------------------------------------------------------------------------------
- // @ResponseBody(usePartSerializer), partSerializer on part.
- //-----------------------------------------------------------------------------------------------------------------
-
- @RestResource
- public static class I {
- @RestMethod
- public void i01(@Response(partSerializer=XPartSerializer.class) Value<List<Integer>> body) {
- body.set(AList.create(1,2));
- }
- @RestMethod
- public void i02(Value<I01> body) {
- body.set(new I01());
- }
- @RestMethod
- @Response(partSerializer=XPartSerializer.class)
- public List<Integer> i03() {
- return AList.create(1,2);
- }
- @RestMethod
- public I01 i04() {
- return new I01();
- }
- }
-
- @Response(partSerializer=XPartSerializer.class)
- public static class I01 extends ArrayList<Integer> {
- public I01() {
- add(1);
- add(2);
- }
- }
-
- static MockRest i = MockRest.create(I.class);
- static Swagger si = getSwagger(I.class);
-
- @Test
- public void i01a_basic_onParameter() throws Exception {
- i.get("/i01").execute().assertStatus(200).assertBody("x[1, 2]x");
- }
- @Test
- public void i01b_basic_onParameter_swagger() throws Exception {
- ResponseInfo ri = si.getResponseInfo("/i01", "get", 200);
- assertObjectEquals("{description:'OK',schema:{type:'array',items:{type:'integer',format:'int32'}}}", ri);
- }
- @Test
- public void i02a_basic_onType() throws Exception {
- i.get("/i02").execute().assertStatus(200).assertBody("x[1, 2]x");
- }
- @Test
- public void i02b_basic_onParameter_swagger() throws Exception {
- ResponseInfo ri = si.getResponseInfo("/i02", "get", 200);
- assertObjectEquals("{description:'OK',schema:{type:'array',items:{type:'integer',format:'int32'}}}", ri);
- }
- @Test
- public void i03a_basic_onMethod() throws Exception {
- i.get("/i03").execute().assertStatus(200).assertBody("x[1, 2]x");
- }
- @Test
- public void i03b_basic_onParameter_swagger() throws Exception {
- ResponseInfo ri = si.getResponseInfo("/i03", "get", 200);
- assertObjectEquals("{description:'OK',schema:{type:'array',items:{type:'integer',format:'int32'}}}", ri);
- }
- @Test
- public void i04a_basic_onReturnedType() throws Exception {
- i.get("/i04").execute().assertStatus(200).assertBody("x[1, 2]x");
- }
- @Test
- public void i04b_basic_onParameter_swagger() throws Exception {
- ResponseInfo ri = si.getResponseInfo("/i04", "get", 200);
- assertObjectEquals("{description:'OK',schema:{type:'array',items:{type:'integer',format:'int32'}}}", ri);
- }
-
//=================================================================================================================
// @Response on RestMethod
@@ -751,8 +459,7 @@ public class ResponseAnnotationTest {
public static class J {
@RestMethod(name="POST")
- @Response(usePartSerializer=true)
- public String j01(@Body(usePartParser=true) String body) {
+ public String j01(@Body String body) {
return body;
}
}
@@ -760,7 +467,7 @@ public class ResponseAnnotationTest {
@Test
public void j01a_basic() throws Exception {
- j.post("/j01", "foo").execute().assertStatus(200).assertBody("foo").assertHeader("Content-Type", "text/plain");
+ j.post("/j01", "foo").accept("text/plain").execute().assertStatus(200).assertBody("foo").assertHeader("Content-Type", "text/plain");
}
@@ -946,7 +653,7 @@ public class ResponseAnnotationTest {
@RestMethod
public SB01 sb01b() {return null;}
- @Response(usePartSerializer=true)
+ @Response
public static class SB02 {
public String f1;
}
@@ -955,7 +662,7 @@ public class ResponseAnnotationTest {
@RestMethod
public SB02 sb02b() {return null;}
- @Response(usePartSerializer=true)
+ @Response
public static class SB03 extends LinkedList<String> {
private static final long serialVersionUID = 1L;
}
@@ -964,7 +671,7 @@ public class ResponseAnnotationTest {
@RestMethod
public SB03 sb03b() {return null;}
- @Response(usePartSerializer=true)
+ @Response
public static class SB04 {}
@RestMethod
public void sb04a(Value<SB04> b) {}
diff --git a/juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/testutils/XPartSerializer.java b/juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/testutils/XPartSerializer.java
index 4cbe638..bb533f0 100644
--- a/juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/testutils/XPartSerializer.java
+++ b/juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/testutils/XPartSerializer.java
@@ -18,10 +18,11 @@ import org.apache.juneau.serializer.*;
/**
* Test serializer.
*/
-public class XPartSerializer implements HttpPartSerializer {
+public class XPartSerializer extends BaseHttpPartSerializer {
+
@Override
- public HttpPartSerializerSession createSession(SerializerSessionArgs args) {
- return new HttpPartSerializerSession() {
+ public HttpPartSerializerSession createPartSession(SerializerSessionArgs args) {
+ return new BaseHttpPartSerializerSession() {
@Override
public String serialize(HttpPartType partType, HttpPartSchema schema, Object value) throws SerializeException, SchemaValidationException {
return "x" + value + "x";
@@ -31,11 +32,6 @@ public class XPartSerializer implements HttpPartSerializer {
@Override
public String serialize(HttpPartType partType, HttpPartSchema schema, Object value) throws SchemaValidationException, SerializeException {
- return createSession(null).serialize(partType, schema, value);
- }
-
- @Override
- public String serialize(HttpPartSchema schema, Object value) throws SchemaValidationException, SerializeException {
- return createSession(null).serialize(null, schema, value);
+ return createPartSession().serialize(partType, schema, value);
}
}
\ No newline at end of file