public class SchemaObjectBuilder extends Object
The Schema Object allows the definition of input and output data types. These types can be objects, but also primitives and arrays. This object is an extended subset of the JSON Schema Specification Wright Draft 00.
For more information about the properties, see JSON Schema Core and JSON Schema Validation. Unless stated otherwise, the property definitions follow the JSON Schema.
Constructor and Description |
---|
SchemaObjectBuilder() |
public SchemaObjectBuilder withTitle(String title)
public SchemaObjectBuilder withMultipleOf(Double multipleOf)
public SchemaObjectBuilder withMaximum(Double maximum)
public SchemaObjectBuilder withExclusiveMaximum(Boolean exclusiveMaximum)
public SchemaObjectBuilder withMinimum(Double minimum)
public SchemaObjectBuilder withExclusiveMinimum(Boolean exclusiveMinimum)
public SchemaObjectBuilder withMaxLength(Integer maxLength)
public SchemaObjectBuilder withMinLength(Integer minLength)
public SchemaObjectBuilder withPattern(Pattern pattern)
public SchemaObjectBuilder withMaxItems(Integer maxItems)
public SchemaObjectBuilder withMinItems(Integer minItems)
public SchemaObjectBuilder withUniqueItems(Boolean uniqueItems)
public SchemaObjectBuilder withMaxProperties(Integer maxProperties)
public SchemaObjectBuilder withMinProperties(Integer minProperties)
public SchemaObjectBuilder withRequired(List<String> required)
public SchemaObjectBuilder withEnumValue(List<Object> enumValue)
public SchemaObjectBuilder withType(String type)
public SchemaObjectBuilder withAllOf(List<SchemaObject> allOf)
public SchemaObjectBuilder withOneOf(List<SchemaObject> oneOf)
public SchemaObjectBuilder withAnyOf(List<SchemaObject> anyOf)
public SchemaObjectBuilder withNot(List<SchemaObject> not)
public SchemaObjectBuilder withItems(SchemaObject items)
public SchemaObjectBuilder withProperties(Map<String,SchemaObject> properties)
public SchemaObjectBuilder withAdditionalProperties(Object additionalProperties)
public SchemaObjectBuilder withDescription(String description)
public SchemaObjectBuilder withFormat(String format)
public SchemaObjectBuilder withDefaultValue(Object defaultValue)
public SchemaObjectBuilder withNullable(Boolean nullable)
nullable
- Allows sending a null
value for the defined schema. Default value is false
.public SchemaObjectBuilder withDiscriminator(DiscriminatorObject discriminator)
discriminator
- Adds support for polymorphism. The discriminator is an object name that is used to differentiate between other schemas which may satisfy the payload description.public SchemaObjectBuilder withReadOnly(Boolean readOnly)
readOnly
- Relevant only for Schema "properties"
definitions. Declares the property as "read only".
This means that it MAY be sent as part of a response but SHOULD NOT be sent as part of the request.
If the property is marked as readOnly
being true
and is in the required
list, the required
will take effect on the response only. A property MUST NOT be marked
as both readOnly
and writeOnly
being true
. Default value is false
.public SchemaObjectBuilder withWriteOnly(Boolean writeOnly)
writeOnly
- Relevant only for Schema "properties"
definitions. Declares the property as "write only".
Therefore, it MAY be sent as part of a request but SHOULD NOT be sent as part of the response. If
the property is marked as writeOnly
being true
and is in the
required
list, the required
will take effect on the request only. A property
MUST NOT be marked as both readOnly
and writeOnly
being true
.
Default value is false
.public SchemaObjectBuilder withXml(XmlObject xml)
xml
- This MAY be used only on properties schemas. It has no effect on root schemas. Adds additional metadata
to describe the XML representation of this property.public SchemaObjectBuilder withExternalDocs(ExternalDocumentationObject externalDocs)
externalDocs
- Additional external documentation for this schema.public SchemaObjectBuilder withExample(Object example)
example
- A free-form property to include an example of an instance for this schema. To represent examples
that cannot be naturally represented in JSON or YAML, a string value can be used to contain the
example with escaping where necessary.public SchemaObjectBuilder withDeprecated(Boolean deprecated)
deprecated
- Specifies that a schema is deprecated and SHOULD be transitioned out of usage. Default value is false
.public SchemaObject build()
public static SchemaObjectBuilder schemaObject()
SchemaObject
public static SchemaObjectBuilder schemaObjectFrom(Class<?> from)
SchemaObject
with the type and format based on the given classfrom
- Type type to build from, e.g. if the type is String.class
then the type
will
be set as string
.Copyright © 2017–2019. All rights reserved.