Class OpenApi
OpenApiSerializer
and OpenApiParser
into a single class with convenience read/write methods.
The general idea is to combine a single serializer and parser inside a simplified API for reading and writing POJOs.
Examples:
See Also:
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
Serializes a Java object to an OpenApi string.static Object
Serializes a Java object to an OpenApi output.static String
of
(HttpPartSchema schema, Object object) Serializes a Java object to an OpenApi output.static <T> T
Parses an OpenApi input object to the specified Java type.static <T> T
Parses an OpenApi input object to the specified Java type.static <T> T
Parses an OpenApi input string to the specified type.static <T> T
Parses an OpenApi input string to the specified Java type.static <T> T
to
(HttpPartSchema schema, String input, Class<T> type) Parses an OpenApi input object to the specified Java type.Methods inherited from class org.apache.juneau.marshaller.CharMarshaller
read, read, write
Methods inherited from class org.apache.juneau.marshaller.Marshaller
getParser, getSerializer, read, read, write
-
Field Details
-
DEFAULT
Default reusable instance.
-
-
Constructor Details
-
OpenApi
Constructor.- Parameters:
s
- The serializer to use for serializing output.
Must not benull .p
- The parser to use for parsing input.
Must not benull .
-
OpenApi
public OpenApi()Constructor.
-
-
Method Details
-
to
Parses an OpenApi input string to the specified type.A shortcut for calling
.DEFAULT .read(input ,type )- Type Parameters:
T
- The class type of the object being created.- Parameters:
input
- The input.type
- The object type to create.- Returns:
- The parsed object.
- Throws:
ParseException
- Malformed input encountered.
-
to
Parses an OpenApi input object to the specified Java type.A shortcut for calling
.DEFAULT .read(input ,type )- Type Parameters:
T
- The class type of the object being created.- Parameters:
input
- The input.
Can be any of the following types:null Reader
CharSequence
InputStream
containing UTF-8 encoded text (or charset defined byReaderParser.Builder.streamCharset(Charset)
property value).
containing UTF-8 encoded text (or charset defined bybyte []ReaderParser.Builder.streamCharset(Charset)
property value).File
containing system encoded text (or charset defined byReaderParser.Builder.fileCharset(Charset)
property value).
type
- The object type to create.- Returns:
- The parsed object.
- Throws:
ParseException
- Malformed input encountered.IOException
- Thrown by underlying stream.
-
to
public static <T> T to(HttpPartSchema schema, String input, Class<T> type) throws ParseException, IOException Parses an OpenApi input object to the specified Java type.A shortcut for calling
.DEFAULT .read(input ,type )- Type Parameters:
T
- The class type of the object being created.- Parameters:
schema
- The part type schema. Can benull .input
- The input.type
- The object type to create.- Returns:
- The parsed object.
- Throws:
ParseException
- Malformed input encountered.IOException
- Thrown by underlying stream.
-
to
Parses an OpenApi input string to the specified Java type.A shortcut for calling
.DEFAULT .read(input ,type ,args )- Type Parameters:
T
- The class type of the object to create.- Parameters:
input
- The input.type
- The object type to create.
Can be any of the following:ClassMeta
,Class
,ParameterizedType
,GenericArrayType
args
- The type arguments of the class if it's a collection or map.
Can be any of the following:ClassMeta
,Class
,ParameterizedType
,GenericArrayType
Ignored if the main type is not a map or collection.- Returns:
- The parsed object.
- Throws:
ParseException
- Malformed input encountered.- See Also:
-
to
Parses an OpenApi input object to the specified Java type.A shortcut for calling
.DEFAULT .read(input ,type ,args )- Type Parameters:
T
- The class type of the object to create.- Parameters:
input
- The input.
Can be any of the following types:null Reader
CharSequence
InputStream
containing UTF-8 encoded text (or charset defined byReaderParser.Builder.streamCharset(Charset)
property value).
containing UTF-8 encoded text (or charset defined bybyte []ReaderParser.Builder.streamCharset(Charset)
property value).File
containing system encoded text (or charset defined byReaderParser.Builder.fileCharset(Charset)
property value).
type
- The object type to create.
Can be any of the following:ClassMeta
,Class
,ParameterizedType
,GenericArrayType
args
- The type arguments of the class if it's a collection or map.
Can be any of the following:ClassMeta
,Class
,ParameterizedType
,GenericArrayType
Ignored if the main type is not a map or collection.- Returns:
- The parsed object.
- Throws:
ParseException
- Malformed input encountered.IOException
- Thrown by underlying stream.- See Also:
-
of
Serializes a Java object to an OpenApi string.A shortcut for calling
.DEFAULT .write(object )- Parameters:
object
- The object to serialize.- Returns:
- The serialized object.
- Throws:
SerializeException
- If a problem occurred trying to convert the output.
-
of
Serializes a Java object to an OpenApi output.A shortcut for calling
.DEFAULT .write(output )- Parameters:
object
- The object to serialize.output
- The output object.
Can be any of the following types:Writer
OutputStream
- Output will be written as UTF-8 encoded stream.File
- Output will be written as system-default encoded stream.StringBuilder
- Output will be written to the specified string builder.
- Returns:
- The output object.
- Throws:
SerializeException
- If a problem occurred trying to convert the output.IOException
- Thrown by underlying stream.
-
of
Serializes a Java object to an OpenApi output.A shortcut for calling
.DEFAULT .write(output )- Parameters:
schema
- The part schema. Can benull .object
- The object to serialize.- Returns:
- The output object.
- Throws:
SerializeException
- If a problem occurred trying to convert the output.
-